HopeLiang commited on
Commit
76636ad
·
1 Parent(s): d9ced36

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +4 -4
  2. app.py +20 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: ID2223Lab2
3
- emoji: 📈
4
- colorFrom: gray
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 3.12.0
8
  app_file: app.py
 
1
  ---
2
+ title: ID2223 Lab2 Whisper
3
+ emoji: 🐨
4
+ colorFrom: purple
5
+ colorTo: purple
6
  sdk: gradio
7
  sdk_version: 3.12.0
8
  app_file: app.py
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ generated_text = pipe2(text, max_length = 30, 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=['text', 'text'],
16
+ title="Whisper Small Swedish + Swedish GPT",
17
+ description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model and text generation with Swedish GPT.",
18
+ )
19
+
20
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch