RuntimeError:无法找到二进制'sox'

问题描述 投票:0回答:1

我正在玩谷歌语音库如下:

from google_speech import Speech

# say "Hello World"
text = "Hello World"
lang = "en"
speech = Speech(text, lang)
speech.play()

收到此错误:

RuntimeError                          

    Traceback (most recent call last)
<ipython-input-2-4daa3294f636> in <module>()
----> 1 from google_speech import Speech
      2 
      3 # say "Hello World"
      4 text = "Hello World"
      5 lang = "en"

D:\soft\Ins\anac\lib\site-packages\google_speech\__init__.py in <module>()
    321 
    322 # check deps
--> 323 bin_dep.check_bin_dependency(("sox",))
    324 
    325 

D:\soft\Ins\anac\lib\site-packages\google_speech\bin_dep.py in check_bin_dependency(bins)
      5   for bin in bins:
      6     if shutil.which(bin) is None:
----> 7       raise RuntimeError("Binary '%s' could not be found" % (bin))

RuntimeError: Binary 'sox' could not be found

我在Windows上工作,我做了所有的指示:

如果你还没有它,请安装pip for Python 3安装Google Speech:pip3 install google_speech安装SoX,支持MP3。关于Ubuntu和其他Debian衍生品:sudo apt-get install sox libsox-fmt-mp3。 Windows用户可以在SoX网站上下载二进制文件,一旦安装,您还需要在已安装SoX的目录中复制libmad DLL,并将此目录添加到PATH环境变量中。

python windows speech-recognition sox
1个回答
1
投票

您可以在sourceforge下载页面找到SoX的二进制文件和安装程序:Get it from here

将SoX添加到您的路径中

首先,找到安装SoX的目录。默认情况下,这可能是C:\ Program Files(x86)\ sox-14-4-1或C:\ Program Files \ sox-14-4-1

需要将此目录添加到PATH环境变量中。通过按Windows键并键入cmd.exe(在Vista或更高版本上)或从“开始”菜单中选择“运行”并键入cmd(在早期版本上)打开命令提示符。

在命令提示符下键入path,它应返回PATH变量(PATH =后跟目录列表)。要临时将SoX添加到PATH变量,请键入以下命令(如有必要,将S:\ Program Files(x86)\ sox-14-4-1替换为您的SoX目录):

set PATH=%PATH%;C:\Program Files (x86)\sox-14-4-1

再次输入路径,它应该返回与以前相同的目录列表,但是使用字符串; C:\ Program Files(x86)\ sox-14-4-1添加到最后。如果它返回任何其他内容(例如,如果它只返回SoX目录),则不要继续执行下一步(关闭命令提示符窗口并重新开始)。如果它返回相同的列表加上SoX,则可以使用setx命令而不是set来永久添加SoX:

setx PATH %PATH%;C:\Program Files (x86)\sox-14-4-1

在Windows XP上,您需要先安装Windows XP SP2支持工具,然后才能执行此操作。检查是否成功

要检查这是否有效,请打开一个新的命令提示符并键入sox。如果成功,它将返回有关使用SoX的信息,否则它应返回“sox not not recognized”。

© www.soinside.com 2019 - 2024. All rights reserved.