Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -478,7 +478,6 @@ def transcribe_audio(audio_input, audio_url, proxy_url, proxy_username, proxy_pa
|
|
| 478 |
|
| 479 |
# Model caching
|
| 480 |
model_key = (pipeline_type, model_id)
|
| 481 |
-
model = None
|
| 482 |
if model_key in loaded_models:
|
| 483 |
model = loaded_models[model_key]
|
| 484 |
logging.info("Loaded model from cache")
|
|
@@ -490,7 +489,7 @@ def transcribe_audio(audio_input, audio_url, proxy_url, proxy_username, proxy_pa
|
|
| 490 |
remote_code=f"./Fun-ASR/model.py",
|
| 491 |
vad_model="fsmn-vad",
|
| 492 |
vad_kwargs={"max_single_segment_time": 30000},
|
| 493 |
-
device=
|
| 494 |
disable_update=True,
|
| 495 |
hub='ms',
|
| 496 |
)
|
|
@@ -500,7 +499,7 @@ def transcribe_audio(audio_input, audio_url, proxy_url, proxy_username, proxy_pa
|
|
| 500 |
trust_remote_code=False,
|
| 501 |
vad_model="fsmn-vad",
|
| 502 |
vad_kwargs={"max_single_segment_time": 30000},
|
| 503 |
-
device=
|
| 504 |
disable_update=True,
|
| 505 |
hub='ms',
|
| 506 |
)
|
|
@@ -510,14 +509,6 @@ def transcribe_audio(audio_input, audio_url, proxy_url, proxy_username, proxy_pa
|
|
| 510 |
yield verbose_messages + error_msg, "", None
|
| 511 |
return
|
| 512 |
loaded_models[model_key] = model
|
| 513 |
-
|
| 514 |
-
try:
|
| 515 |
-
model.to(device)
|
| 516 |
-
logging.info(f"Model moved to device: {device}")
|
| 517 |
-
except Exception as e:
|
| 518 |
-
logging.error(f"Error moving model to device: {str(e)}")
|
| 519 |
-
yield verbose_messages + f"Error moving model to device: {str(e)}", "", None
|
| 520 |
-
return
|
| 521 |
|
| 522 |
# Perform the transcription
|
| 523 |
start_time_perf = time.time()
|
|
@@ -545,8 +536,6 @@ def transcribe_audio(audio_input, audio_url, proxy_url, proxy_username, proxy_pa
|
|
| 545 |
merge_vad=True,
|
| 546 |
merge_length_s=15,
|
| 547 |
)
|
| 548 |
-
|
| 549 |
-
model.to('cpu') # Move model back to CPU after inference to free GPU memory
|
| 550 |
|
| 551 |
transcription = rich_transcription_postprocess(res[0]["text"])
|
| 552 |
end_time_perf = time.time()
|
|
|
|
| 478 |
|
| 479 |
# Model caching
|
| 480 |
model_key = (pipeline_type, model_id)
|
|
|
|
| 481 |
if model_key in loaded_models:
|
| 482 |
model = loaded_models[model_key]
|
| 483 |
logging.info("Loaded model from cache")
|
|
|
|
| 489 |
remote_code=f"./Fun-ASR/model.py",
|
| 490 |
vad_model="fsmn-vad",
|
| 491 |
vad_kwargs={"max_single_segment_time": 30000},
|
| 492 |
+
device=device,
|
| 493 |
disable_update=True,
|
| 494 |
hub='ms',
|
| 495 |
)
|
|
|
|
| 499 |
trust_remote_code=False,
|
| 500 |
vad_model="fsmn-vad",
|
| 501 |
vad_kwargs={"max_single_segment_time": 30000},
|
| 502 |
+
device=device,
|
| 503 |
disable_update=True,
|
| 504 |
hub='ms',
|
| 505 |
)
|
|
|
|
| 509 |
yield verbose_messages + error_msg, "", None
|
| 510 |
return
|
| 511 |
loaded_models[model_key] = model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 512 |
|
| 513 |
# Perform the transcription
|
| 514 |
start_time_perf = time.time()
|
|
|
|
| 536 |
merge_vad=True,
|
| 537 |
merge_length_s=15,
|
| 538 |
)
|
|
|
|
|
|
|
| 539 |
|
| 540 |
transcription = rich_transcription_postprocess(res[0]["text"])
|
| 541 |
end_time_perf = time.time()
|