如何使用命令行进行文本到语音输出?
如何使用命令行从输入的文本中获取语音输出 ?
还可以使用简单的命令改变语速,音高,音量等。
按降序流行 :
-
比如使用GNUstep语音引擎将文本转换为可听语音。
sudo apt-get install gnustep-gui-runtime say "hello"
-
节日通用多语言语音合成系统。
sudo apt-get install festival echo "hello" | festival --tts
-
spd-say向语音调度员发送文本到语音输出请求
sudo apt-get install speech-dispatcher spd-say "hello"
-
espeak是一种多语言软件语音合成器。
sudo apt-get install espeak espeak "hello"
来自man spd-say
:
名称 spd-say - 向语音调度员发送文本到语音输出请求 概要 spd-say [options]“some text” 描述 spd-say向语音调度程序进程发送文本到语音输出请求,该进程处理它并理想地输出结果 到音频系统。 OPTIONS -r,--rate 设置语音速率(介于-100和+100之间,默认值:0) -p, - pitch 设置语音的音高(介于-100和+100之间,默认值:0) -i, - 体积 设置语音的音量(强度)(介于-100和+100之间,默认值:0)
因此,您可以通过以下命令获得文本到语音:
spd-say ""
例如:
spd-say "Welcome to Ubuntu Linux"
您还可以设置语速,音高,音量等。请参阅man-page。
对于festival
(声音对我来说似乎更自然):
sudo apt-get install festival
echo "hello" | festival --tts
间距和速度配置:
创建~/.festivalrc
:
(Parameter.set 'Audio_Command "play -b 16 -c 1 -e signed-integer -r $SR -t raw $FILE tempo 1.5 pitch -100") (Parameter.set 'Audio_Method 'Audio_Command)
另见http://www.solomonson.com/content/ubuntu-linux-text-speech
更新:尝试在另一台ubuntu计算机上。 不得不安装英语语音引擎包与节日合作:
sudo apt-get install festvox-kallpc16k
另外play
是一个带有sox
包的cli命令:
sudo apt-get install sox
2017年11月Ubuntu 16.04
对于我的项目,可以说话的cron
工作, espeak
是最简单的。
sudo apt-get update sudo apt-get install espeak
对于第一部分,让系统说出时间需要一个单独的cron条目
0 * * * * /home/username/scripts/saytime
saytime:
#!/bin/bash echo "\`$(date +%H)\` Hundred" | espeak
它可以通过stdio接收输入,如下所示:
cat textfile | espeak -s 100
作为参考,以下是eSpeak的选定命令行选项:
espeak [options] [“”]
-一个
Amplitude, 0 to 200, default is 100
-G
Word gap. Pause between words, units of 10mS at the default speed
-k
Indicate capital letters with: 1=sound, 2=the word "capitals", higher values indicate a pitch increase (try -k20).
-l
Line length. If not zero (which is the default), consider lines less than this length as end-of-clause
-p
Pitch adjustment, 0 to 99, default is 50
-s
Speed in words per minute, 80 to 450, default is 175
-v
Use voice file of this name from espeak-data/voices
-w
Write speech to this WAV file, rather than speaking it directly
-z
No final sentence pause at the end of the text
–voices =
List the available voices for the specified language. If
is omitted, then list all voices.
Python Google Speach:
pip install google_speech google_speech "Test the hello world"
来自Android的Svox:
apt-get install svox-pico pico2wave --wave=test.wav "Test the hello world" play test.wav
Svox Nanotts:
git clone https://github.com/gmn/nanotts.git cd nanotts make ./nanotts -v en-US "Test the hello world"
链接 – 维基:
语音合成器的比较