douqinlu4217 2012-10-10 03:57
浏览 102

在Asterisk拨号方案中将单词转换为数字

I Spent the last 3 weeks trying to get this to work. I want to do voice dialing from asterisk using googletts.agi script available on github. It works but the problem is googletts sometimes return a word instead of a digit in the "utterance" variable like 18004633339 may come back as "180046 tree tree tree nite" or "1800 force 6 tree tree 339" etc.

https://github.com/zaf/asterisk-googletts https://github.com/zaf/asterisk-speech-recog

The link below has a script That converts words to numbers

http://www.karlrixon.co.uk/writing/convert-numbers-to-words-with-php

This is my dialplan

exten => 2255,1,Answer()
exten => 2255,n,Wait(1)
;exten => 2255,n,flite("Say the number you wish to call. Then press the pound key.")
exten => 2255,n,Espeak("Say the number you wish to call. Then press the pound key.")
exten => 2255,n(record),agi(speech-recog.agi,en-US)
exten => 2255,n,Noop(= Script returned: ${status} , ${id} , ${confidence},            ${utterance} =)
exten => 2256,6,Set(NUM2CALL=${utterance})

NEED CODE FOR HERE that would take ${utterance} or NUM2CALL variable and fix it if there are words in it to a proper number which asterisk can dial

exten => 2255,n,SayDigits("${NUM2CALL2}")
exten => 2255,n,Background(vm-star-cancel)
exten => 2255,n,Background(vm-tocallnum)
exten => 2255,n,Read(PROCEED,beep,1)                                        
exten => 2255,n,GotoIf($["foo${PROCEED}" = "foo1"]?15:16)
exten => 2255,15,Goto(outbound-allroutes,${NUM2CALL2},1)
exten => 2255,16,hangup

I am thinking if I can add to the dictionary array I will eventually have a very accurate voice dialer. I spent 4 days testing tropo ASR it is very accurate for single digits but with multiple digit accuracy falls away fast. Thanks in advance for any assistance. I will post the completed script as a project on github. I tried with pocketphinx also with the TIDIGITS grammar and model but that was even worse than the pocketsphinx default dictionary which was giving a similar problem.

  • 写回答

1条回答 默认 最新

  • dongtang5776 2012-10-11 08:10
    关注

    With AGI, PHP-AGI you can call a function, ie. convert_word_to_number and set a Variable, which you can use in the Dialpan after executing the AGI Script.

    In the Dialplan

    exten => 2256,6,Set(NUM2CALL=${utterance})
    exten => 2256,n,AGI(/home/asterisk/agi-bin/words_agi.php);
    

    And the AGI Script:

    #!/usr/bin/php -q
    <?php
    set_time_limit(30);
    require_once 'phpagi.php';
    
    // replace this function with yours
    function convert_word_to_number($word) {
       $words = array(
         'tree',
         'too',
          // ...
        );
        $numbers = array(3,2)
       // replace words with numbers - example only
       $num = str_replace($words, $numbers, $word);
       return $num;
    }
    
    $agi = new AGI();
    $word = $agi->get_variable("NUM2CALL"); 
    $spokenNumber = convert_word_to_number($word);
    $agi->set_variable("NUM2CALL", $spokenNumber);
    

    You only have to implement a more accurat version of convert_word_to_number to replace words with numbers, replace it with your function.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法