AI_Application / app.py
Antoniskaraolis's picture
Update app.py
d7aa11b
raw
history blame
629 Bytes
import whisper
import gradio as gr
def transcribe_audio(file_info):
model = whisper.load_model("base") # Choose the appropriate model size
audio = whisper.load_audio(file_info.name)
audio = whisper.pad_or_trim(audio)
mel = whisper.log_mel_spectrogram(audio).to(model.device)
_, probs = model.detect_language(mel)
language = max(probs, key=probs.get)
print(f"Detected language: {language}")
result = model.transcribe(mel)
return result["text"]
iface = gr.Interface(
fn=transcribe_audio,
inputs=gr.inputs.Audio(source="microphone", type="file"),
outputs="text"
)
iface.launch()