当前位置: 首页>>技术教程>>正文


如何使用命令行输出text-to-speech?

, ,

问题描述

如何使用命令行从输入的文本中获取语音输出?

还可以使用简单的命令改变语速,音高,音量等。

最佳解决方法

按降序popularity

  • say使用GNUstep语音引擎将文本转换为可听语音。

    sudo apt-get install gnustep-gui-runtime
    say "hello"
    
  • festival通用multi-lingual语音合成系统。

    sudo apt-get install festival
    echo "hello" | festival --tts
    
  • spd-say向speech-dispatcher发送text-to-speech输出请求

    sudo apt-get install speech-dispatcher
    spd-say "hello"
    
  • espeak是multi-lingual软件语音合成器。

    sudo apt-get install espeak
    espeak "hello"
    

次佳解决方法

来自man spd-say


NAME
       spd-say - send text-to-speech output request to speech-dispatcher

SYNOPSIS
       spd-say [options] "some text"

DESCRIPTION
       spd-say  sends text-to-speech output request to speech-dispatcher process which handles it and ideally outputs the result
       to the audio system.

OPTIONS
       -r, --rate
              Set the rate of the speech (between -100 and +100, default: 0)

       -p, --pitch
              Set the pitch of the speech (between -100 and +100, default: 0)

       -i, --volume
              Set the volume (intensity) of the speech (between -100 and +100, default: 0)

因此,您可以通过以下命令获取text-to-speech:

spd-say "<type text>"

例如:

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] [“”]

-a

 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 <language> 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"

链接 – 维基:

Comparison of speech synthesizers

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/1349.html,未经允许,请勿转载。