File size: 931 Bytes
e8e4726
 
 
ebefed3
e8e4726
 
 
 
 
 
 
 
 
966566c
 
 
e8e4726
 
 
 
 
 
 
966566c
 
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
30
31
32
33
34
import whisper
import gradio as gr

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


def transcribe(audio, translate):

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

    return result["text"]

title = "BabelFish"

description = "Record your voice in any language, babelfish will output a transcript of what was said. Check 'Translate to english' to get an english transcription. Based on the OpenAI Whisper model"

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