Zoro-2.0-Voice-assistant

This program is a voice assistant that utilizes OpenAI's API to generate responses to user inputs. The voice assistant listens to user input through a microphone, converts it to text using the SpeechRecognition library, and sends the conversation to the OpenAI API for generating a response. The response is then converted back to speech using the pyttsx3 library and played back to the user.

Prerequisites

  • Python 3.x
  • SpeechRecognition library (pip install SpeechRecognition)
  • pyttsx3 library (pip install pyttsx3)
  • OpenAI API key

Setup

  1. Clone the repository or download the source code files.

  2. Install the required libraries by running the following command:

    pip install SpeechRecognition pyttsx3
    
  3. Obtain an OpenAI API key by signing up for the OpenAI GPT-3 service.

  4. Replace "Your API Key" in the code with your actual OpenAI API key.

Usage

  1. Connect a microphone to your computer.

  2. Run the program by executing the python file run command in the terminal.

  3. The voice assistant will start listening for your voice input.

  4. Begin speaking your command or question after the assistant indicates that it is listening.

  5. The voice assistant will process your input, send it to the OpenAI API, and generate a response.

  6. The response will be spoken back to you by the assistant.

  7. The conversation history will be displayed on the console, with user inputs prefixed by user_name: and assistant responses prefixed by bot_name:.

  8. The assistant will continue to listen for new commands until you manually exit the program.

Customization

  • You can customize the user_name and bot_name variables in the code to change the names used in the conversation history.

  • Adjust the parameters in the openai.Completion.create() method to modify the behavior of the OpenAI API model. You can experiment with the temperature, max_tokens, top_p, frequency_penalty, and presence_penalty parameters to control the output generated by the model.

Disclaimer

Please note that the OpenAI GPT-3 model is a language model trained on a large corpus of text and may not always generate accurate or appropriate responses. Exercise caution when using the voice assistant for sensitive or critical tasks. The program is provided as-is without any warranties or guarantees.

Acknowledgments

  • The voice assistant is built using the SpeechRecognition and pyttsx3 libraries.
  • OpenAI for providing the GPT-3 API.