修改whisper音频转写命令

This commit is contained in:
William Jin 2025-10-06 17:51:56 +08:00
parent 9da3cdb614
commit 65439486ce

View File

@ -29,13 +29,11 @@ def convert_to_wav(audio_file):
def transcribe_audio(wav_file, original_filename, offset_time, duration_time): def transcribe_audio(wav_file, original_filename, offset_time, duration_time):
# 调用 whisper 命令行程序进行转写 # 调用 whisper 命令行程序进行转写
whisper_cmd = [ whisper_cmd = [
"/home/tmfc/apps/whisper/main", "/home/tmfc/apps/whisper/.venv/bin/whisper",
"--language", "Chinese", "--language", "zh",
"-otxt", "--output_dir", "/home/tmfc/whisper_output/",
"-ot", str(offset_time * 1000), "--output_format", "txt",
"-d", str(duration_time * 1000), "--model", "turbo",
"-of", "/home/tmfc/apps/whisper/" + original_filename,
"-m", "/home/tmfc/apps/whisper/models/ggml-large-v3-q5_0.bin",
wav_file wav_file
] ]
print(whisper_cmd) print(whisper_cmd)
@ -47,7 +45,7 @@ def transcribe_audio(wav_file, original_filename, offset_time, duration_time):
# with open(txt_file, "w") as f: # with open(txt_file, "w") as f:
# f.write(result.stdout) # f.write(result.stdout)
txt_file = original_filename + ".txt" txt_file = "/home/tmfc/whisper_output/" + original_filename + ".txt"
print(f"音频文件 {wav_file} 转写完成,结果已保存为 {txt_file}") print(f"音频文件 {wav_file} 转写完成,结果已保存为 {txt_file}")
return txt_file return txt_file