Ai-audio / app.py
Athspi's picture
Update app.py
49d93f9 verified
raw
history blame
920 Bytes
import gradio as gr
from transformers import pipeline
# Load the Whisper model for speech recognition
model = pipeline("automatic-speech-recognition", model="openai/whisper-medium")
def transcribe_audio(audio_file, language="english"):
# Transcribe the audio file
transcription = model(audio_file, generate_kwargs={"language": language})
return transcription["text"]
# Define the Gradio interface
iface = gr.Interface(
fn=transcribe_audio,
inputs=[
gr.Audio(type="filepath", label="Upload Audio File"),
gr.Dropdown(choices=["english", "spanish", "french", "german", "chinese", "japanese", "korean", "hindi"], label="Select Language", value="english")
],
outputs=gr.Textbox(label="Transcription"),
title="Multi-Language Audio Transcription",
description="Upload an audio file and select the language to transcribe it."
)
# Launch the Gradio interface
iface.launch()