Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ model.eval()
|
|
| 21 |
|
| 22 |
# Load the summarization model once at startup
|
| 23 |
#summarizer = pipeline("summarization", model="Falconsai/text_summarization", device="cpu")
|
| 24 |
-
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
|
| 25 |
|
| 26 |
def get_audio_segment(audio_path, start_second, end_second):
|
| 27 |
"""
|
|
@@ -239,32 +239,32 @@ def get_full_transcript(vis_data):
|
|
| 239 |
# Simple summary function (replace with a real model if needed)
|
| 240 |
# Replace the old summarize_transcript function with this one
|
| 241 |
@spaces.GPU
|
| 242 |
-
def summarize_transcript(transcript: str) -> str:
|
| 243 |
"""
|
| 244 |
Summarizes the transcript using the sshleifer/distilbart-cnn-12-6 model.
|
| 245 |
"""
|
| 246 |
# Check for empty or whitespace-only input
|
| 247 |
-
if not transcript or not transcript.strip():
|
| 248 |
-
return "No transcript available to summarize."
|
| 249 |
-
|
| 250 |
-
try:
|
| 251 |
-
gr.Info("Generating summary...", duration=2)
|
| 252 |
-
# Use the pre-loaded summarizer object to generate the summary
|
| 253 |
-
result = summarizer(
|
| 254 |
-
transcript,
|
| 255 |
-
max_length=250,
|
| 256 |
-
min_length=50,
|
| 257 |
-
num_beams=4,
|
| 258 |
-
|
| 259 |
-
)
|
| 260 |
-
# Extract the summary text from the result
|
| 261 |
-
summary = result[0]['summary_text']
|
| 262 |
-
return summary
|
| 263 |
-
except Exception as e:
|
| 264 |
-
error_message = f"An error occurred during summarization: {e}"
|
| 265 |
-
print(error_message) # Log the error to the console for debugging
|
| 266 |
-
gr.Warning("Sorry, the summary could not be generated at this time.")
|
| 267 |
-
return "" # Return an empty string on failure
|
| 268 |
|
| 269 |
# Apply the custom theme
|
| 270 |
|
|
|
|
| 21 |
|
| 22 |
# Load the summarization model once at startup
|
| 23 |
#summarizer = pipeline("summarization", model="Falconsai/text_summarization", device="cpu")
|
| 24 |
+
#summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
|
| 25 |
|
| 26 |
def get_audio_segment(audio_path, start_second, end_second):
|
| 27 |
"""
|
|
|
|
| 239 |
# Simple summary function (replace with a real model if needed)
|
| 240 |
# Replace the old summarize_transcript function with this one
|
| 241 |
@spaces.GPU
|
| 242 |
+
#def summarize_transcript(transcript: str) -> str:
|
| 243 |
"""
|
| 244 |
Summarizes the transcript using the sshleifer/distilbart-cnn-12-6 model.
|
| 245 |
"""
|
| 246 |
# Check for empty or whitespace-only input
|
| 247 |
+
# if not transcript or not transcript.strip():
|
| 248 |
+
# return "No transcript available to summarize."
|
| 249 |
+
#
|
| 250 |
+
# try:
|
| 251 |
+
# gr.Info("Generating summary...", duration=2)
|
| 252 |
+
# # Use the pre-loaded summarizer object to generate the summary
|
| 253 |
+
# result = summarizer(
|
| 254 |
+
# transcript,
|
| 255 |
+
# max_length=250,
|
| 256 |
+
# min_length=50,
|
| 257 |
+
# num_beams=4,
|
| 258 |
+
# early_stopping=True
|
| 259 |
+
# )
|
| 260 |
+
# # Extract the summary text from the result
|
| 261 |
+
# summary = result[0]['summary_text']
|
| 262 |
+
# return summary
|
| 263 |
+
# except Exception as e:
|
| 264 |
+
# error_message = f"An error occurred during summarization: {e}"
|
| 265 |
+
# print(error_message) # Log the error to the console for debugging
|
| 266 |
+
# gr.Warning("Sorry, the summary could not be generated at this time.")
|
| 267 |
+
# return "" # Return an empty string on failure
|
| 268 |
|
| 269 |
# Apply the custom theme
|
| 270 |
|