我在Linux上编写了一个C程序,从它的边长("l")算出正方形的周长(我称之为周长变量"p")。现在我想使用speak,一个在Linux上的语音合成程序来讲述结果。我想过使用“系统”方法。
例如,如果我想让would在我的程序中说"hello“,我会这样做:
system("espeak -v it Hello");
现在我该怎么处理周边环境?
system ("espeak -v it The perimeter is p");
不起作用。
我已经下载了espeak-ng 1.1.49和./configure make make install,并通过espeak --stdout "this is a test" | paplay成功地进行了测试,并且成功了。然后,我尝试在我的C++代码(testSpeak.cpp)中使用它,这是我在互联网上找到的,如下所示:
#include <string.h>
#include <vector>
#include </usr/local/include/espeak-ng/speak_lib.h>
int samplerate; /
我对linux有点陌生,我试着运行这个python代码。第一次,它要求我安装libespeak并尝试再次运行代码。当我运行代码时,安装了它之后,声音非常奇怪,非常机械,听起来很糟糕。以下是代码:
import pyttsx3
engine = pyttsx3.init()
def speak(text):
engine.say(text)
engine.runAndWait()
speak("Hello World and this is a test.")
当我试图用相同的python版本在windows 10上运行相同的代码时,听起来很正常,但是当
所以我需要安装一个包,但当我尝试下载它时,出现一个错误,说我需要升级pip,所以我(升级到版本19.0.1),但它不起作用,在那之后,我无法下载任何包,并且总是出现这样的错误: C:\Users\Marina bar>python -m pip install espeak
Collecting espeak
Could not find a version that satisfies the requirement espeak (from
versions: )
No matching distribution found for espeak 我尝试使用python -m
我正在尝试使用使用MBROLA语音"us1“的python来执行es匹克。
from subprocess import call
call(["espeak","-v mb-us1","Hello, I am espeak"])
然后出现以下错误:
读不清声音‘mb-us1’
但它可以很好地应用于:
os.system("espeak -v mb-us1 'hello, I am espeak'")
我正在制作一个pyttsx3聊天机器人,但是发生了这个错误:
OSError: libespeak.so.1: cannot open shared object file: No such file or directory
还发生了此错误:
KeyError: None
下面是我的代码:
import pyttsx3
def say(sp):
engine = pyttsx3.init()
engine.say(sp)
engine.runandwait()
say("Hello my name is Neuron")
有人知道我怎么解决
在这里看到了上述问题的解决方案后,当我在OSError: libespeak.so.1: cannot open shared object file: No such file or directory中安装espeak时,同样也出现了同样的问题,安装后我重新启动了系统,如果它工作了,它也不工作,我在google collab上做这段代码时,我也再次安装了libespeak1,同样的问题也发生了
我想知道是否有一种方法可以像在命令行中那样访问espeak:
laptop:~$espeak
say this line first
say this line second
...
现在,我在python中唯一能做到这一点的方法是process = subprocess.Popen(['espeak'], stdin=subprocess.PIPE ),然后是
process.communicate(expression)
或
process.stdin.write(expression)
process.stdin.close()
前者阻止程序的其余部分,直到espeak完
我正在写一个程序,我正在使用espeak库来让它说话。问题是我已经编写了我的程序,但现在我想在一开始就问用户,他是想让程序与他对话,还是仅仅依靠阅读。因此,如果他说是,程序使用espeak,但如果他说不,程序不使用espeak,那么我就被困在no部分了。 我想问一个问题,并根据答案使用正确的函数,但问题是它是一个本地函数,所以当您使用函数espeak()时,它会说 NameError: name 'espeak' is not defined 下面是我想要的: import os
ai_talk = False
# MAKE THE AI SPEAK, OR NOT
def
我是linux的新手,我试着运行这段python代码。第一次,它要求我安装libespeak dev,然后再次尝试运行代码。安装后,当我运行代码时,声音非常奇怪,非常机械,听起来很糟糕。代码如下:
import pyttsx3
engine = pyttsx3.init()
def speak(text):
engine.say(text)
engine.runAndWait()
speak("Hello World and this is a test.")
由于某些原因,我无法附加mp3文件来说明它听起来有多糟糕。顺便说一下,我使用的是Ubuntu
一开始我会说这里有一个类似的帖子:和我正在使用这个帖子的答案,但我仍然收到错误,所以也许你可以帮助我解决它。
import subprocess
text = '"Hello world"'
subprocess.call('espeak '+text, shell=True)
这段代码给了我一个错误:
'espeak' is not recognized as an internal or external command,
operable program or batch file.
ps。我想我安装espeak是正确的,因