Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -209,7 +209,7 @@ def generate_audio_kokoro(text, lang, selected_voice):
|
|
209 |
global kokoro_tts # Access the preloaded model
|
210 |
if os.path.exists(f"audio_{lang}.wav"):
|
211 |
os.remove(f"audio_{lang}.wav")
|
212 |
-
|
213 |
lang_code = SUPPORTED_TTS_LANGUAGES.get(lang, "a") # Default to English
|
214 |
#generator = kokoro_tts(text, voice="bm_george", speed=1, split_pattern=r'\n+')
|
215 |
generator = kokoro_tts(text, voice=selected_voice, speed=1, split_pattern=r'\n+')
|
@@ -220,7 +220,7 @@ def generate_audio_kokoro(text, lang, selected_voice):
|
|
220 |
|
221 |
output_file = f"audio_{lang}.wav"
|
222 |
sf.write(output_file, full_audio, 24000) # Save as WAV file
|
223 |
-
|
224 |
|
225 |
### 5️⃣ Chunk-Based Summarization
|
226 |
def split_text_with_optimized_overlap(text, max_tokens=1024, overlap_tokens=25):
|
@@ -341,14 +341,18 @@ with gr.Blocks() as demo:
|
|
341 |
#process_summary_button.click(hierarchical_summarization, inputs=[extracted_text], outputs=[summary_output])
|
342 |
|
343 |
process_audio_button.click(
|
344 |
-
lambda text, summary, lang, voice, tts_choice:
|
345 |
-
|
|
|
|
|
|
|
346 |
),
|
347 |
inputs=[extracted_text, summary_output, detected_lang, voice_selection, tts_option],
|
348 |
-
outputs=[full_audio_output],
|
349 |
show_progress=True
|
350 |
)
|
351 |
|
|
|
352 |
process_ner_button.click(
|
353 |
#extract_entities_with_stanza,
|
354 |
extract_entities_with_gliner,
|
|
|
209 |
global kokoro_tts # Access the preloaded model
|
210 |
if os.path.exists(f"audio_{lang}.wav"):
|
211 |
os.remove(f"audio_{lang}.wav")
|
212 |
+
|
213 |
lang_code = SUPPORTED_TTS_LANGUAGES.get(lang, "a") # Default to English
|
214 |
#generator = kokoro_tts(text, voice="bm_george", speed=1, split_pattern=r'\n+')
|
215 |
generator = kokoro_tts(text, voice=selected_voice, speed=1, split_pattern=r'\n+')
|
|
|
220 |
|
221 |
output_file = f"audio_{lang}.wav"
|
222 |
sf.write(output_file, full_audio, 24000) # Save as WAV file
|
223 |
+
return output_file
|
224 |
|
225 |
### 5️⃣ Chunk-Based Summarization
|
226 |
def split_text_with_optimized_overlap(text, max_tokens=1024, overlap_tokens=25):
|
|
|
341 |
#process_summary_button.click(hierarchical_summarization, inputs=[extracted_text], outputs=[summary_output])
|
342 |
|
343 |
process_audio_button.click(
|
344 |
+
lambda text, summary, lang, voice, tts_choice: (
|
345 |
+
None, # Clear previous audio
|
346 |
+
generate_audio_kokoro(
|
347 |
+
summary if tts_choice == "Summary Audio" else text, lang, voice
|
348 |
+
)
|
349 |
),
|
350 |
inputs=[extracted_text, summary_output, detected_lang, voice_selection, tts_option],
|
351 |
+
outputs=[full_audio_output, full_audio_output], # Clear first, then display new audio
|
352 |
show_progress=True
|
353 |
)
|
354 |
|
355 |
+
|
356 |
process_ner_button.click(
|
357 |
#extract_entities_with_stanza,
|
358 |
extract_entities_with_gliner,
|