Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,8 @@ openai.api_key = os.environ["OPEN_AI_KEY"]
|
|
9 |
# takes an audio file from the microphone
|
10 |
# submits the raw audio to OpenAI for
|
11 |
# Speech to Text Translation
|
|
|
|
|
12 |
def transcribe(audio):
|
13 |
audio_file = open(audio, "rb")
|
14 |
# Call the transcribe method with the file-like object
|
@@ -28,6 +30,8 @@ with gr.Blocks() as demo:
|
|
28 |
# Takes the users transcribed audio as a string
|
29 |
# Takes the messages list as a reference
|
30 |
# Sends the ongoing chat log to OpenAI
|
|
|
|
|
31 |
def botResponse(user_input, messages):
|
32 |
# adds the user input to the ongoing chat log
|
33 |
# and submits the log to OpenAI
|
@@ -57,6 +61,8 @@ with gr.Blocks() as demo:
|
|
57 |
# convert the last response into
|
58 |
# an audio file. Returns a path to
|
59 |
# the converted text as an mp3 file
|
|
|
|
|
60 |
def giveVoice(messages):
|
61 |
bot_message=messages[-1]
|
62 |
|
@@ -85,5 +91,7 @@ with gr.Blocks() as demo:
|
|
85 |
gpt_transcript.change(giveVoice, messages, gpt_voice)
|
86 |
|
87 |
|
88 |
-
|
|
|
|
|
89 |
demo.launch(share=False)
|
|
|
9 |
# takes an audio file from the microphone
|
10 |
# submits the raw audio to OpenAI for
|
11 |
# Speech to Text Translation
|
12 |
+
# input from Microphone Component
|
13 |
+
# output to User Input - Textbox Component
|
14 |
def transcribe(audio):
|
15 |
audio_file = open(audio, "rb")
|
16 |
# Call the transcribe method with the file-like object
|
|
|
30 |
# Takes the users transcribed audio as a string
|
31 |
# Takes the messages list as a reference
|
32 |
# Sends the ongoing chat log to OpenAI
|
33 |
+
# input from User Input - Textbox Component
|
34 |
+
# output to Chat Log - Textbox Component
|
35 |
def botResponse(user_input, messages):
|
36 |
# adds the user input to the ongoing chat log
|
37 |
# and submits the log to OpenAI
|
|
|
61 |
# convert the last response into
|
62 |
# an audio file. Returns a path to
|
63 |
# the converted text as an mp3 file
|
64 |
+
# input from messages as a reference
|
65 |
+
# output to GPT Voice - Audio Component
|
66 |
def giveVoice(messages):
|
67 |
bot_message=messages[-1]
|
68 |
|
|
|
91 |
gpt_transcript.change(giveVoice, messages, gpt_voice)
|
92 |
|
93 |
|
94 |
+
# creates a local web server
|
95 |
+
# if share=True creates a public
|
96 |
+
# demo on huggingface.co
|
97 |
demo.launch(share=False)
|