File size: 781 Bytes
483362e
 
 
0cc869c
 
483362e
 
0cc869c
 
 
 
 
483362e
 
 
84d64d1
0cc869c
 
 
483362e
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from transformers import pipeline
import gradio as gr

pipe_fine = pipeline(model="zeihers-mart/whisper-small-swedish-basic") 
pipe_raw = pipeline(model="openai/whisper-small") 

def transcribe(audio):
    text_sv = pipe_fine(audio)["text"]
    print(f"Audio transcribed: {text_sv}")
    text_raw= pipe_raw(audio)["text"]
    print(f"Text translated: {text_raw}")
    return text_sv, text_raw

iface = gr.Interface(
    fn=transcribe, 
    inputs=gr.Audio(sources=["microphone"], type="filepath"), 
    outputs=[gr.Textbox(label="Fine-tuned transcription"),
             gr.Textbox(label="Whisper Transcription")],
    title="Finetuned Whisper Swedish Small",
    description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
)

iface.launch()