Four: Call Ekho in FreeSWITCH
Note: The voice packet seems useless during the testing process
FreeSWITCH Chinese Voice Pack beta Fssounds.zip
Create a directory under/usr/local/freeswitch/sounds/zh/cn/sue (because I don't know the name of the voice owner, I'll take Sue instead, sorry)
Mkdir-p/usr/local/freeswitch/sounds/zh/cn/sue
Move a sound file to the destination directory
MV output/*/usr/local/freeswitch/sounds/zh/cn/sue/
-Added Chinese definition
Cd/usr/local/freeswitch/conf/lang
Cp-a en en
CD en
MV En.xml Zh.xml
Edit the Zh.xml and replace the 2nd line with
<language name= "zh" say-module= "zh" sound-prefix= "$${sounds_dir}/zh/cn/sue" tts-engine= "Mod_tts_commandline" Tts-voice= "Sue" >
-Increase the loading of Chinese
Edit/usr/local/freeswitch/conf/freeswitch.xml, find <section name= "languages" description= "Language Management" > Segment Join
<x-pre-process cmd= "include" Data= "Lang/zh/*.xml"/>
-Increased loading of Chinese say modules
Edit/usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
Remove comments from <load module= "Mod_say_zh"/>
-Set Chinese as the default language
Edit/usr/local/freeswitch/conf/vars.xml, add the following lines
<x-pre-process cmd= "Set" Data= "Default_language=zh"/>
<x-pre-process cmd= "Set" Data= "DEFAULT_DIALECT=CN"/>
<x-pre-process cmd= "Set" Data= "Default_voice=sue"/>
-Added support for Ekho in Chinese
Edit/usr/local/freeswitch/conf/autoload_configs/tts_commandline.conf.xml
<param name= "command" Value= "Echo ${text} | Text2wave-f ${rate} > ${file} "/>
Switch
<param name= "command" Value= "Echo ${text} > Tmp.txt; Iconv-t UTF8 tmp.txt >${file}.txt; Ekho-v ${voice}-F ${file}.txt-o ${file} "/>
Or is. where Iconv-t UTF8 tmp.txt >${file}.txt; This is because some systems are converting character encodings
<param name= "command" Value= "Echo ${text} > ${file}.txt; Ekho-f ${file}.txt-o ${file} "/>
-Reload XML, in Fs_cli, to execute:
Reloadxml
-Outbound call routing to LUA scripting for TTS
Originate user/1002 &lua (Recharge.lua)
1--session:set_tts_parms ("Tts_commandline", "ting-ting") 2--session:setvariable ("Tts_engine", "Tts_commandline") 3 --session:setvariable ("Tts_voice", "ting-ting") 4--session:answer () 5--session:sleep (+) 6--print ("Hello") 7--se Ssion:speak ("Hello") 8--session:speak ("Hello, Welcome to Air Recharge Service") 9--session:speak ("Hello, I am a good person")--session:sleep (5000) 11 12 Error_prompt = "SAY: input error, please re-enter" "account =" "digits =" "balance = 100-balance of charge = 100--Prepaid card amount * Function error () session:speak ("Input error, please re-enter") End of function Do_charge (account, charge) Balanc E = balance + charge return balance the end of function main_menu () if not session:ready () then return E nd--session:speak (' Enquiry please press 1, recharge please press 2, otherwise please hang up the machine ') digits = session:playandgetdigits (1, 1, 3, 10000, "#", "Say: Inquiry please press 1, recharge please press 2, otherwise please hang up the machine", Error_prompt, "^1|2$")--digits = Session:playandgetdigits (2, 2, 3, 10000, "#", "", "" , "")--sessioN:speak (' input error, please reenter ') "--digits = Session:playandgetdigits (1, 1, 3, +," # "," "," "," ^1|2$ ") Sessi On:execute ("Log", "INFO Main_Menu:"). digits) if not (digits = = ") then-ask_account (digits)-all else---session: Speak (' input error, please re-enter ')--main_menu () Goodbye ()-end-of-the-function Ask_accou NT (Service_type) Session:ready () then return end digits = Session:playandgetdigits (4, 5, 3, 5 "#", "Say: Please enter your account number, to the end of the pound", Error_prompt, "^\\d{4}$") Session:execute ("Log", "INFO Account:"). digits) if not (digits = = ") then the account = digits if (Service_type = =" 1 ") Then Ask_account_password () Else Ask_card () 57 End + Else Goodbye ()-end-of-the-function Ask_account_password ()F not Session:ready () then return end digits = Session:playandgetdigits (4, 5, 3,, "#", "Say: Please enter your password to End of the pound ", Error_prompt," ^\\d{4}$ ") Session:execute (" Log "," INFO account P: "). digits) (digits = = "") then Password = Digits Chack_account_password () 7 1 Else Goodbye () The end of the Ask_card (), if not Session:ready () Then return end of the digits = Session:playandgetdigits (4, 5, 3,, "#", "Say: Please enter your prepaid card number to the end of the pound", error_prompt , "^\\d{4}$") Session:execute ("Log", "INFO Card:") digits) if not (digits = = "") then $ = Digits Chack_account_card () 87 Else goodbye () The end of the Chack_account_password () 94 If not SES Sion:ready () Then return end, if (account = = "1111" and Password = = "1111") then SessiOn:speak ("Your balance is": balance.) "Yuan") 98 Session:sleep () Main_Menu () else101 session:speak ("Transmission Input error, re-enter ") 102 Main_Menu () 103 end104 end105 106 function Chack_account_card () 107 if not Sessio N:ready () then return end108 109 if (account = = "1111" and card = = "2222") then110 session:speak ("You want to recharge " .. Charge. "Yuan") 111 digits = Session:playandgetdigits (1, 1, 3, 10000, "#", "Say: Confirm please press 1, return please press 2", Error_promp T, "^[12]$") 113 if digits = = "1" then115 balance = do_charge (account, charge) 116 Session:speak ("Top up successfully, top up amount"): Charge. "Yuan, the balance is". Balance. "Yuan") 117 Main_Menu () 118 else119 if digits = = "2" then120 Session:sleep (121) Main_Menu () 122 else12 3 Goodbye () 124 end125 end126 else127 Session:spea K ("Input wrong, please re-enter") Ask_account ("2") 129 end130 end131 () Goodbye if not session: Ready () then return end134 135 session:speak ("Good-Bye") 136 Session:hangup () 137 end138 139 Arms ("Tts_commandline", "Mandarin") 141 session:setvariable ("Tts_engine", "Tts_commandline") 142 session:setvariable ("Tts_voice", "Mandarin") 143 144 Session:answer () 145--session:speak ("Hello,welcome to FreeSWITCH") 146 Session:speak ( "Hello, welcome to use air Recharge service")--, "zh", "messages", "pronounced") 147 session:set_tts_parms ("Flite", "Kal") 148 Session:speak (" Please say the name of the person you ' re trying to contact ") 149 session:set_tts_parms (" Tts_commandline "," Mandarin ") 150-- Session:speak ("Hello, Welcome to use air Recharge service") 151--session:say ("12345", "zh", "number", "pronounced")--session:sleep (10000) 153 Main_Menu () 154--session:streamfile ("/usr/local/freesWitch/hello.wav ") 155--session:streamfile ("/usr/local/freeswitch/sounds/zh/cn/sue/ivr/8000/ivr-accept_reject_ Voicemail.wav ") 156--sound.load ("/usr/local/freeswitch/sounds/music/8000/ Danza-espanola-op-37-h-142-xii-arabesca.wav "):p Lay () 157 session:hangup () 158--session:print (" hello! ")
Special attention:
First, install the Mod_say_zh and Mod_tts_commandline modules in FreeSWITCH, and if FreeSWITCH is installed but the 2 modules are not installed, follow these steps to install them:
1. Use in the FreeSWITCH source code directory
Make Mod_say_zh-install
Make Mod_tts_commandline
2. Then load the module into the FreeSWITCH
Load Mod_say_zh
Load Mod_tts_commandle
The FreeSWITCH in CentOS 5 is integrated using Ekho to implement TTS function three