Giter Club home page Giter Club logo

iammarcin / chatgpt-openai-smart-speaker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from olney1/chatgpt-openai-smart-speaker

0.0 0.0 0.0 36 KB

This program uses speech recognition and text-to-speech to enable voice-driven conversations with OpenAI. The user speaks a prompt into the microphone, and the program sends the prompt to OpenAI to generate a response. The response is then converted to an audio file and played back to the user.

License: MIT License

Python 100.00%

chatgpt-openai-smart-speaker's Introduction

Speech recognition and text-to-speech using OpenAI and gTTS

This script allows you to use speech recognition to input a prompt, send the prompt to OpenAI to generate a response, and then use gTTS to convert the response to an audio file and play the audio file.

Prerequisites

  • You need to have a valid OpenAI API key. You can sign up for a free API key at https://beta.openai.com/.
  • You need to install the following packages: openai, gTTS, pyaudio, SpeechRecognition, playsound. You can install these packages using pip install openai gTTS pyaudio SpeechRecognition playsound or use pipenv if you wish to contain a virtual environment.

Usage

  1. Replace YOUR_API_KEY_HERE in the following line with your actual OpenAI API key: openai.api_key = "YOUR_API_KEY_HERE"
  2. Run the script using python smart_speaker.py.
  3. The script will prompt you to say something. Speak a sentence into your microphone. You may need to allow the program permission to access your microphone on a Mac, a prompt should appear when running the program.
  4. The script will send the spoken sentence to OpenAI, generate a response using the text-to-speech model, and play the response as an audio file.

Customization

  • You can change the OpenAI model engine by modifying the value of model_engine. For example, to use the "davinci" engine, set model_engine = "davinci".
  • You can change the language of the generated audio file by modifying the value of language. For example, to generate audio in French, set language = 'fr'.
  • You can adjust the temperature parameter in the following line to control the randomness of the generated response:
response = openai.Completion.create(
engine=model_engine,
prompt=prompt,
max_tokens=1024,
n=1,
temperature=0.7,
)

Higher values of temperature will result in more diverse and random responses, while lower values will result in more deterministic responses.

chatgpt-openai-smart-speaker's People

Contributors

olney1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.