HopeLiang commited on
Commit
d78f3c8
1 Parent(s): 4f2811e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -1,16 +1,22 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
- pipe = pipeline(model="khalidey/ID2223_Lab2_Whisper_SV") # change to "your-username/the-name-you-picked"
 
5
 
6
  def transcribe(audio):
7
- text = pipe(audio)["text"]
8
  return text
9
 
 
 
 
 
 
10
  iface = gr.Interface(
11
  fn=transcribe,
12
  inputs=gr.Audio(source="microphone", type="filepath"),
13
- outputs="text",
14
  title="Whisper Small Swedish",
15
  description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
16
  )
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ pipe1 = pipeline(model="khalidey/ID2223_Lab2_Whisper_SV") # change to "your-username/the-name-you-picked"
5
+ pipe2 = pipeline('text-generation', model='birgermoell/swedish-gpt')
6
 
7
  def transcribe(audio):
8
+ text = pipe1(audio)["text"]
9
  return text
10
 
11
+ def generateText(audio):
12
+ text = pipe1(audio)["text"]
13
+ generated_text = pipe2(text, max_length = 30, num_return_sequences=1)['generated_text']
14
+ return generated_text
15
+
16
  iface = gr.Interface(
17
  fn=transcribe,
18
  inputs=gr.Audio(source="microphone", type="filepath"),
19
+ outputs=["text","generated_text"],
20
  title="Whisper Small Swedish",
21
  description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
22
  )