Archive for July, 2011


FreeSWITCH tutorial part-2

In this tutorial I will show you how to configure  ivr_demo and Voice mail in German Language.You can configure even your dial plan.

1) Basic Setup

Install German sounds from freeswitch-sounds-de-at-ute-8000-0.0.1.tar.gz  from http://freeswitch.xpirio.com/

extract in /opt/freeswitch/sounds.

In directory  “opt/freeswitch/sounds/de/at/ute/” create folder ivr and copy “8000” folder from “opt/freeswitch/sounds/de/at/ute/ivr_not_ok” . This step is important to enable ivr in German.

Install  freeswitch-lang-de  from synaptic if not installed.

Add ” <load module=”mod_say_de” />  ” in  /conf/autoconf/module.conf.xml  under ” <!– Say –> ” section.

In freeswitch.xml  add  ”  <X-PRE-PROCESS cmd=”include” data=”lang/de/*.xml”/> ”

<section name="phrases" description="Speech Phrase Management">
<macros>
<X-PRE-PROCESS cmd="include" data="lang/de/*.xml"/>
<X-PRE-PROCESS cmd="include" data="lang/en/*.xml"/>
</macros>
</section>

modify sound-path in /conf/lang/de/de.xml  to “$${sounds_dir}/de/at/ute”  .


<include>
<language name="de" sound-path="$${sounds_dir}/de/at/ute" tts-engine="cepstral" tts-voice="david">
<X-PRE-PROCESS cmd="include" data="demo/*.xml"/>
<!--voicemail_de_tts is purely implemented with tts, we need a files based implementation too -->

<X-PRE-PROCESS cmd=”include” data=”vm/tts.xml”/>

</language>
</include>

2) ivr_demo in German.

goto  /conf/dialplan/default.xml  .search for “ivr_demo” . when you call on 5000 ,you will hear  ivr in english language. To configure it in German add following line under “condition” section in “ivr_demo” extension.

<action application=”set” data=”default_language=de”/>

For example.

<!-- a sample IVR  -->
<extension name="ivr_demo">
<condition field="destination_number" expression="^5000$">
<action application="set" data="default_language=de"/>
<action application="answer"/>
<action application="sleep" data="2000"/>
<action application="ivr" data="demo_ivr"/>
</condition>
</extension>

copy /opt/freeswitch/conf/lang/en/demo/demo-ivr.xml to /opt/freeswitch/conf/lang/de/demo/ .

and modify /opt/freeswitch/conf/lang/de/de.xml to

<include>
<language name="de" sound-path="$${sounds_dir}/de/at/ute" tts-engine="cepstral" tts-voice="david">
    <X-PRE-PROCESS cmd="include" data="demo/*.xml"/>
<!--voicemail_de_tts is purely implemented with tts, we need a files based implementation too -->
<X-PRE-PROCESS cmd="include" data="vm/tts.xml"/>
</language>
</include>

IF you don’t follow above step you will get following error when you call on 5000

[ERR] switch_ivr_play_say.c:150 Can't find macro demo_ivr_main_menu.

[ERR] switch_ivr_play_say.c:150 Can’t find macro demo_ivr_main_menu_short

etc…

We are Done !!

3) Voicemail in German.

Open /conf/dialplan/default.xml  . Search <extension name=”vmain”> .

Add <action application=”set” data=”default_language=de”/>

For Example.

<!-- voicemail main extension -->
<extension name="vmain">
<condition field="destination_number" expression="^vmain$|^4000$|^\*98$">
<action application="set" data="default_language=de"/>
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="voicemail" data="check default ${domain_name}"/>
</condition>
</extension>

Call 4000 .

if you run into following error

" [ERR] switch_core_speech.c:61 Invalid speech module [cepstral]!
[ERR] switch_ivr_play_say.c:2136 Invalid TTS module!
[ERR] switch_core_speech.c:61 Invalid speech module [cepstral]!
[ERR] switch_ivr_play_say.c:2136 Invalid TTS module!
[ERR] switch_core_speech.c:61 Invalid speech module [cepstral]!
[ERR] switch_ivr_play_say.c:2136 Invalid TTS module!
"

You need to install cepstral Or you can follow the following trick.

copy /opt/freeswitch/conf/lang/en/vm/sounds.xml to /opt/freeswitch/conf/lang/de/vm/ .

modify /opt/freeswitch/conf/lang/de/de.xml to as follow.

<include>
<language name="de" sound-path="$${sounds_dir}/de/at/ute" tts-engine="cepstral" tts-voice="david">
<X-PRE-PROCESS cmd="include" data="demo/demo.xml"/>
<!--voicemail_de_tts is purely implemented with tts, we need a files based implementation too -->
<!--
   <X-PRE-PROCESS cmd="include" data="vm/tts.xml"/>
-->
  <X-PRE-PROCESS cmd="include" data="vm/sounds.xml"/>
</language>
</include>

Call 4000 .

We are done!

3) custom dialplan in German.

In pervious tutorial we created simple dialplan which pronouns  some digits. dialplan was as follow.

<extension name="mydemo">
<condition field="destination_number" expression="^5343$">
<action application="answer"/>
<action application="say" data="en number pronounced 12345"/>
</condition>
</extension>

to pronouns digit in German you need to just add following line.

<extension name="mydemo">
<condition field="destination_number" expression="^5343$">
<action application="set" data="default_language=de"/>
<action application="answer"/>
<action application="say" data="en number pronounced 12345"/>
</condition>
</extension>

We are done!!

In this tutorial I am going to cover following topics.

1) Setting up freeswitch on Ubuntu.

2)Try demo-ivr application,voicemail

3) Create  simple dialplan.

1)Setting up freeswitch on Ubuntu.

        Install FreeSWITCH

Setting freeswitch on ubuntu is pretty  easy. Open terminal and execute following commands.
apt-get install python-software-properties
add-apt-repository ppa:freeswitch-drivers/freeswitch-nightly-drivers
apt-get update
apt-get install freeswitch freeswitch-lang-en freeswitch-sounds-en-us-callie-8000

You can also download  freeswitch-lang-de, freeswitch-lang-fr  etc to support different language.freeswitch will be installed in /opt directory.

Enabling FreeSWITCH

nano /etc/default/freeswitch

FREESWITCH_ENABLED="true"

Start freeSWITCH.

execute invoke-rc.d freeswitch start or  sudo /opt/freeswitch/bin/freeswitch .

If you get  following error it means freeswitch is running in background.you can try sudo /opt/freeswitch/bin/fs_cli.
Error: stacksize 4194303 is too large: run ulimit -s 240 or run /opt/freeswitch/bin/freeswitch -waste.
auto-adjusting stack size for optimal performance...
Cannot lock pid file /opt/freeswitch/run/freeswitch.pid.
To stop freeswitch  execute invoke-rc.d freeswitch stop.

2) Try some sample demo IVR,voicemail,etc..

Go to /conf/diaplan/default.xml. Search for extension name  “ivr_demo”.  To try ivr_demo you need to call  on 5000 .

I assume you have started freeswitch in terminal and you have command prompt something like “freeswitch@user>”

Try following commands if you have not configured sip account.

load mod_portaudio

pa call 5000

pa hangup.

In /conf/dialplan/default.xml  search for  <extension name=”vmain”> . To try voicemail you need to call on 4000 .

3)Create simple dialplan

Go to /conf/diaplan/default.xml.  add following code

<extension name=”mydemo”>
<condition field=”destination_number” expression=”^5343$”>
<action application=”answer”/>
<action application=”say” data=”en number pronounced 12345″/>
</condition>
</extension>

in console execute   “reloadxml” and call on 5343 and see what happens.  please refer following link

http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_say
http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_phrase
http://wiki.freeswitch.org/wiki/FreeSwitch_Dialplan_XML

Next Tutorial I will show how to configure freeswitch in German Language.