如何在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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 08:29:15  来源:igfitidea点击:

How to use espeak with python

pythonwindowswindows-7espeak

提问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:

这里有文档:

eSpeak Documentation

eSpeak 文档

And samples:

和样品:

eSpeak samples

eSpeak 示例

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 一起工作所做的工作

  1. Download and Install espeak for Windows from here
  2. Add the eSpeak/command-linefolder to PATHso that the command espeakis available
  3. Call espeakcommands using python module subprocesssimilar to how it is done in the example below
  1. 这里下载并安装 espeak for Windows
  2. eSpeak/command-line文件夹添加到,PATH以便命令espeak可用
  3. 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"])