mirror of
https://github.com/harry0703/MoneyPrinterTurbo.git
synced 2026-02-21 08:27:22 +08:00
Merge pull request #320 from harry0703/dev
1. Added exception handling when loading the Whisper model. 2. Check if the file exists before verifying the subtitles.
This commit is contained in:
commit
b08b79f9cf
@ -24,9 +24,18 @@ def create(audio_file, subtitle_file: str = ""):
|
||||
model_path = model_size
|
||||
|
||||
logger.info(f"loading model: {model_path}, device: {device}, compute_type: {compute_type}")
|
||||
model = WhisperModel(model_size_or_path=model_path,
|
||||
device=device,
|
||||
compute_type=compute_type)
|
||||
try:
|
||||
model = WhisperModel(model_size_or_path=model_path,
|
||||
device=device,
|
||||
compute_type=compute_type)
|
||||
except Exception as e:
|
||||
logger.error(f"failed to load model: {e} \n\n"
|
||||
f"********************************************\n"
|
||||
f"this may be caused by network issue. \n"
|
||||
f"please download the model manually and put it in the 'models' folder. \n"
|
||||
f"see [README.md FAQ](https://github.com/harry0703/MoneyPrinterTurbo) for more details.\n"
|
||||
f"********************************************\n\n")
|
||||
return None
|
||||
|
||||
logger.info(f"start, output file: {subtitle_file}")
|
||||
if not subtitle_file:
|
||||
@ -120,6 +129,9 @@ def create(audio_file, subtitle_file: str = ""):
|
||||
|
||||
|
||||
def file_to_subtitles(filename):
|
||||
if not filename or not os.path.isfile(filename):
|
||||
return []
|
||||
|
||||
times_texts = []
|
||||
current_times = None
|
||||
current_text = ""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user