Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# Load the Hugging Face model pipeline (example: Automatic Speech Recognition) | |
model = pipeline("automatic-speech-recognition", model="kattojuprashanth238/whisper-small-te-v9") | |
def process_audio(audio): | |
""" | |
Process the audio input and return the transcription. | |
Args: | |
- audio: file path of the uploaded or recorded audio | |
Returns: | |
- Transcription text | |
""" | |
if audio is None: | |
return "No audio input provided." | |
try: | |
# Hugging Face model processing with long-form transcription | |
result = model(audio, return_timestamps=True) | |
transcription = result["text"] | |
return transcription | |
except Exception as e: | |
return f"Error processing audio: {str(e)}" | |
# Gradio interface | |
with gr.Blocks() as app: | |
gr.Markdown("## Audio Transcription Interface") | |
gr.Markdown("Record audio or upload an audio file to transcribe it.") | |
audio_input = gr.Audio(type="filepath", label="Record or Upload Audio") | |
output = gr.Textbox(label="Transcription Result") | |
# Submit button for processing | |
btn = gr.Button("Transcribe") | |
# Logic for the interface | |
btn.click(process_audio, inputs=audio_input, outputs=output) | |
# Launch the interface | |
app.launch() | |