whisper执行ffmpeg时,报错: hp, ht, pid, tid = 您所在的位置:网站首页 文件系统open whisper执行ffmpeg时,报错: hp, ht, pid, tid =

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

2023-03-10 06:04| 来源: 网络整理| 查看: 265

最近在用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记得关闭重启。)

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

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有