File size: 687 Bytes
8665607
9bf77ab
 
 
 
 
8665607
9bf77ab
8665607
9bf77ab
 
8665607
 
 
 
9bf77ab
 
8665607
 
 
 
 
 
 
 
9bf77ab
8665607
9bf77ab
8665607
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from transformers import (
    WhisperProcessor,
    WhisperForConditionalGeneration,
    pipeline
)

MODEL_ID = "TuniSpeech-AI/whisper-tunisian-dialect"

processor = WhisperProcessor.from_pretrained(MODEL_ID)
model = WhisperForConditionalGeneration.from_pretrained(MODEL_ID)

asr_pipe = pipeline(
    "automatic-speech-recognition",
    model=model,
    tokenizer=processor.tokenizer,
    feature_extractor=processor.feature_extractor
)

def transcribe(audio):
    result = asr_pipe(audio)
    return result["text"]

iface = gr.Interface(
    fn=transcribe,
    inputs=gr.Audio(type="filepath"),
    outputs="text",
    title="Tunisian Dialect ASR"
)

iface.launch()