GithubHelp home page GithubHelp logo

freeswitch-asr's Introduction

FreeSWITCH ASR 模块

最近很多人都对FreeSWITCH和ASR对接比较感谢兴趣,我之前已经做了一个商业模块(商业模块请点击这里http://www.dingdingtong.cn/smartivr/),考虑到大部分人,只是研究一下,并不准确购买商业模块,特意做一个开源项目给大家提供一个参考。

第一个版本实现 阿里云ASR和FreeSWITCH的直接对接,把识别结果通过ESL输出。

想了开发进度,和本项目的技术交流欢迎加QQ群:340129771

2017-12-10 第一版本代码提交

  • 安装

    • 如果你觉得自己编译太麻烦,可以直接下载我编译好的,放在bin 目录里面。路径请根据自己情况修改。注意只支持x64系统
    • mod_asr.so 复制到到 FreeSWITCH mod 目录。 cp mod_asr.so /usr/local/freeswitch/mod/,如果是fs1.2,请用fs1.2_mod_asr.so的那个。
    • librealTimeUnity.so FreeSWITCH lib 目录,或者系统lib目录。cp librealTimeUnity.so /usr/local/freeswitch/lib/
    • libopus.so FreeSWITCH lib 目录,或者系统lib目录。cp libopus.so.0 /usr/local/freeswitch/lib/
    • config-realtime.txt 复制到 /etc/目录。cp config-realtime.txt /etc/
    • /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml 加入 <load module="mod_asr"/>
    • 重启FreeSWITCH,或者fs_cli 里面执行 reload mod_asr
    • 注意默认只支持单声道8000hz的编码,opus或者g722编码不支持。
  • 编译

  • 使用

    • 申请阿里云的Access Key ID 和 Secret ,请参考 https://help.aliyun.com/document_detail/30437.html?spm=5176.doc35312.6.539.7eNuaN,如果你还没有,可以先使用我已经申请的id(LTAIRLpr2pJFjQbY)和key(oxrJhiBZB5zLX7LKYqETC8PC8ulwh0)测试。

    • fs_cli 执行 originate user/1001 'start_asr:id secret,park' inline,如 bgapi originate user/1001 'start_asr:LTAIRLpr2pJFjQbY oxrJhiBZB5zLX7LKYqETC8PC8ulwh0,park' inline,分机接起来开始说话,就可以看到识别结果输出了。 输出结果的日志等级是 notify console loglevel 5

    • dialplan中使用 测试的时候如果不执行其他APP,park超时会自动挂断,可以加入<action application="set" data="park_timeout=60"/>修改park超时时间。

        <extension name="asr">
        	<condition field="destination_number" expression="^(888)$">
        		<action application="answer"/>
        		<action application="start_asr" data="LTAIRLpr2pJFjQbY oxrJhiBZB5zLX7LKYqETC8PC8ulwh0"/>
        		<action application="park"/>
        	</condition>
        </extension> 
      
  • 开发

    • fs_cli 测试方式 ,执行 /event custom asr 订阅事件。

    • 识别结果会通过esl输出(需要订阅 custom asr 事件)(阿里云返回的原始json数据)例子如下:

        RECV EVENT
        Event-Subclass: asr
        Event-Name: CUSTOM
        Core-UUID: 48a08a69-7858-407a-be69-679150d34193
        FreeSWITCH-Hostname: MiWiFi-R3D-srv
        FreeSWITCH-Switchname: MiWiFi-R3D-srv
        FreeSWITCH-IPv4: 192.168.31.164
        FreeSWITCH-IPv6: ::1
        Event-Date-Local: 2017-12-10 11:30:32
        Event-Date-GMT: Sun, 10 Dec 2017 03:30:32 GMT
        Event-Date-Timestamp: 1512876632835590
        Event-Calling-File: mod_asr.cpp
        Event-Calling-Function: OnResultDataRecved
        Event-Calling-Line-Number: 55
        Event-Sequence: 914
        ASR-Response: {"finish":0,"request_id":"ee87d7fd5e304bdaa9343d9262f34125","result":{"sentence_id":2,"begin_time":4200,"end_time":6525,"status_code":0,"text":"美国拜拜"},"status_code":200,"version":"2.0"}
        Channel: sofia/external/[email protected]
      

      ASR-Response:asr返回结果。 Channel:当前通道。主要使用这2个通道变量。

    • 如果你需要用户说完一整句话,再一次性返回结果。请把config-realtime.txt文件ResponseMode:streaming修改为ResponseMode:normal

    • 如果你觉得自己开发太麻烦了,可以联系QQ:1280791187 或者微信:cdevelop,获取商业服务和支持。

freeswitch-asr's People

Contributors

cdevelop avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.