File size: 485 Bytes
36bec1c
ec72da9
89f5759
2bacaf7
ec72da9
2bacaf7
ec72da9
89f5759
 
ec72da9
 
 
 
 
2bacaf7
ec72da9
2bacaf7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
import whisper
import numpy as np

model = whisper.load_model("base")

def transcribe(audio):
    if not isinstance(audio, np.ndarray):
        audio = np.array(audio)
    audio = whisper.pad_or_trim(audio)
    mel = whisper.log_mel_spectrogram(audio).to(model.device)
    options = whisper.DecodingOptions()
    result = whisper.decode(model, mel, options)
    return result.text

iface = gr.Interface(fn=transcribe, inputs="audio", outputs="text")
iface.launch()