Spaces:
Running
on
Zero
Running
on
Zero
Commit
•
558c54d
1
Parent(s):
7bd176a
Add app
Browse files
app.py
CHANGED
@@ -65,7 +65,6 @@ frame_rate = model.audio_encoder.config.frame_rate
|
|
65 |
|
66 |
|
67 |
def generate_response(audio):
|
68 |
-
yield None, None
|
69 |
gr.Info("Transcribing Audio", duration=5)
|
70 |
question = client.automatic_speech_recognition(audio).text
|
71 |
|
@@ -73,12 +72,13 @@ def generate_response(audio):
|
|
73 |
"Someone will present to you a situation or question and your job "
|
74 |
"is to answer with a cryptic addage or proverb such as "
|
75 |
"'curiosity killed the cat' or 'The early bird gets the worm'."
|
76 |
-
"Keep your answers short."
|
77 |
-
|
|
|
78 |
|
79 |
-
response = client.chat_completion(messages, max_tokens=
|
80 |
response = response.choices[0].message.content
|
81 |
-
|
82 |
|
83 |
@spaces.GPU
|
84 |
def generate_base(answer):
|
@@ -129,6 +129,6 @@ with gr.Blocks() as block:
|
|
129 |
with gr.Row():
|
130 |
audio_in = gr.Audio(label="Speak you question", sources="microphone", type="filepath")
|
131 |
|
132 |
-
audio_in.stop_recording(generate_response, audio_in, state).then(fn=generate_base, inputs=state, outputs=[answer, audio_out])
|
133 |
|
134 |
block.launch()
|
|
|
65 |
|
66 |
|
67 |
def generate_response(audio):
|
|
|
68 |
gr.Info("Transcribing Audio", duration=5)
|
69 |
question = client.automatic_speech_recognition(audio).text
|
70 |
|
|
|
72 |
"Someone will present to you a situation or question and your job "
|
73 |
"is to answer with a cryptic addage or proverb such as "
|
74 |
"'curiosity killed the cat' or 'The early bird gets the worm'."
|
75 |
+
"Keep your answers short. "
|
76 |
+
"For example, 'Magic 8 Ball, should I get a dog?', 'A dog is ready for you but are you ready for the dog?'")},
|
77 |
+
{"role": "user", "content": f"Magic 8 Ball, {question}"}]
|
78 |
|
79 |
+
response = client.chat_completion(messages, max_tokens=32, seed=random.randint(1, 5000))
|
80 |
response = response.choices[0].message.content
|
81 |
+
return response, None, None
|
82 |
|
83 |
@spaces.GPU
|
84 |
def generate_base(answer):
|
|
|
129 |
with gr.Row():
|
130 |
audio_in = gr.Audio(label="Speak you question", sources="microphone", type="filepath")
|
131 |
|
132 |
+
audio_in.stop_recording(generate_response, audio_in, [state, answer, audio_out]).then(fn=generate_base, inputs=state, outputs=[answer, audio_out])
|
133 |
|
134 |
block.launch()
|