- Joined
- May 5, 2009
- Messages
- 40
- Reaction score
- 0
Hi everybody !
Googling around i found some script (i modified for may own need) the let you use the google text to speech and speech to text engine. I want just share this with you all because i think is usefull.
I use two agi script:
googletts.agi for text to speech and speech-recog.agi for speech to text
here is the original scripts: googletts and speech-recog
=============================================
Google TTS script for Asterisk
=============================================
This script makes use of Google's translate text to speech service
in order to redner text to speech and play it back to the user.
It supports a variety of different languages.
------------
Requirements
------------
Perl The Perl Programming Language
perl-libwww The World-Wide Web library for Perl
sox Sound eXchange, sound processing program
mpg123 MPEG Audio Player and decoder
format_sln Raw slinear module for asterisk
Internet access in order to contact google and get the voice data.
------------
Installation
------------
To install copy googletts.agi to your agi-bin directory.
Usually this is /var/lib/asterisk/agi-bin/
To make sure check your /etc/asterisk/asterisk.conf file
-----
Usage
-----
agi(googletts.agi,text,[language],[intkey]): This will invoke the Google TTS engine,
render the text string to speech and play it back to the user. If 'intkey' is set
the script will wait for user input. Any given interrupt keys will cause the playback
to immediately terminate and the dialplan to proceed to the matching extension (for use in IVR).
The script contacts google's TTS service in order to get the voice data
which then stores in a local cache (by default /tmp/) for future use.
Parameters like default language, enabling or disabling caching and cache dir
can be set up by editing the script.
--------
Examples
--------
sample dialplan code for your extensions.conf
;GoogleTTS Demo
;PLayback messages to user
exten => 1234,1,Answer()
;;Play mesage in English:
exten => 1234,n,agi(googletts.agi,"This is a simple google text to speech test in english.",en)
;;Play message in Spanish
exten => 1234,n,agi(googletts.agi,"Esta es una simple prueba en espa?±ol.",es)
;;Play message in Greek
exten => 1234,n,agi(googletts.agi,"ŒëœÖœÑœå ŒµŒØŒ?Œ±Œ? Œ?Œ?Œ± Œ±œÄŒªœå œÑŒ?œÉœÑ œÉœÑŒ± ŒµŒªŒªŒ?Œ?Œ?Œ?Œ¨.",el)
;A simple dynamic IVR using GoogleTTS
[my_ivr]
exten => s,1,Answer()
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,agi(googletts.agi,"Welcome to my small interactive voice response menu.",en)
;;Wait for digit:
exten => s,n(start),agi(googletts.agi,"Please dial a digit.",en,any)
exten => s,n,WaitExten()
;;PLayback the name of the digit and wait for another one:
exten => _X,1,agi(googletts.agi,"You just pressed ${EXTEN}. Try another one please.",en,any)
exten => _X,n,WaitExten()
exten => i,1,agi(googletts.agi,"Invalid extension.",en)
exten => i,n,goto(s,start)
exten => t,1,agi(googletts.agi,"Request timed out.",en)
exten => t,n,goto(s,start)
exten => h,1,Hangup()
-------------------
Supported Languages
-------------------
"af" Afrikaans, "sq" Albanian, "am" Amharic, "ar" Arabic, "hy" Armenian, "az" Azerbaijani,
"eu" Basque, "be" Belarusian, "bn" Bengali, "bh" Bihari, "bs" Bosnian, "br" Breton, "bg" Bulgarian,
"km" Cambodian, "ca" Catalan, "zh-CN" Chinese (Simplified), "zh-TW" Chinese (Traditional),
"co" Corsican, "hr" Croatian, "cs" Czech, "da" Danish, "nl" Dutch, "en" English, "eo" Esperanto,
"et" Estonian, "fo" Faroese, "tl" Filipino, "fi" Finnish, "fr" French, "fy" Frisian, "gl" Galician,
"ka" Georgian, "de" German, "el" Greek, "gn" Guarani, "gu" Gujarati, "xx-hacker" Hacker, "ha" Hausa,
"iw" Hebrew, "hi" Hindi, "hu" Hungarian, "is" Icelandic, "id" Indonesian, "ia" Interlingua, "ga" Irish,
"it" Italian, "ja" Japanese, "jw" Javanese, "kn" Kannada, "kk" Kazakh, "rw" Kinyarwanda,
"rn" Kirundi, "xx-klingon" Klingon, "ko" Korean, "ku" Kurdish, "ky" Kyrgyz, "lo" Laothian,
"la" Latin, "lv" Latvian, "ln" Lingala, "lt" Lithuanian, "mk" Macedonian, "mg" Malagasy,
"ms" Malay, "ml" Malayalam, "mt" Maltese, "mi" Maori, "mr" Marathi, "mo" Moldavian, "mn" Mongolian,
"sr-ME" Montenegrin, "ne" Nepali, "no" Norwegian, "nn" Norwegian (Nynorsk), "oc" Occitan, "or" Oriya,
"om" Oromo, "ps" Pashto, "fa" Persian, "xx-pirate" Pirate, "pl" Polish, "pt-BR" Portuguese (Brazil),
"pt-PT" Portuguese (Portugal), "pa" Punjabi, "qu" Quechua, "ro" Romanian, "rm" Romansh, "ru" Russian,
"gd" Scots Gaelic, "sr" Serbian, "sh" Serbo-Croatian, "st" Sesotho, "sn" Shona, "sd" Sindhi,
"si" Sinhalese, "sk" Slovak, "sl" Slovenian, "so" Somali, "es" Spanish, "su" Sundanese, "sw" Swahili,
"sv" Swedish, "tg" Tajik, "ta" Tamil, "tt" Tatar, "te" Telugu, "th" Thai, "ti" Tigrinya, "to" Tonga,
"tr" Turkish, "tk" Turkmen, "tw" Twi, "ug" Uighur, "uk" Ukrainian, "ur" Urdu, "uz" Uzbek,
"vi" Vietnamese, "cy" Welsh, "xh" Xhosa, "yi" Yiddish, "yo" Yoruba, "zu" Zulu.
-------
License
-------
The GoogleTTS script for asterisk is distributed under the GNU General Public
License v2. See COPYING for details.
==============================================
Speech recognition script for Asterisk
==============================================
This script makes use of Google's speech recognition engine
in order to render speech to text and return it back to the dialplan
as an asterisk channel variable.
------------
Requirements
------------
Perl The Perl Programming Language
perl-libwww The World-Wide Web library for Perl
flac Free Lossless Audio Codec
Internet access in order to contact google and get the speech data.
The script can optionally use sox for sound conversion. It works with recent
versions of sox (It will not work in RHEL/Centos 5).
------------
Installation
------------
To install copy speech-recog.agi to your agi-bin directory.
Usually this is /var/lib/asterisk/agi-bin/
To make sure check your /etc/asterisk/asterisk.conf file
-----
Usage
-----
agi(speech-recog.agi,[lang],[timeout])
Records from the current channel untill the pound key (#) is pressed or the
timeout (set to 10 seconds by default, -1 for no timeout) is reached.
The recording is send over to googles speech recognition service and the
returned text string is assigned as the value of the channel variable 'utterance'.
The scripts sets the following channel variables:
status : Return status. 0 means success, non zero values indicating different errors.
id : Some id string that googles engine returns, not very useful(?).
utterance : The generated text string.
confidence : A value between 0 and 1 indicating the probability of a correct recognition.
Values bigger than 0.95 usually mean that the resulted text is correct.
--------
Examples
--------
sample dialplan code for your extensions.conf
;Simple speech recognition
exten => 1234,1,Answer()
exten => 1234,n,agi(speech-recog.agi,en-US)
exten => 1234,n,Noop(== The text you just said is: ${utterance} ==)
exten => 1234,n,Noop(== The probability to be right is: ${confidence} ==)
exten => 1234,n,Hangup()
;Speech recognition demo also using googletts.agi for text to speech synthesis:
exten => 1235,1,Answer()
exten => 1235,n,agi(googletts.agi,"Say something in English, when done press the pound key.",en)
exten => 1235,n(record),agi(speech-recog.agi,en-US)
exten => 1235,n,Noop(= Script returned: ${status} , ${id} , ${confidence} , ${utterance} =)
exten => 1235,n,GotoIf($["${status}" = "0"]?success:fail)
exten => 1235,n(success),GotoIf($["${confidence}" > "0.8"]?playback:retry)
exten => 1235,n(playback),agi(googletts.agi,"The text you just said was...",en)
exten => 1235,n,agi(googletts.agi,"${utterance}",en)
exten => 1235,n,goto(end)
exten => 1235,n(retry),agi(googletts.agi,"Can you please repeat more clearly?",en)
exten => 1235,n,goto(record)
exten => 1235,n(fail),agi(googletts.agi,"Failed to get speech data.",en)
exten => 1235,n(end),Hangup()
;Voice dialing example
exten => 1236,1,Answer()
exten => 1236,n,agi(googletts.agi,"PLease say the number you want to dial.",en)
exten => 1236,n(record),agi(speech-recog.agi,en-US)
exten => 1236,n,GotoIf($[$["${status}" = "0"] & $["${confidence}" > "0.8"]]?success:retry)
exten => 1236,n(success),goto(${utterance})
exten => 1236,n(retry),agi(googletts.agi,"Can you please repeat?",en)
exten => 1236,n,goto(record)
-------------------
Supported Languages
-------------------
English
Afrikaans
Arabic
Chinese
Czech
Dutch
French
German
Hebrew
Italian
Indonesian
Japanese
Korean
Latin
Malaysian
Polish
Portuguese
Russian
Spanish
Turkish
Yue Chinese (Traditional Hong Kong)
Zulu
-----------------------
Security Considerations
-----------------------
This script contacts google's servers in order send the recorded voice data and get back
the resulted text. If you are using voice recognition for sensitive data or you want to
make sure that no 3rd party can eavesdrop your communication with the google service it is
advised to enable the use of SSL in the script. This will encrypt all the traffic between
your pbx and google servers making it much safer.
To enable the use of SSL set the variable '$use_ssl' to 1 in the script. Keep in mind that
security comes with a price, the initialisation of the SSL session adds a small delay in
communication (usually under 1 sec).
-------
License
-------
The speech-recog script for asterisk is distributed under the GNU General Public
License v2. See COPYING for details.
I hope this could be useful for you
Googling around i found some script (i modified for may own need) the let you use the google text to speech and speech to text engine. I want just share this with you all because i think is usefull.
I use two agi script:
googletts.agi for text to speech and speech-recog.agi for speech to text
here is the original scripts: googletts and speech-recog
=============================================
Google TTS script for Asterisk
=============================================
This script makes use of Google's translate text to speech service
in order to redner text to speech and play it back to the user.
It supports a variety of different languages.
------------
Requirements
------------
Perl The Perl Programming Language
perl-libwww The World-Wide Web library for Perl
sox Sound eXchange, sound processing program
mpg123 MPEG Audio Player and decoder
format_sln Raw slinear module for asterisk
Internet access in order to contact google and get the voice data.
------------
Installation
------------
To install copy googletts.agi to your agi-bin directory.
Usually this is /var/lib/asterisk/agi-bin/
To make sure check your /etc/asterisk/asterisk.conf file
-----
Usage
-----
agi(googletts.agi,text,[language],[intkey]): This will invoke the Google TTS engine,
render the text string to speech and play it back to the user. If 'intkey' is set
the script will wait for user input. Any given interrupt keys will cause the playback
to immediately terminate and the dialplan to proceed to the matching extension (for use in IVR).
The script contacts google's TTS service in order to get the voice data
which then stores in a local cache (by default /tmp/) for future use.
Parameters like default language, enabling or disabling caching and cache dir
can be set up by editing the script.
--------
Examples
--------
sample dialplan code for your extensions.conf
;GoogleTTS Demo
;PLayback messages to user
exten => 1234,1,Answer()
;;Play mesage in English:
exten => 1234,n,agi(googletts.agi,"This is a simple google text to speech test in english.",en)
;;Play message in Spanish
exten => 1234,n,agi(googletts.agi,"Esta es una simple prueba en espa?±ol.",es)
;;Play message in Greek
exten => 1234,n,agi(googletts.agi,"ŒëœÖœÑœå ŒµŒØŒ?Œ±Œ? Œ?Œ?Œ± Œ±œÄŒªœå œÑŒ?œÉœÑ œÉœÑŒ± ŒµŒªŒªŒ?Œ?Œ?Œ?Œ¨.",el)
;A simple dynamic IVR using GoogleTTS
[my_ivr]
exten => s,1,Answer()
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,agi(googletts.agi,"Welcome to my small interactive voice response menu.",en)
;;Wait for digit:
exten => s,n(start),agi(googletts.agi,"Please dial a digit.",en,any)
exten => s,n,WaitExten()
;;PLayback the name of the digit and wait for another one:
exten => _X,1,agi(googletts.agi,"You just pressed ${EXTEN}. Try another one please.",en,any)
exten => _X,n,WaitExten()
exten => i,1,agi(googletts.agi,"Invalid extension.",en)
exten => i,n,goto(s,start)
exten => t,1,agi(googletts.agi,"Request timed out.",en)
exten => t,n,goto(s,start)
exten => h,1,Hangup()
-------------------
Supported Languages
-------------------
"af" Afrikaans, "sq" Albanian, "am" Amharic, "ar" Arabic, "hy" Armenian, "az" Azerbaijani,
"eu" Basque, "be" Belarusian, "bn" Bengali, "bh" Bihari, "bs" Bosnian, "br" Breton, "bg" Bulgarian,
"km" Cambodian, "ca" Catalan, "zh-CN" Chinese (Simplified), "zh-TW" Chinese (Traditional),
"co" Corsican, "hr" Croatian, "cs" Czech, "da" Danish, "nl" Dutch, "en" English, "eo" Esperanto,
"et" Estonian, "fo" Faroese, "tl" Filipino, "fi" Finnish, "fr" French, "fy" Frisian, "gl" Galician,
"ka" Georgian, "de" German, "el" Greek, "gn" Guarani, "gu" Gujarati, "xx-hacker" Hacker, "ha" Hausa,
"iw" Hebrew, "hi" Hindi, "hu" Hungarian, "is" Icelandic, "id" Indonesian, "ia" Interlingua, "ga" Irish,
"it" Italian, "ja" Japanese, "jw" Javanese, "kn" Kannada, "kk" Kazakh, "rw" Kinyarwanda,
"rn" Kirundi, "xx-klingon" Klingon, "ko" Korean, "ku" Kurdish, "ky" Kyrgyz, "lo" Laothian,
"la" Latin, "lv" Latvian, "ln" Lingala, "lt" Lithuanian, "mk" Macedonian, "mg" Malagasy,
"ms" Malay, "ml" Malayalam, "mt" Maltese, "mi" Maori, "mr" Marathi, "mo" Moldavian, "mn" Mongolian,
"sr-ME" Montenegrin, "ne" Nepali, "no" Norwegian, "nn" Norwegian (Nynorsk), "oc" Occitan, "or" Oriya,
"om" Oromo, "ps" Pashto, "fa" Persian, "xx-pirate" Pirate, "pl" Polish, "pt-BR" Portuguese (Brazil),
"pt-PT" Portuguese (Portugal), "pa" Punjabi, "qu" Quechua, "ro" Romanian, "rm" Romansh, "ru" Russian,
"gd" Scots Gaelic, "sr" Serbian, "sh" Serbo-Croatian, "st" Sesotho, "sn" Shona, "sd" Sindhi,
"si" Sinhalese, "sk" Slovak, "sl" Slovenian, "so" Somali, "es" Spanish, "su" Sundanese, "sw" Swahili,
"sv" Swedish, "tg" Tajik, "ta" Tamil, "tt" Tatar, "te" Telugu, "th" Thai, "ti" Tigrinya, "to" Tonga,
"tr" Turkish, "tk" Turkmen, "tw" Twi, "ug" Uighur, "uk" Ukrainian, "ur" Urdu, "uz" Uzbek,
"vi" Vietnamese, "cy" Welsh, "xh" Xhosa, "yi" Yiddish, "yo" Yoruba, "zu" Zulu.
-------
License
-------
The GoogleTTS script for asterisk is distributed under the GNU General Public
License v2. See COPYING for details.
==============================================
Speech recognition script for Asterisk
==============================================
This script makes use of Google's speech recognition engine
in order to render speech to text and return it back to the dialplan
as an asterisk channel variable.
------------
Requirements
------------
Perl The Perl Programming Language
perl-libwww The World-Wide Web library for Perl
flac Free Lossless Audio Codec
Internet access in order to contact google and get the speech data.
The script can optionally use sox for sound conversion. It works with recent
versions of sox (It will not work in RHEL/Centos 5).
------------
Installation
------------
To install copy speech-recog.agi to your agi-bin directory.
Usually this is /var/lib/asterisk/agi-bin/
To make sure check your /etc/asterisk/asterisk.conf file
-----
Usage
-----
agi(speech-recog.agi,[lang],[timeout])
Records from the current channel untill the pound key (#) is pressed or the
timeout (set to 10 seconds by default, -1 for no timeout) is reached.
The recording is send over to googles speech recognition service and the
returned text string is assigned as the value of the channel variable 'utterance'.
The scripts sets the following channel variables:
status : Return status. 0 means success, non zero values indicating different errors.
id : Some id string that googles engine returns, not very useful(?).
utterance : The generated text string.
confidence : A value between 0 and 1 indicating the probability of a correct recognition.
Values bigger than 0.95 usually mean that the resulted text is correct.
--------
Examples
--------
sample dialplan code for your extensions.conf
;Simple speech recognition
exten => 1234,1,Answer()
exten => 1234,n,agi(speech-recog.agi,en-US)
exten => 1234,n,Noop(== The text you just said is: ${utterance} ==)
exten => 1234,n,Noop(== The probability to be right is: ${confidence} ==)
exten => 1234,n,Hangup()
;Speech recognition demo also using googletts.agi for text to speech synthesis:
exten => 1235,1,Answer()
exten => 1235,n,agi(googletts.agi,"Say something in English, when done press the pound key.",en)
exten => 1235,n(record),agi(speech-recog.agi,en-US)
exten => 1235,n,Noop(= Script returned: ${status} , ${id} , ${confidence} , ${utterance} =)
exten => 1235,n,GotoIf($["${status}" = "0"]?success:fail)
exten => 1235,n(success),GotoIf($["${confidence}" > "0.8"]?playback:retry)
exten => 1235,n(playback),agi(googletts.agi,"The text you just said was...",en)
exten => 1235,n,agi(googletts.agi,"${utterance}",en)
exten => 1235,n,goto(end)
exten => 1235,n(retry),agi(googletts.agi,"Can you please repeat more clearly?",en)
exten => 1235,n,goto(record)
exten => 1235,n(fail),agi(googletts.agi,"Failed to get speech data.",en)
exten => 1235,n(end),Hangup()
;Voice dialing example
exten => 1236,1,Answer()
exten => 1236,n,agi(googletts.agi,"PLease say the number you want to dial.",en)
exten => 1236,n(record),agi(speech-recog.agi,en-US)
exten => 1236,n,GotoIf($[$["${status}" = "0"] & $["${confidence}" > "0.8"]]?success:retry)
exten => 1236,n(success),goto(${utterance})
exten => 1236,n(retry),agi(googletts.agi,"Can you please repeat?",en)
exten => 1236,n,goto(record)
-------------------
Supported Languages
-------------------
English
Afrikaans
Arabic
Chinese
Czech
Dutch
French
German
Hebrew
Italian
Indonesian
Japanese
Korean
Latin
Malaysian
Polish
Portuguese
Russian
Spanish
Turkish
Yue Chinese (Traditional Hong Kong)
Zulu
-----------------------
Security Considerations
-----------------------
This script contacts google's servers in order send the recorded voice data and get back
the resulted text. If you are using voice recognition for sensitive data or you want to
make sure that no 3rd party can eavesdrop your communication with the google service it is
advised to enable the use of SSL in the script. This will encrypt all the traffic between
your pbx and google servers making it much safer.
To enable the use of SSL set the variable '$use_ssl' to 1 in the script. Keep in mind that
security comes with a price, the initialisation of the SSL session adds a small delay in
communication (usually under 1 sec).
-------
License
-------
The speech-recog script for asterisk is distributed under the GNU General Public
License v2. See COPYING for details.
I hope this could be useful for you