Update app.py
Browse files
app.py
CHANGED
@@ -135,4 +135,21 @@ def handle_query(audio_or_text: str):
|
|
135 |
# --- Gradio UI ---
|
136 |
with gr.Blocks() as demo:
|
137 |
gr.Markdown("## Shop Voice-Box Assistant (Speech In/Out)")
|
138 |
-
inp = gr.Audio(sources=["microphone"], type="filepath", label="Speak or type your question")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
# --- Gradio UI ---
|
136 |
with gr.Blocks() as demo:
|
137 |
gr.Markdown("## Shop Voice-Box Assistant (Speech In/Out)")
|
138 |
+
inp = gr.Audio(sources=["microphone"], type="filepath", label="Speak or type your question")
|
139 |
+
out_text = gr.Textbox(label="Answer (text)")
|
140 |
+
out_audio = gr.Audio(label="Answer (speech)")
|
141 |
+
submit = gr.Button("Submit")
|
142 |
+
# Examples
|
143 |
+
gr.Examples(
|
144 |
+
examples=[
|
145 |
+
["What is the max revenue product today?"],
|
146 |
+
["Who invented the light bulb?"],
|
147 |
+
["Tell me a joke about cats."],
|
148 |
+
],
|
149 |
+
inputs=inp,
|
150 |
+
outputs=[out_text, out_audio],
|
151 |
+
)
|
152 |
+
submit.click(fn=handle_query, inputs=inp, outputs=[out_text, out_audio])
|
153 |
+
|
154 |
+
if __name__ == "__main__":
|
155 |
+
demo.launch(share=False, server_name="0.0.0.0", server_port=7860)
|