File size: 852 Bytes
abaf86c
 
 
7069d5c
9417b92
abaf86c
 
7069d5c
36c60a1
b23d0f5
7069d5c
abaf86c
57970f1
abaf86c
b4fbd3e
 
 
 
57970f1
 
abaf86c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from transformers import pipeline
import gradio as gr

pipe1 = pipeline(model="khalidey/ID2223_Lab2_Whisper_SV")  # change to "your-username/the-name-you-picked"
pipe2 = pipeline('text-generation', model='birgermoell/swedish-gpt')

def transcribe(audio):
    text = pipe1(audio)["text"]
    generated_text = pipe2(text, max_length = 30, num_return_sequences=2)[0]['generated_text']
    return text, generated_text

iface = gr.Interface(
    fn=transcribe, 
    inputs=gr.Audio(source="microphone", type="filepath"), 
    outputs=[
        gr.Textbox(label='Transcribed Speech'), 
        gr.Textbox(label='Swedish GPT Generated Speech')
    ],
    title="Whisper Small Swedish + Swedish GPT",
    description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model and text generation with Swedish GPT.",
)

iface.launch()