Fast voice dialing on Asterisk

    There are already several articles on the use of speech recognition services in asterisk from Google and Yandex on Habré. But you always want to do something your own and somehow in your own way.

    So, I wanted to make a quick voice call to subscribers from the address book. When you work with several dozens of people in an organization, sometimes you sometimes forget and confuse internal numbers of subscribers (and there aren’t enough speed dial buttons for everyone). Therefore, you just need to press the button, said "Zina from the third mobile" and Zina from the third answers you on your mobile.

    Short video with a demonstration of work:



    Wrote a small AGI server on node.js. Many implement the logic of AGI in the dialplan as running scripts from the agi-bin folder, but you can run the server application on some network port and process requests from asterisk.

    In the asterisk dialplan, we need almost one line that redirects the control of the call flow from the dialplan to our voicer application.

    //extensions.conf
    [default]
    exten => 1000,1,AGI(agi://192.168.2.1:3000/)
    

    It should be clearly understood that if the logic of forming a dialplan is transferred from asterisk to AGI, but all work still happens on asterisk.

    Further. Calling the number 1000 (1) we hear a greeting (3), then we say the name, asterisk writes the file (4), the AGI service sends it to Yandex or Google for recognition (5), receives the recognition option, looks for it in its list ( 6), in the case of finding a successful option, makes a call to the specified number (7).

    Voicer working scheme:



    How to run voicer?


    A. Install the application
    • Copy the repository and install the dependencies

    B. Configuring the recognition service

    B. Configure the name search (more on that later)
    D. Configure the dialplan as described above
    D. Run the application, make a test call.

    (Detailed step-by-step installation with commands is given in readme )

    How does word search work?


    The application applies a test json file, filling in which the correspondence of the name and the channel, you can get a finished file for finding matches. A channel in this case is a channel in the understanding of asterisk. For example, SIP / 123 or Local / 8913XXXXXX @ outbound. Those. if opposite Masha there will be SIP / 123, then asterisk will connect you to the SIP / 123 channel, and opposite Masha Mobile will be SIP / 8913XXXXYYYY @ gate, then the call will go to the number through the gate context. Of course, outgoing communication must be configured on asterisk in advance.

    Example file:
    [{
    "name": "Василий",
    "channel": "SIP/Sf12345678"
    },
    {
    "name": "Василий Мобильный",
    "channel": "Local/8913XXXXXXX@outbound"
    }]
    

    The application includes search scripts for mongodb and mysql, you can modify it for your address book.

    Additionally


    Also in the settings you must specify the directory where the recorded files should be stored, and the directory where to take the files in order to send them to the recognition service.

    It would seem that this is one directory, but this is so until you run voicer on the same machine as asterisk works for you. If your asterisk and voicer work on different machines (my case), then the directory for recording is the directory on the machine with asterisk (the AGI server tells asterisk where to write the file with what the subscriber said), and the directory with the files for recognition is the same directory with recorded files mounted on a machine with a working voicer.

    -

    Application repository on github I hope someone will come in handy such an option for implementing voice speed dialing on asterisk.

    Links to npm used in the application: ding-dong (my fork node-agi ) - an AGI server with wrappers for AGI commands, yandex-speech , google-speech - wrappers for Yandex and Google voice services.

    Having the opportunity to compare speech recognition services, I can note a clearer recognition of surnames and names by Google. Yandex, for example, poorly distinguished between Pakhomov (defined as “Bad”), Vital (“Details”), etc.

    Also popular now: