如何修复 subprocess.py",第 1438 行,以 _execute_child hp、ht、pid、tid = _winapi 为单位。CreateProcess(executable,



我正试图建立一个功能,捕捉你的声音,并把它变成文本与耳语从OpenAI。

这是我的代码:

import whisper
import sounddevice as sd
from scipy.io.wavfile import write
import wavio as wv
import os
# Sampling frequency
freq = 44100
# Recording duration
duration = 5
# Start recorder with the given values
# of duration and sample frequency
print("Début de l'enregistrement")
recording = sd.rec(int(duration * freq),
samplerate=freq, channels=2)
# Record audio for the given number of seconds
sd.wait()
print("Fin de l'enregistrement")
# This will convert the NumPy array to an audio
# file with the given sampling frequency
write("audio/recording.wav", freq, recording)
model = whisper.load_model("base")
result = model.transcribe("audio\recording.wav", fp16=False)
print(result["text"])

这是我的错误:

Traceback (most recent call last):
File "c:UsersbertrDocumentsEliottCodeOoshotProjet Whispermain.py", line 28, in <module>
result = model.transcribe("audio\recording.wav", fp16=False)
File "C:UsersbertrAppDataLocalProgramsPythonPython310libsite-packageswhispertranscribe.py", line 84, in transcribe
mel = log_mel_spectrogram(audio)
File "C:UsersbertrAppDataLocalProgramsPythonPython310libsite-packageswhisperaudio.py", line 111, in log_mel_spectrogram
audio = load_audio(audio)
File "C:UsersbertrAppDataLocalProgramsPythonPython310libsite-packageswhisperaudio.py", line 42, in load_audio
ffmpeg.input(file, threads=0)
File "C:UsersbertrAppDataLocalProgramsPythonPython310libsite-packagesffmpeg_run.py", line 313, in run
process = run_async(
File "C:UsersbertrAppDataLocalProgramsPythonPython310libsite-packagesffmpeg_run.py", line 284, in run_async
return subprocess.Popen(
File "C:UsersbertrAppDataLocalProgramsPythonPython310libsubprocess.py", line 969, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:UsersbertrAppDataLocalProgramsPythonPython310libsubprocess.py", line 1438, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

我已经尝试了这些解决方案,但都没有成功:

  • https://discuss.python.org/t/filenotfounderror-winerror-2-the-system-cannot-find-the-file-specified/9757/8
  • https://discuss.ray.io/t/winapi-createprocess-executable-args-filenotfounderror-winerror-2/5943/9

谢谢你的帮助!

使用whisper意味着使用ffmpeg。如[https://github.com/openai/whisper][1]所述"。它还需要在系统上安装命令行工具ffmpeg,该工具可以从大多数包管理器中获得:

# on Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# on Arch Linux
sudo pacman -S ffmpeg
# on MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg
# on Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg
# on Windows using Scoop (https://scoop.sh/)
scoop install ffmpeg

"安装应该检查:ffmpeg -version。PATH也应该更新为C:ffmpegbin或安装ffmpeg的正确位置

最新更新