V7.0
Browse files
app.py
CHANGED
|
@@ -137,11 +137,28 @@ def transcribe_microphone(audio, language_choice, decoding_method):
|
|
| 137 |
return "⚠️ कोई ऑडियो रिकॉर्ड नहीं हुआ। कृपया माइक्रोफ़ोन पर क्लिक करें और बोलें। (No audio recorded. Please click the microphone and speak.)"
|
| 138 |
return transcribe_audio(audio, language_choice, decoding_method)
|
| 139 |
|
| 140 |
-
def
|
| 141 |
-
"""
|
| 142 |
-
if
|
| 143 |
-
return "
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
# Model status message
|
| 147 |
model_status = "✅ Model loaded successfully!" if model is not None else "❌ Model failed to load"
|
|
@@ -209,7 +226,7 @@ with gr.Blocks(title="भारतीय भाषा स्पीच टू ट
|
|
| 209 |
with gr.Row():
|
| 210 |
mic_submit_btn = gr.Button("🔄 ट्रांसक्राइब करें", variant="primary", size="lg")
|
| 211 |
clear_mic_btn = gr.Button("🗑️ साफ़ करें", variant="secondary")
|
| 212 |
-
|
| 213 |
|
| 214 |
with gr.Column(scale=1):
|
| 215 |
mic_output = gr.Textbox(
|
|
@@ -217,8 +234,7 @@ with gr.Blocks(title="भारतीय भाषा स्पीच टू ट
|
|
| 217 |
placeholder="रिकॉर्डिंग के बाद आपका ट्रांस्क्रिप्शन यहाँ दिखाई देगा...",
|
| 218 |
lines=8,
|
| 219 |
max_lines=15,
|
| 220 |
-
interactive=True
|
| 221 |
-
show_copy_button=True # Add copy button
|
| 222 |
)
|
| 223 |
|
| 224 |
# Button actions for microphone tab
|
|
@@ -240,9 +256,9 @@ with gr.Blocks(title="भारतीय भाषा स्पीच टू ट
|
|
| 240 |
outputs=[microphone_input, mic_output]
|
| 241 |
)
|
| 242 |
|
| 243 |
-
#
|
| 244 |
-
|
| 245 |
-
|
| 246 |
inputs=mic_output,
|
| 247 |
outputs=mic_output
|
| 248 |
)
|
|
@@ -263,7 +279,7 @@ with gr.Blocks(title="भारतीय भाषा स्पीच टू ट
|
|
| 263 |
with gr.Row():
|
| 264 |
file_submit_btn = gr.Button("🔄 फ़ाइल ट्रांसक्राइब करें", variant="primary", size="lg")
|
| 265 |
clear_file_btn = gr.Button("🗑️ साफ़ करें", variant="secondary")
|
| 266 |
-
|
| 267 |
|
| 268 |
with gr.Column(scale=1):
|
| 269 |
file_output = gr.Textbox(
|
|
@@ -271,8 +287,7 @@ with gr.Blocks(title="भारतीय भाषा स्पीच टू ट
|
|
| 271 |
placeholder="एक ऑडियो फ़ाइल अपलोड करें और ट्रांसक्राइब पर क्लिक करें...",
|
| 272 |
lines=8,
|
| 273 |
max_lines=15,
|
| 274 |
-
interactive=True
|
| 275 |
-
show_copy_button=True # Add copy button
|
| 276 |
)
|
| 277 |
|
| 278 |
# Button actions for file tab
|
|
@@ -287,9 +302,9 @@ with gr.Blocks(title="भारतीय भाषा स्पीच टू ट
|
|
| 287 |
outputs=[file_input, file_output]
|
| 288 |
)
|
| 289 |
|
| 290 |
-
#
|
| 291 |
-
|
| 292 |
-
|
| 293 |
inputs=file_output,
|
| 294 |
outputs=file_output
|
| 295 |
)
|
|
|
|
| 137 |
return "⚠️ कोई ऑडियो रिकॉर्ड नहीं हुआ। कृपया माइक्रोफ़ोन पर क्लिक करें और बोलें। (No audio recorded. Please click the microphone and speak.)"
|
| 138 |
return transcribe_audio(audio, language_choice, decoding_method)
|
| 139 |
|
| 140 |
+
def create_shareable_text(text, method="Voice"):
|
| 141 |
+
"""Create formatted text for sharing"""
|
| 142 |
+
if not text or text.strip() == "":
|
| 143 |
+
return "📤 कोई टेक्स्ट शेयर करने के लिए उपलब्ध नहीं है।"
|
| 144 |
+
|
| 145 |
+
# Clean the text (remove markdown and emojis from result)
|
| 146 |
+
clean_text = text.replace("✅ **ट्रांस्क्रिप्शन (CTC):**", "").replace("✅ **ट्रांस्क्रिप्शन (RNNT):**", "")
|
| 147 |
+
clean_text = clean_text.strip()
|
| 148 |
+
|
| 149 |
+
# Create shareable format
|
| 150 |
+
share_text = f"""📱 Hindi Speech-to-Text Result
|
| 151 |
+
|
| 152 |
+
🎙️ Input Method: {method}
|
| 153 |
+
📝 Transcription: {clean_text}
|
| 154 |
+
|
| 155 |
+
🤖 Generated by: AI4Bharat IndicConformer
|
| 156 |
+
🌐 App: Hindi ASR - Hugging Face Spaces
|
| 157 |
+
|
| 158 |
+
---
|
| 159 |
+
Share this Hindi transcription with others!"""
|
| 160 |
+
|
| 161 |
+
return share_text
|
| 162 |
|
| 163 |
# Model status message
|
| 164 |
model_status = "✅ Model loaded successfully!" if model is not None else "❌ Model failed to load"
|
|
|
|
| 226 |
with gr.Row():
|
| 227 |
mic_submit_btn = gr.Button("🔄 ट्रांसक्राइब करें", variant="primary", size="lg")
|
| 228 |
clear_mic_btn = gr.Button("🗑️ साफ़ करें", variant="secondary")
|
| 229 |
+
share_mic_btn = gr.Button("📤 शेयर करें", variant="secondary")
|
| 230 |
|
| 231 |
with gr.Column(scale=1):
|
| 232 |
mic_output = gr.Textbox(
|
|
|
|
| 234 |
placeholder="रिकॉर्डिंग के बाद आपका ट्रांस्क्रिप्शन यहाँ दिखाई देगा...",
|
| 235 |
lines=8,
|
| 236 |
max_lines=15,
|
| 237 |
+
interactive=True # Enable text selection
|
|
|
|
| 238 |
)
|
| 239 |
|
| 240 |
# Button actions for microphone tab
|
|
|
|
| 256 |
outputs=[microphone_input, mic_output]
|
| 257 |
)
|
| 258 |
|
| 259 |
+
# Share functionality for microphone tab
|
| 260 |
+
share_mic_btn.click(
|
| 261 |
+
fn=share_microphone_result,
|
| 262 |
inputs=mic_output,
|
| 263 |
outputs=mic_output
|
| 264 |
)
|
|
|
|
| 279 |
with gr.Row():
|
| 280 |
file_submit_btn = gr.Button("🔄 फ़ाइल ट्रांसक्राइब करें", variant="primary", size="lg")
|
| 281 |
clear_file_btn = gr.Button("🗑️ साफ़ करें", variant="secondary")
|
| 282 |
+
share_file_btn = gr.Button("📤 शेयर करें", variant="secondary")
|
| 283 |
|
| 284 |
with gr.Column(scale=1):
|
| 285 |
file_output = gr.Textbox(
|
|
|
|
| 287 |
placeholder="एक ऑडियो फ़ाइल अपलोड करें और ट्रांसक्राइब पर क्लिक करें...",
|
| 288 |
lines=8,
|
| 289 |
max_lines=15,
|
| 290 |
+
interactive=True # Enable text selection
|
|
|
|
| 291 |
)
|
| 292 |
|
| 293 |
# Button actions for file tab
|
|
|
|
| 302 |
outputs=[file_input, file_output]
|
| 303 |
)
|
| 304 |
|
| 305 |
+
# Share functionality for file tab
|
| 306 |
+
share_file_btn.click(
|
| 307 |
+
fn=share_file_result,
|
| 308 |
inputs=file_output,
|
| 309 |
outputs=file_output
|
| 310 |
)
|