如何在python中使用espeak
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17547531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use espeak with python
提问by steel
I want to use espeak(http://espeak.sourceforge.net) with python2.7.0-32 bit in windows7.
我想在 windows7 中使用带有 python2.7.0-32 位的espeak( http://espeak.sourceforge.net)。
Additionally, I also want to save the audio files generated by espeak.
另外,我还想保存espeak生成的音频文件。
回答by Antonio MG
What are you asking exactly?
你具体问什么?
Here there is documentation:
这里有文档:
And samples:
和样品:
If you have a specific doubt we can help you.
如果您有具体疑问,我们可以为您提供帮助。
回答by Vidhuran
I tried to install this packagein Windows 8 but couldn't really get it in the first few attempts.
我试图在 Windows 8 中安装这个包,但在最初的几次尝试中无法真正得到它。
But this is what i did to get espeak to work with python
但这就是我为让 espeak 与 python 一起工作所做的工作
- Download and Install espeak for Windows from here
- Add the
eSpeak/command-line
folder toPATH
so that the commandespeak
is available - Call
espeak
commands using python modulesubprocess
similar to how it is done in the example below
- 从这里下载并安装 espeak for Windows
- 将
eSpeak/command-line
文件夹添加到,PATH
以便命令espeak
可用 espeak
使用 python 模块调用命令subprocess
类似于下面示例中的完成方式
http://machakux.appspot.com/blog/44003/making_speech_with_python
http://machakux.appspot.com/blog/44003/making_speech_with_python
回答by lolamontes69
How about something like this.
这样的事情怎么样。
import subprocess
def execute_unix(inputcommand):
p = subprocess.Popen(inputcommand, stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
return output
a = "Some amazing words of wisdom."
# write out to wav file
b = 'espeak -w temp.wav "%s" 2>>/dev/null' % a
# speak aloud
c = 'espeak -ven+f3 -k5 -s150 --punct="<characters>" "%s" 2>>/dev/null' % a #speak aloud
execute_unix(b)
execute_unix(c)
回答by Mikeys4u
Im using this at the moment which is working well...on my Raspberry Pi
我现在正在使用它,它运行良好......在我的 Raspberry Pi 上
from subprocess import call
call(["espeak","-s140 -ven+18 -z","Hello From Mike"])