添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
威武的苹果  ·  paper.js 波形图_paper.js ...·  4 月前    · 
八块腹肌的大葱  ·  Maven Build 중 ...·  4 月前    · 
礼貌的罐头  ·  Talend·  1 年前    · 

最近在用openai/whisper-small进行语音转文字任务时,想着自己下载模型在本地离线跑,但是遇到了一下问题:

import whisper
import wave
import numpy as np
download_root = r""whisper-small" # 模型路径
Automati_file = r"20230302152850300.mp3" #音频路径
model = whisper.load_model("small",download_root = download_root)
result = model.transcribe(Automati_file,language="zh",fp16=False)
print(result)

执行代码后,报错:

-> 1420 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

1421 # no special security

1422 None, None,

1423 int(not close_fds),

1424 creationflags,

1425 env,

1426 cwd,

1427 startupinfo)

1428 finally:

1429 # Child is launched. Close the parent's copy of those pipe

1430 # handles that only the child should have open. You need

(...)

1433 # pipe will not close when the child process exits and the

1434 # ReadFile will hang.

1435 self._close_pipe_fds(p2cread, p2cwrite,

1436 c2pread, c2pwrite,

1437 errread, errwrite)

FileNotFoundError: [WinError 2] 系统找不到指定的文件。

这个时候很大可能是这个_winapi.CreateProcess(executable, args,.....)中executable的问题。

当我们直接调用模型进行语音转问文字时,会调用fmpeg对数据进行处理

     41     out, _ = (
---> 42         ffmpeg.input(file, threads=0)
     43         .output("-", format="s16le", acodec="pcm_s16le", ac=1, ar=sr)
     44         .run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True)
     45     )

此时需要一个ffmpeg.exe 的系统变量进行调用执行。

解决方法:

在电脑中配置好ffmpeg.exe的路径:

找到 ffmpeg.exe 路径:

配置到系统变量中:

(Pycharm记得关闭重启。)

重新运行一下上述代码,就可以正常执行并输出结果了。