Update app.py
Browse files
app.py
CHANGED
@@ -85,7 +85,7 @@ def process_audio(audio_file, translate=False):
|
|
85 |
|
86 |
|
87 |
@spaces.GPU(duration=120)
|
88 |
-
def summarize_text(
|
89 |
"""Summarize text"""
|
90 |
try:
|
91 |
|
@@ -94,6 +94,8 @@ def summarize_text(results):
|
|
94 |
if summarizer is None:
|
95 |
return "Summarization model could not be loaded."
|
96 |
logger.info("Successfully loaded summarization Model")
|
|
|
|
|
97 |
# full_text = ''.join(item['translated'] for item in results if 'translated' in item)
|
98 |
logger.info(f"\n\nWorking on text:\n{full_text}")
|
99 |
summary = summarizer( full_text, max_length=150, min_length=50, do_sample=False)[0]['summary_text']
|
@@ -156,9 +158,9 @@ with gr.Blocks() as iface:
|
|
156 |
inputs=[audio_input, translate_checkbox],
|
157 |
# outputs=[transcription_output, full_text_output]
|
158 |
outputs=[ASR_RESULT]
|
159 |
-
)
|
160 |
-
logger.info(f"{ASR_RESULT}")
|
161 |
-
translated_text = ''.join(item['translated'] for item in ASR_RESULT if 'translated' in item)
|
162 |
summarize_button.click(
|
163 |
summarize_text,
|
164 |
inputs=[translated_text],
|
|
|
85 |
|
86 |
|
87 |
@spaces.GPU(duration=120)
|
88 |
+
def summarize_text(text):
|
89 |
"""Summarize text"""
|
90 |
try:
|
91 |
|
|
|
94 |
if summarizer is None:
|
95 |
return "Summarization model could not be loaded."
|
96 |
logger.info("Successfully loaded summarization Model")
|
97 |
+
data = json.loads(text)
|
98 |
+
translated_text = ''.join(item['translated'] for item in data if 'translated' in item)
|
99 |
# full_text = ''.join(item['translated'] for item in results if 'translated' in item)
|
100 |
logger.info(f"\n\nWorking on text:\n{full_text}")
|
101 |
summary = summarizer( full_text, max_length=150, min_length=50, do_sample=False)[0]['summary_text']
|
|
|
158 |
inputs=[audio_input, translate_checkbox],
|
159 |
# outputs=[transcription_output, full_text_output]
|
160 |
outputs=[ASR_RESULT]
|
161 |
+
# )
|
162 |
+
# logger.info(f"{ASR_RESULT}")
|
163 |
+
# translated_text = ''.join(item['translated'] for item in ASR_RESULT if 'translated' in item)
|
164 |
summarize_button.click(
|
165 |
summarize_text,
|
166 |
inputs=[translated_text],
|