khalidey commited on
Commit
b152137
1 Parent(s): 5b8fd04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -12
app.py CHANGED
@@ -9,15 +9,32 @@ 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
- iface = gr.Interface(
13
- fn=transcribe,
14
- inputs=gr.Audio(source="microphone", type="filepath", label="Audio from Microphone"),
15
- outputs=[
16
- gr.Textbox(label='Transcribed Speech'),
17
- gr.Textbox(label='Swedish GPT Generated Speech')
18
- ],
19
- title="Whisper Small Swedish + Swedish GPT",
20
- description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model & text generation with Swedish GPT.",
21
- )
22
-
23
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.Markdown("Whisper Small Swedish + Swedish GPT")
14
+ gr.Markdown("Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model & text generation with Swedish GPT.")
15
+ with gr.TabItem("Upload from disk"):
16
+ upload_file = gr.Audio(source="upload", type="filepath",label="Upload from disk")
17
+ upload_button = gr.Button("Submit for recognition")
18
+ upload_outputs = [
19
+ gr.Textbox(label="Recognized speech from uploaded file"),
20
+ gr.Textbox(label="Swedish-gpt generated speech from uploaded file")
21
+ ]
22
+ with gr.TabItem("Record from microphone"):
23
+ record_file = gr.Audio(source="microphone", type="filepath",label="Record from microphone")
24
+ record_button = gr.Button("Submit for recognition")
25
+ record_outputs = [
26
+ gr.Textbox(label="Recognized speech from recordings"),
27
+ gr.Textbox(label="Swedish-gpt generated speech from recordings")
28
+ ]
29
+ upload_button.click(
30
+ fn=transcribe,
31
+ inputs=upload_file,
32
+ outputs=upload_outputs,
33
+ )
34
+ record_button.click(
35
+ fn=transcribe,
36
+ inputs=record_file,
37
+ outputs=record_outputs,
38
+ )
39
+
40
+ demo.launch()