Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,15 +9,34 @@ def transcribe(audio):
|
|
| 9 |
generated_text = pipe2(text, max_length=50, num_return_sequences=2)[0]['generated_text']
|
| 10 |
return text, generated_text
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
generated_text = pipe2(text, max_length=50, num_return_sequences=2)[0]['generated_text']
|
| 10 |
return text, generated_text
|
| 11 |
|
| 12 |
+
with gr.Blocks() as demo:
|
| 13 |
+
#gr.Interface(
|
| 14 |
+
# title="Whisper Small Swedish + Swedish GPT",
|
| 15 |
+
# description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model & text generation with Swedish GPT.",
|
| 16 |
+
#)
|
| 17 |
+
with gr.TabItem("Upload from disk"):
|
| 18 |
+
upload_file = gr.Audio(source="upload", type="filepath",label="Upload from disk")
|
| 19 |
+
upload_button = gr.Button("Submit for recognition")
|
| 20 |
+
upload_outputs = [
|
| 21 |
+
gr.Textbox(label="Recognized speech from uploaded file"),
|
| 22 |
+
gr.Textbox(label="Swedish-gpt generated speech from uploaded file")
|
| 23 |
+
]
|
| 24 |
+
with gr.TabItem("Record from microphone"):
|
| 25 |
+
record_file = gr.Audio(source="microphone", type="filepath",label="Record from microphone")
|
| 26 |
+
record_button = gr.Button("Submit for recognition")
|
| 27 |
+
record_outputs = [
|
| 28 |
+
gr.Textbox(label="Recognized speech from recordings"),
|
| 29 |
+
gr.Textbox(label="Swedish-gpt generated speech from recordings")
|
| 30 |
+
]
|
| 31 |
+
upload_button.click(
|
| 32 |
+
fn=transcribe,
|
| 33 |
+
inputs=upload_file
|
| 34 |
+
outputs=upload_outputs
|
| 35 |
+
)
|
| 36 |
+
record_button.click(
|
| 37 |
+
fn=transcribe,
|
| 38 |
+
inputs=record_file
|
| 39 |
+
outputs=record_outputs
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
demo.launch()
|