Misc. Dialplan Tools phrase

From FreeSWITCH Wiki
Jump to: navigation, search

Speak a phrase of text using a predefined phrase macro. (For more information on TTS see mod_cepstral and OpenMRCP.)
See also the speech phrase management page for more information and examples; This command relies on the configuration in the phrases section of the freeswitch.xml file and including xml files in lang/en/*.xml. Following is a sample of phrases management:

 <section name="phrases" description="Speech Phrase Management">
   <macros>
     <language name="en" sound_path="/snds" tts_engine="cepstral" tts_voice="david">
       <macro name="msgcount">
         <input pattern="(.*)">
           <action function="execute" data="sleep(1000)"/>
           <action function="play-file" data="vm-youhave.wav"/>
           <action function="say" data="$1" method="pronounced" type="items"/>
           <action function="play-file" data="vm-messages.wav"/>
         </input>
       </macro>
       <macro name="saydate">
         <input pattern="(.*)">
           <action function="say" data="$1" method="pronounced" type="current_date_time"/>
         </input>
       </macro>
       <macro name="timespec">
         <input pattern="(.*)">
           <action function="say" data="$1" method="pronounced" type="time_measurement"/>
         </input>
       </macro>
       <macro name="spell">
         <input pattern="(.*)">
           <action function="say" data="$1" method="pronounced" type="name_spelled"/>
         </input>
       </macro>
       <macro name="spell-phonetic">
         <input pattern="(.*)">
           <action function="say" data="$1" method="pronounced" type="name_phonetic"/>
         </input>
       </macro>
       <macro name="tts-timeleft">
         <input pattern="(\d+):(\d+)">
           <action function="speak-text" data="You have $1 minutes, $2 seconds remaining $strftime(%Y-%m-%d)"/>
         </input>
       </macro>
     </language>
     <language name="fr" sound_path="/var/sounds/lang/fr/jean" tts_engine="cepstral" tts_voice="jean-pierre">
       <macro name="msgcount">
         <input pattern="(.*)">
           <action function="play-file" data="tuas.wav"/>
           <action function="say" data="$1" method="pronounced" type="items"/>
           <action function="play-file" data="messages.wav"/>
         </input>
       </macro>
       <macro name="timeleft">
         <input pattern="(\d+):(\d+)">
           <action function="speak-text" data="il y a $1 minutes et de $2 secondes de restant"/>
         </input>
       </macro>
     </language>
   </macros>
 </section>

Usage:

phrase <macro_name>,

Examples:

<extension name="556"> 
  <condition field="destination_number" expression="^556$">
    <action application="answer"/>
    <action application="sleep" data="1000"/>
    <action application="phrase" data="spell,${caller_id_name}"/>
    <action application="phrase" data="spell-phonetic,${caller_id_name}"/>
    <action application="phrase" data="timespec,12:45:15"/>
    <action application="phrase" data="saydate,0"/>
    <action application="phrase" data="msgcount,130"/>
  </condition>
</extension>