3

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 Answers1

1

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.

pce
  • 5,571
  • 2
  • 20
  • 25
  • Thank a lot. made some progress but the variable is not going to the array is something missing. – user1733491 Oct 11 '12 at 23:38
  • Thank a lot. made some progress but the variable is not going to the array is something missing. here is the log. [link](https://docs.google.com/document/pub?id=1KmHPi41pGdhSoHLmAmJwNQNsPWsUucBZMpZD04_ILgc) – user1733491 Oct 11 '12 at 23:55
  • How do you set the Variable? I see $num in the Log, Not the expected value of $num. – pce Oct 12 '12 at 09:58
  • I set exactly as you give me it here. had to add ";" to the end of number array line. The agi debug log seems to be showing the variable being passed into the script but the string replace function don't seem to run also have to remove spaces but I think I can figure that out. $num should be the actual variable but that is what is happening. – user1733491 Oct 12 '12 at 23:16
  • Update The string replace is not happening I will keep trying. Asterisk 10 has this function built in now STRREPLACE a an added feature of function string trying to get that working too. – user1733491 Oct 14 '12 at 20:10