Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- README.md +4 -4
- app.py +20 -0
- requirements.txt +3 -0
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 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
|