Speech synthesis through Microsoft Translator for Asterisk

    Now, to translate text to speech on the Asterisk PBX platform with open source, you can use the Microsoft translator.

    image

    The presented script will allow you to use Microsoft Translator to play user text into speech. It includes local caching for voice data, contains many languages ​​in its database, and also supports 8 kHz or 16 kHz rates. This will provide the best sound quality, along with the use of broadband codecs.



    Dependencies:

    perl: The Perl Programming Language
    perl-libwww: The World-Wide Web library for Perl
    sox: Sound eXchange, sound processing program
    API Key (appid) from Microsoft, i.e. Internet access in order to contact MS and receive voice data.

    Installation:

    To install a copy of mstts.agi to the agi-bin directory. 
    / var / lib / asterisk / agi-bin /
    To verify that the file is installed:
    /etc/asterisk/asterisk.conf file

    Usage:

    agi (mstts.agi, text, [language], [intkey])

    This command translator MS TTS Engine, which will translate a text string into speech and play it for the user. 

    If 'intkey' is already installed, the script will ask for user input. The interrupt key on this will immediately stop playing and the set has begun to go to the corresponding extension (for use in IVR) of TTS contact scripts Microsoft. Voice data that is then stored in the local cache (default is default / tmp) for future use. 

    The user can set the language and parameters for using the cache memory and cache directory in the default settings. Dialog

    Asterisk

    :; MsTTS Demo
    exten => 1234.1, Answer ()
    ;; Play mesage in English:
    exten => 1234, n, agi (mstts.agi, “Communication has been waiting.”, En)
    ;; Play message in Spanish:
    exten => 1234, n, agi (mstts.agi, "La comunicación se ha estado esperando.", es)
    ;; Play message in Japanese:
    exten => 1234, n, agi (mstts.agi, "こ れは 、 日本 の 簡 単 な テ ス 日 で す。 良 い 一日 を。 ", ja)
    ;; Play message in simplified Chinese:
    exten => 1234, n, agi (mstts.agi," 通信 が 待 っ て い る ", zh-cn )
    ; A simple dynamic IVR using MsTTS

    [my_ivr]
    exten => s, 1, Answer ()
    exten => s, n,
    exten => s, n, agi (mstts.agi, "Welcome to my small interactive voice response menu.", en)
    ;; Wait for digit:
    exten => s, n (start), agi (mstts.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 (mstts.agi,“ You just pressed $ {EXTEN}. Try another one please. ”, en, any)
    exten => _X, n, WaitExten ()

    exten => i, 1, agi (mstts.agi,“ Invalid extension. ”, en)
    exten => i, n, goto (s, start)

    exten => t, 1, agi (mstts.agi, “Request timed out.”, en)
    exten => t, n, goto (s, start)

    exten => h, 1, Hangup ()


    License:
    MS Translator TTS script for asterisk is distributed under the terms of the GNU General Public License version 2

    You can download the latest stable version here.

    MyAsterisk collected and translated information for you .

    Also popular now: