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.
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.