HopeLiang commited on
Commit
7e6830a
·
1 Parent(s): c98376b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -12
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
- iface = gr.Interface(
13
- fn=transcribe,
14
- inputs=gr.Audio(source="microphone", type="filepath"),
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.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()