Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
import whisperx
|
| 4 |
+
audio_model = whisperx.load_model('tiny', 'cpu', compute_type="float32")
|
| 5 |
+
|
| 6 |
+
def generate_answers(audio_q):
|
| 7 |
+
trans = audio_model.transcribe(aud)
|
| 8 |
+
audio_res = ""
|
| 9 |
+
for seg in trans['segments']:
|
| 10 |
+
audio_res += seg['text']
|
| 11 |
+
audio_res = audio_res.strip()
|
| 12 |
+
return audio_res
|
| 13 |
+
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
|
| 16 |
+
gr.Markdown(
|
| 17 |
+
# Testing wisper
|
| 18 |
+
"""
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# app GUI
|
| 22 |
+
with gr.Row():
|
| 23 |
+
with gr.Column():
|
| 24 |
+
audio_q = gr.Audio(label="Audio Question", value=None, sources=['microphone', 'upload'], type='filepath',show_download_button=True)
|
| 25 |
+
with gr.Row():
|
| 26 |
+
answer = gr.Text(label ='Answer')
|
| 27 |
+
with gr.Row():
|
| 28 |
+
submit = gr.Button("Submit")
|
| 29 |
+
submit.click(generate_answers, inputs=[audio_q], outputs=[answer])
|
| 30 |
+
clear_btn = gr.ClearButton([audio_q, answer])
|
| 31 |
+
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
|
| 34 |
+
demo.launch(share=True)
|