import gradio as gr import os import tempfile from openai import OpenAI # Set an environment variable for key os.environ['OPENAI_API_KEY'] = os.environ.get('OPENAI_API_KEY') client = OpenAI() # add api_key def tts(text): response = client.audio.speech.create( model="tts-1", voice="alloy", input=text, ) # Create a temp file to save the audio with tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) as temp_file: temp_file.write(response.content) # Get the file path of the temp file temp_file_path = temp_file.name return temp_file_path with gr.Blocks() as demo: gr.Markdown("#