2012-10-10 33 views
3

我花了最近3周的時間試圖使其發揮作用。我想使用github上的googletts.agi腳本從星號進行語音撥號。它的工作原理,但問題是googletts有時會返回一個單詞而不是數字在像「話語」變量18004633339可能會回來作爲「180046樹樹樹奈特」或「1800力6棵樹樹339」等將單詞轉換爲Asterisk dialplan中的數字

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

下面的鏈接有一個腳本,轉換字號碼

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

這是我的撥號方案

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}) 

需要編寫代碼在這裏,將採取$ {話語}或NUM2CALL變量,並修復它是否有它的話,以適當的數量,其星號可以撥打

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 

我想如果我可以添加到字典數組中,我最終將擁有一個非常準確的語音撥號程序。我花了4天時間測試tropo ASR,它對於單個數字非常準確,但具有多位數字的準確性快速下降。預先感謝您的幫助。我將在github上發佈完成的腳本作爲項目。我還用pocketphinx與TIDIGITS語法和模型一起嘗試過,但這比提供類似問題的pocketsphinx默認字典更糟糕。

回答

1

With AGIPHP-AGI你可以調用一個函數,即。 convert_word_to_numberset a Variable, ,您可以在執行AGI腳本後在Dialpan中使用它。

在撥號方案

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

而且AGI腳本:

#!/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); 

你只需要實施更加accurat的convert_word_to_number版本號來代替的話,你的函數替換它。

+0

非常感謝。取得了一些進展,但變量不會去數組是缺少的東西。 – user1733491

+0

非常感謝。取得了一些進展,但變量不會去數組是缺少的東西。這裏是日誌。 [鏈接](https://docs.google.com/document/pub?id=1KmHPi41pGdhSoHLmAmJwNQNsPWsUucBZMpZD04_ILgc) – user1733491

+0

如何設置變量?我在日誌中看到$ num,而不是$ num的期望值。 – pce