小工具知识网

当前位置: 首页 > 行业知识 > whisper执行ffmpeg时,报错: hp, ht, pid, tid =

行业知识

whisper执行ffmpeg时,报错: hp, ht, pid, tid =

2026-11-28 09:58:34 来源:互联网转载

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

import whisperimport waveimport numpy as npdownload_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记得关闭重启。)

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

 

上一篇:手游服务器ip怎么找?

下一篇:mcpe如何开服务器?