Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
import soundfile as sf
|
@@ -34,6 +35,7 @@ def get_pipeline(language):
|
|
34 |
)
|
35 |
return pipelines[language]
|
36 |
|
|
|
37 |
def transcribe(audio, language):
|
38 |
"""Transcribes speech from an audio file based on selected language."""
|
39 |
try:
|
@@ -78,59 +80,3 @@ iface = gr.Interface(
|
|
78 |
|
79 |
iface.launch()
|
80 |
|
81 |
-
|
82 |
-
# import gradio as gr
|
83 |
-
# import torch
|
84 |
-
# import soundfile as sf
|
85 |
-
# from transformers import pipeline
|
86 |
-
|
87 |
-
# device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
88 |
-
# pipe = pipeline(
|
89 |
-
# "automatic-speech-recognition",
|
90 |
-
# model="leenag/Tamil_ASR",
|
91 |
-
# chunk_length_s=10,
|
92 |
-
# device=device,
|
93 |
-
# )
|
94 |
-
|
95 |
-
# def transcribe(audio):
|
96 |
-
# """Transcribes Tamil speech from an audio file."""
|
97 |
-
# try:
|
98 |
-
# if audio is None:
|
99 |
-
# return "Please record or upload an audio file."
|
100 |
-
|
101 |
-
# print(f"[DEBUG] Received audio: {audio}")
|
102 |
-
|
103 |
-
# # Handle filepath case from Gradio
|
104 |
-
# audio_path = audio if isinstance(audio, str) else audio.get("name", None)
|
105 |
-
# if audio_path is None:
|
106 |
-
# return "Could not read audio file."
|
107 |
-
|
108 |
-
# print(f"[DEBUG] Reading audio file: {audio_path}")
|
109 |
-
# audio_data, sample_rate = sf.read(audio_path)
|
110 |
-
|
111 |
-
# print(f"[DEBUG] Audio sample rate: {sample_rate}, shape: {audio_data.shape}")
|
112 |
-
|
113 |
-
# transcription = pipe(
|
114 |
-
# {"array": audio_data, "sampling_rate": sample_rate},
|
115 |
-
# chunk_length_s=10,
|
116 |
-
# batch_size=8,
|
117 |
-
# )["text"]
|
118 |
-
|
119 |
-
# print(f"[DEBUG] Transcription: {transcription}")
|
120 |
-
# return transcription
|
121 |
-
|
122 |
-
# except Exception as e:
|
123 |
-
# import traceback
|
124 |
-
# print("[ERROR] Exception during transcription:")
|
125 |
-
# traceback.print_exc()
|
126 |
-
# return f"Error: {str(e)}"
|
127 |
-
|
128 |
-
# iface = gr.Interface(
|
129 |
-
# fn=transcribe,
|
130 |
-
# inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"),
|
131 |
-
# outputs="text",
|
132 |
-
# title="Tamil Speech Recognition",
|
133 |
-
# description="Record or upload Tamil speech and submit to get the transcribed text.",
|
134 |
-
# )
|
135 |
-
|
136 |
-
# iface.launch()
|
|
|
1 |
+
# Gradio for Multi ASR
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
import soundfile as sf
|
|
|
35 |
)
|
36 |
return pipelines[language]
|
37 |
|
38 |
+
# Transcription code with error debugging
|
39 |
def transcribe(audio, language):
|
40 |
"""Transcribes speech from an audio file based on selected language."""
|
41 |
try:
|
|
|
80 |
|
81 |
iface.launch()
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|