File size: 665 Bytes
e8e4726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f9d9070
 
 
 
 
 
e8e4726
 
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
import whisper
import gradio as gr

model = whisper.load_hf_model(repo_id="jerpint/whisper", filename="small.pt")


def transcribe(audio, translate):

    task = "translate" if translate else None
    result = model.transcribe(audio, task=task)

    return result["text"]


gr.Interface(
    fn=transcribe,
    inputs=[
        gr.Audio(source="microphone", type="filepath"),
        gr.Checkbox(label="Translate to english"),
    ],
    examples=[
        ["samples/french_hello.wav", True],
        ["samples/english_hello.wav", True],
        ["samples/hebrew_hello.wav", True],
        ["samples/spanish_hello.wav", True],
    ],
    outputs="text",
).launch()