Update app.py
Browse files
app.py
CHANGED
@@ -48,7 +48,7 @@ def load_summarization_model():
|
|
48 |
return None
|
49 |
|
50 |
|
51 |
-
@spaces.GPU(duration=
|
52 |
def process_audio(audio_file, translate=False):
|
53 |
"""Process audio file"""
|
54 |
transcriber = ChunkedTranscriber(chunk_size=5, overlap=1)
|
@@ -84,22 +84,26 @@ def process_audio(audio_file, translate=False):
|
|
84 |
# raise gr.Error(f"Processing failed: {str(e)}")
|
85 |
|
86 |
|
87 |
-
@spaces.GPU(duration=
|
88 |
def summarize_text(results):
|
89 |
"""Summarize text"""
|
90 |
try:
|
|
|
91 |
summarizer = load_summarization_model()
|
|
|
92 |
if summarizer is None:
|
93 |
return "Summarization model could not be loaded."
|
94 |
-
|
95 |
-
|
|
|
|
|
96 |
return summary
|
97 |
except Exception as e:
|
98 |
logger.error(f"Summarization failed: {str(e)}")
|
99 |
return "Error occurred during summarization."
|
100 |
|
101 |
|
102 |
-
@spaces.GPU(duration=
|
103 |
def answer_question(context, question):
|
104 |
"""Answer questions about the text"""
|
105 |
try:
|
|
|
48 |
return None
|
49 |
|
50 |
|
51 |
+
@spaces.GPU(duration=120)
|
52 |
def process_audio(audio_file, translate=False):
|
53 |
"""Process audio file"""
|
54 |
transcriber = ChunkedTranscriber(chunk_size=5, overlap=1)
|
|
|
84 |
# raise gr.Error(f"Processing failed: {str(e)}")
|
85 |
|
86 |
|
87 |
+
@spaces.GPU(duration=120)
|
88 |
def summarize_text(results):
|
89 |
"""Summarize text"""
|
90 |
try:
|
91 |
+
|
92 |
summarizer = load_summarization_model()
|
93 |
+
|
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']
|
100 |
return summary
|
101 |
except Exception as e:
|
102 |
logger.error(f"Summarization failed: {str(e)}")
|
103 |
return "Error occurred during summarization."
|
104 |
|
105 |
|
106 |
+
@spaces.GPU(duration=120)
|
107 |
def answer_question(context, question):
|
108 |
"""Answer questions about the text"""
|
109 |
try:
|