Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -373,12 +373,15 @@ def process_url(url, num_speakers, whisper_model, custom_prompt, offset, api_nam
|
|
| 373 |
download_video_flag=download_video, custom_prompt=custom_prompt)
|
| 374 |
if results:
|
| 375 |
transcription_result = results[0]
|
|
|
|
| 376 |
json_file_path = transcription_result['audio_file'].replace('.wav', '.segments.json')
|
| 377 |
prettified_json_file_path = transcription_result['audio_file'].replace('.wav', '.segments_pretty.json')
|
|
|
|
| 378 |
summary_file_path = json_file_path.replace('.segments.json', '_summary.txt')
|
| 379 |
|
| 380 |
json_file_path = format_file_path(json_file_path)
|
| 381 |
-
prettified_json_file_path = format_file_path(prettified_json_file_path)
|
|
|
|
| 382 |
summary_file_path = format_file_path(summary_file_path)
|
| 383 |
|
| 384 |
if download_video:
|
|
@@ -1259,9 +1262,16 @@ def format_transcription(transcription_result):
|
|
| 1259 |
return ""
|
| 1260 |
|
| 1261 |
|
| 1262 |
-
def format_file_path(file_path):
|
| 1263 |
-
|
| 1264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1265 |
|
| 1266 |
|
| 1267 |
def update_visibility(mode):
|
|
@@ -1447,7 +1457,13 @@ def main(input_path, api_name=None, api_key=None, num_speakers=2, whisper_model=
|
|
| 1447 |
# Perform summarization based on the specified API
|
| 1448 |
logging.debug(f"MAIN: Summarization being performed by {api_name} API")
|
| 1449 |
json_file_path = audio_file.replace('.wav', '.segments.json')
|
|
|
|
|
|
|
|
|
|
| 1450 |
prettified_json_file_path = transcription_result['audio_file'].replace('.wav', '.segments_pretty.json')
|
|
|
|
|
|
|
|
|
|
| 1451 |
if api_name == "huggingface":
|
| 1452 |
huggingface_api_key = os.getenv('HF_TOKEN').replace('"', '')
|
| 1453 |
if huggingface_api_key is None:
|
|
|
|
| 373 |
download_video_flag=download_video, custom_prompt=custom_prompt)
|
| 374 |
if results:
|
| 375 |
transcription_result = results[0]
|
| 376 |
+
|
| 377 |
json_file_path = transcription_result['audio_file'].replace('.wav', '.segments.json')
|
| 378 |
prettified_json_file_path = transcription_result['audio_file'].replace('.wav', '.segments_pretty.json')
|
| 379 |
+
|
| 380 |
summary_file_path = json_file_path.replace('.segments.json', '_summary.txt')
|
| 381 |
|
| 382 |
json_file_path = format_file_path(json_file_path)
|
| 383 |
+
prettified_json_file_path = format_file_path(prettified_json_file_path, fallback_path=json_file_path)
|
| 384 |
+
|
| 385 |
summary_file_path = format_file_path(summary_file_path)
|
| 386 |
|
| 387 |
if download_video:
|
|
|
|
| 1262 |
return ""
|
| 1263 |
|
| 1264 |
|
| 1265 |
+
def format_file_path(file_path, fallback_path=None):
|
| 1266 |
+
if file_path and os.path.exists(file_path):
|
| 1267 |
+
logging.debug(f"File exists: {file_path}")
|
| 1268 |
+
return file_path
|
| 1269 |
+
elif fallback_path and os.path.exists(fallback_path):
|
| 1270 |
+
logging.debug(f"File does not exist: {file_path}. Returning fallback path: {fallback_path}")
|
| 1271 |
+
return fallback_path
|
| 1272 |
+
else:
|
| 1273 |
+
logging.debug(f"File does not exist: {file_path}. No fallback path available.")
|
| 1274 |
+
return None
|
| 1275 |
|
| 1276 |
|
| 1277 |
def update_visibility(mode):
|
|
|
|
| 1457 |
# Perform summarization based on the specified API
|
| 1458 |
logging.debug(f"MAIN: Summarization being performed by {api_name} API")
|
| 1459 |
json_file_path = audio_file.replace('.wav', '.segments.json')
|
| 1460 |
+
# UNDO
|
| 1461 |
+
#prettified_json_file_path = transcription_result['audio_file'].replace('.wav', '.segments_pretty.json')
|
| 1462 |
+
json_file_path = transcription_result['audio_file'].replace('.wav', '.segments.json')
|
| 1463 |
prettified_json_file_path = transcription_result['audio_file'].replace('.wav', '.segments_pretty.json')
|
| 1464 |
+
|
| 1465 |
+
json_file_path = format_file_path(json_file_path)
|
| 1466 |
+
prettified_json_file_path = format_file_path(prettified_json_file_path, fallback_path=json_file_path)
|
| 1467 |
if api_name == "huggingface":
|
| 1468 |
huggingface_api_key = os.getenv('HF_TOKEN').replace('"', '')
|
| 1469 |
if huggingface_api_key is None:
|