You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenAI Text to Speech Test import openai import pyttsx3 # Set up the OpenAI API client openai.api_key = "YOUR_API_KEY" # Initialize the text-to-speech engine engine = pyttsx3.init() # Start a loop to prompt the user for input and speak my response while True: # Get input from the user input_text = input("What would you like to say? ") # Use the OpenAI API to generate a response response = openai.Completion.create( model="text-davinci-002", prompt=input_text, max_tokens=1024, temperature=0.5, ) # Get the generated response as text response_text = response["choices"][0]["text"] # Speak the response out loud engine.say(response_text) engine.runAndWait()