Mod tts commandline

From FreeSWITCH Wiki
Jump to: navigation, search

Run a command line and play the output file.

It is mainly for testing purpose. It may not fit for extensive use (but it may). Once you have chosen your TTS engine, write a native module!

Contents

Installing mod_tts_commandline

  • In modules.conf, add asr_tts/mod_tts_commandline.

Linux:

  • Run make, make install.

Windows:

  • copy the msvc project from freeswitch-contrib in grmt\mod_tts_commandline for windows
  • add project to Freeswitch.2010.sln and build it (sorry, I didn't test MSVC 2008)

Configuring mod_tts_commandline

  • In freeswitch/conf/autoload_configs/modules.conf.xml, uncomment <load module="mod_tts_commandline"/>.
  • Edit conf/autoload_configs/tts_commandline.conf.xml.
  • Reload configuration by reloadxml (or restarting FreeSWITCH)
  • Add tts_commandline to dialplan (or phrase, etc.) like this:
<action application="speak" data="tts_commandline|pico|This is an example of using tts_commandline"/>

Example commands

Using festival's text2wave:

echo ${text} | text2wave -f ${rate} > ${file}

Using festival's server client:

echo ${text} | festival_client --server xxx.xxx.xxx.xxx --otype riff --ttw --output ${file}

(may be needed ajust festival's default sample rate on server)

Using Cepstral's swift:

swift -n ${voice} ${text}  -o ${file}

Using espeak (using sox to adjust sample rate):

echo ${text} | espeak --stdin -v ${voice} --stdout | sox -t wav - -r ${rate} ${file}

Using espeak + mbrola :

echo ${text} | espeak --stdin -v mb/mb-fr4 | mbrola -e /usr/share/mbrola/voices/fr4 - -.au | sox -t au - -r ${rate} ${file}

Using lliaphon + mbrola (French voice fr4) (NB it does not work for me):

echo ${text} | (lliaphon 2>/dev/null) | mbrola -e -f 1.0 -t 0.6 -l 8000 -I /usr/local/share/lliaphon/initfile.lia /usr/share/mbrola/voices/fr4 - ${file}

Using svox pico (from the Android project - supports it-IT, fr-FR, es-ES, de-DE, en-US and en-GB languages:

pico2wave --lang=fr-FR --wave=/tmp/$$.wav ${text} && sox /tmp/$$.wav -r ${rate} ${file} && rm /tmp/$$.wav

(You should apply patches from here (see alsoissue 4362 and issue 4363)

Write your own here...

Notes on svox pico

Windows:

  • build from MSVC 2010 solution file freeswitch-contrib in grmt\svox pico\svoxpico for windows (again sorry I didn't do MSVC 2008)

Linux (at least tested on x64 centos - includes fixes from below and even more fixes from debian-sid and some more fixes to make it compatible with MSVC 2010):

  • freeswitch-contrib in grmt/svox\ pico/svox/pico
  • sh ./autogen.sh
  • ./configure
  • make && make install

or alternatively :

Here is a sample of cmd that work on centos 5 64bit (This code includes a fix so it works ok on a 64bit system)

mkdir ~/src
cd ~/src
git clone git://git.debian.org/collab-maint/svox.git svox-git
cd svox-git
git branch -a
git checkout -f origin/debian-sid
cd pico
base64 -d -i << EOF | patch -p2
ZGlmZiAtLWdpdCBhL3BpY28vbGliL3BpY29hcGkuYyBiL3BpY28vbGliL3BpY29hcGkuYwppbmRl
eCBiZTZkMWEyLi5kMDk5YmRhIDEwMDY0NAotLS0gYS9waWNvL2xpYi9waWNvYXBpLmMKKysrIGIv
cGljby9saWIvcGljb2FwaS5jCkBAIC00MSwxMCArNDEsMTAgQEAgZXh0ZXJuICJDIiB7CiAjZGVm
aW5lIE1BR0lDX01BU0sgMHg1MDY5NjM2RiAgLyogUGljbyAqLwogCiAjZGVmaW5lIFNFVF9NQUdJ
Q19OVU1CRVIoc3lzKSBcCi0gICAgKHN5cyktPm1hZ2ljID0gKChwaWNvb3NfdWludDMyKSAoc3lz
KSkgXiBNQUdJQ19NQVNLCisgICAgKHN5cyktPm1hZ2ljID0gKChwaWNvb3NfdWludHB0cl90KSAo
c3lzKSkgXiBNQUdJQ19NQVNLCiAKICNkZWZpbmUgQ0hFQ0tfTUFHSUNfTlVNQkVSKHN5cykgXAot
ICAgICgoc3lzKS0+bWFnaWMgPT0gKCgocGljb29zX3VpbnQzMikgKHN5cykpIF4gTUFHSUNfTUFT
SykpCisgICAgKChzeXMpLT5tYWdpYyA9PSAoKChwaWNvb3NfdWludHB0cl90KSAoc3lzKSkgXiBN
QUdJQ19NQVNLKSkKIAogCiAKZGlmZiAtLWdpdCBhL3BpY28vbGliL3BpY29hcGkuaCBiL3BpY28v
bGliL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gICgoZW5nKS0+bWFnaWMg
PT0gKCgocGljb29zX3VpbnRwdHJfdCkgKGVuZykpIF4gTUFHSUNfTUFTSykpCiAKIC8qKgogICog
cGVyZm9ybXMgYW4gZW5naW5lIHJlc2V0CmRpZmYgLS1naXQgYS9waWNvL2xpYi9waWNvb3MuaCBi
L3BpY28vbGliL3BpY29vcy5oCmluZGV4IDg1OWUxNzYuLmZlNWFmYmEgMTAwNjQ0Ci0tLSBhL3Bp
Y28vbGliL3BpY29vcy5oCisrKyBiL3BpY28vbGliL3BpY29vcy5oCkBAIC03MCw2ICs3MCw4IEBA
IHR5cGVkZWYgcGljb3BhbF91aW50OCAgIHBpY29vc19ib29sOwogdHlwZWRlZiBwaWNvcGFsX29i
anNpemVfdCBwaWNvb3Nfb2Jqc2l6ZV90OwogdHlwZWRlZiBwaWNvcGFsX3B0cmRpZmZfdCBwaWNv
b3NfcHRyZGlmZl90OwogCit0eXBlZGVmIHBpY29wYWxfdWludHB0cl90IHBpY29vc191aW50cHRy
X3Q7CisKIC8qICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KiovCiAvKiBmdW5jdGlvbnMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAq
LwogLyogKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8K
ZGlmZiAtLWdpdCBhL3BpY28vbGliL3BpY29wYWwuaCBiL3BpY28vbGliL3BpY29wYWwuaAppbmRl
eCBhY2ZjOGUwLi4yZTY0NDI3IDEwMDY0NAotLS0gYS9waWNvL2xpYi9waWNvcGFsLmgKKysrIGIv
cGljby9saWIvcGljb3BhbC5oCkBAIC00MSw2ICs0MSw3IEBACiAjaW5jbHVkZSA8c3RkZGVmLmg+
CiAjaW5jbHVkZSAicGljb3BsdGYuaCIKICNpbmNsdWRlICJwaWNvZGVmcy5oIgorI2luY2x1ZGUg
PGludHR5cGVzLmg+CiAKICNpZmRlZiBfX2NwbHVzcGx1cwogZXh0ZXJuICJDIiB7CkBAIC0xMTcs
NiArMTE4LDcgQEAgdHlwZWRlZiB1bnNpZ25lZCBjaGFyICAgcGljb3BhbF91Y2hhcjsKIAogdHlw
ZWRlZiBzaXplX3QgICAgcGljb3BhbF9vYmpzaXplX3Q7CiB0eXBlZGVmIHB0cmRpZmZfdCBwaWNv
cGFsX3B0cmRpZmZfdDsKK3R5cGVkZWYgdWludHB0cl90IHBpY29wYWxfdWludHB0cl90OwogCiAv
KiAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwogLyog
ZnVuY3Rpb25zICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KZGlmZiAt
LWdpdCBhL3BpY28vbGliL3BpY29wci5jIGIvcGljby9saWIvcGljb3ByLmMKaW5kZXggMGQ2MTVk
OS4uYzAxY2ZkZSAxMDA2NDQKLS0tIGEvcGljby9saWIvcGljb3ByLmMKKysrIGIvcGljby9saWIv
cGljb3ByLmMKQEAgLTMyMDksMTEgKzMyMDksMTEgQEAgcGljb19zdGF0dXNfdCBwclJlc2V0KHJl
Z2lzdGVyIHBpY29kYXRhX1Byb2Nlc3NpbmdVbml0IHRoaXMsIHBpY29vc19pbnQzMiByZXNldE0K
ICAgICBwci0+YWN0Q3R4Q2hhbmdlZCA9IEZBTFNFOwogICAgIHByLT5wcm9kTGlzdCA9IE5VTEw7
CiAKLSAgICBpZiAoKChwaWNvb3NfdWludDMyKXByLT5wcl9Xb3JrTWVtICUgUElDT09TX0FMSUdO
X1NJWkUpID09IDApIHsKKyAgICBpZiAoKChwaWNvb3NfdWludHB0cl90KXByLT5wcl9Xb3JrTWVt
ICUgUElDT09TX0FMSUdOX1NJWkUpID09IDApIHsKICAgICAgICAgcHItPndvcmtNZW1Ub3AgPSAw
OwogICAgIH0KICAgICBlbHNlIHsKLSAgICAgICAgcHItPndvcmtNZW1Ub3AgPSBQSUNPT1NfQUxJ
R05fU0laRS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ZmluZSBNQUdJQ19NQVNLIDB4NzA0OTYzNEYgIC8q
IHBJY08gKi8KIAogI2RlZmluZSBTRVRfTUFHSUNfTlVNQkVSKHJlcykgXAotICAgIChyZXMpLT5t
YWdpYyA9ICgocGljb29zX3VpbnQzMikgKHJlcykpIF4gTUFHSUNfTUFTSworICAgIChyZXMpLT5t
YWdpYyA9ICgocGljb29zX3VpbnRwdHJfdCkgKHJlcykpIF4gTUFHSUNfTUFTSwogCiAjZGVmaW5l
IENIRUNLX01BR0lDX05VTUJFUihyZXMpIFwKLSAgICAoKHJlcyktPm1hZ2ljID09ICgoKHBpY29v
c191aW50MzIpIChyZXMpKSBeIE1BR0lDX01BU0spKQorICAgICgocmVzKS0+bWFnaWMgPT0gKCgo
cGljb29zX3VpbnRwdHJfdCkgKHJlcykpIF4gTUFHSUNfTUFTSykpCiAKIAogCkBAIC02MDMsNyAr
NjAzLDcgQEAgcGljb19zdGF0dXNfdCBwaWNvcnNyY19sb2FkUmVzb3VyY2UocGljb3JzcmNfUmVz
b3VyY2VNYW5hZ2VyIHRoaXMsCiAgICAgICAgICAgICBzdGF0dXMgPSAoTlVMTCA9PSByZXMtPnJh
d19tZW0pID8gUElDT19FWENfT1VUX09GX01FTSA6IFBJQ09fT0s7CiAgICAgICAgIH0KICAgICAg
ICAgaWYgKFBJQ09fT0sgPT0gc3RhdHVzKSB7Ci0gICAgICAgICAgICByZW0gPSAocGljb29zX3Vp
bnQzMikgcmVzLT5yYXdfbWVtICUgUElDT09TX0FMSUdOX1NJWkU7CisgICAgICAgICAgICByZW0g
PSAocGljb29zX3VpbnRwdHJfdCkgcmVzLT5yYXdfbWVtICUgUElDT09TX0FMSUdOX1NJWkU7CiAg
ICAgICAgICAgICBpZiAocmVtID4gMCkgewogICAgICAgICAgICAgICAgIHJlcy0+c3RhcnQgPSBy
ZXMtPnJhd19tZW0gKyAoUElDT09TX0FMSUdOX1NJWkUgLSByZW0pOwogICAgICAgICAgICAgfSBl
bHNlIHsK
EOF
./autogen.sh
./configure --prefix=/opt/svox-pico/
make install