Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the Whisper model for Hindi transcription
|
5 |
+
pipe = pipeline(model="Tashuu/whisper-medium-hindi")
|
6 |
+
|
7 |
+
def transcribe_audio(audio):
|
8 |
+
"""
|
9 |
+
Transcribes the uploaded audio file using the fine-tuned Whisper model.
|
10 |
+
"""
|
11 |
+
try:
|
12 |
+
transcription = pipe(audio)["text"]
|
13 |
+
return transcription
|
14 |
+
except Exception as e:
|
15 |
+
return f"Error during transcription: {str(e)}"
|
16 |
+
|
17 |
+
# Define the Gradio interface
|
18 |
+
interface = gr.Interface(
|
19 |
+
fn=transcribe_audio,
|
20 |
+
inputs=gr.Audio(type="filepath"),
|
21 |
+
outputs="text",
|
22 |
+
title="Hindi Speech-to-Text Transcription",
|
23 |
+
description="Upload an audio file in Hindi, and this app will transcribe it to text using a fine-tuned Whisper model."
|
24 |
+
)
|
25 |
+
|
26 |
+
# Launch the app
|
27 |
+
interface.launch()
|