Spaces:
Sleeping
Sleeping
File size: 916 Bytes
d5134c8 2009c4b d5134c8 2009c4b d5134c8 2009c4b d5134c8 2009c4b d5134c8 2009c4b |
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 |
import gradio as gr
from transformers import pipeline
# Whisper pipeline (supports Hindi, Punjabi, etc.)
asr_pipeline = pipeline(
task="automatic-speech-recognition",
model="openai/whisper-small",
)
# Function to transcribe and detect language
def transcribe(audio_np, sample_rate):
result = asr_pipeline({
"array": audio_np,
"sampling_rate": sample_rate
})
text = result["text"]
lang = result.get("language", "unknown")
return f"Detected Language: {lang}\n\nTranscription:\n{text}"
# Gradio Interface
interface = gr.Interface(
fn=transcribe,
inputs=gr.Audio(type="numpy", label="Upload or Record Audio"), # FIXED
outputs=gr.Textbox(label="Detected Language & Transcription"),
title="Auto Language Detection - Whisper",
description="Upload or record Hindi or Punjabi audio. Whisper will auto-detect language and transcribe."
)
interface.launch()
|