如果我用 work_space_batch.py 来调用 work_space_demo.py 来遍历处理多个文件。 要怎么改这两个文件呢?
work_space_batch.py 如下import os
for home, dirs, files in os.walk("/home/dengz/pytvzhen-master/test/"):
for name in files:
fullname = os.path.join(home, name)
print(name)
print(fullname)
code = f"python work_space_demo.py {fullname}"
os.system(code)
work_space_demo.py 大致如下:from faster_whisper import WhisperModel
from sys import argv
def transcribeAudioEn(path, modelName="medium", languate="fr",srtFilePathAndName="VIDEO_FILENAME.srt"):
model = WhisperModel(modelName, device1, compute_type="auto", download_root="faster-whisper_models", local_files_only=False)
print("Whisper model loaded.")
segments, _ = model.transcribe(audio=path, language=languate, word_timestamps=True)
# 转换为srt的Subtitle对象
pass
print("Transcription complete.")
transcribeAudioEn(argv[1])
|