. WIKIMERIONET
Merion Mertics , ,

-
-
CRM

. , , . , ASR (Automatic speech recognition).

, IP Asterisk. () Yandex SpeechKit. ?

! SpeechKit .

?

: Asterisk . , : ! . , , , , . . , extension.

:

  Asterisk  Yandex SpeechKit

API -

, , . https://developer.tech.yandex.ru/ :

  Yandex SpeechKit

. SpeechKit Cloud:

   API Yandex

. .

    ASR

Asterisk . PHP , AGI . ( ):

#!/usr/bin/php -q 
<?php
require('phpagi.php'); 
$agi = new AGI(); # AGI ;
$audio = $argv[1]; #    AGI.    - ,     ;
$token = '_';
$theme = "queries"; # . queries -      ;
$lang = "ru-RU"; # ;
$uuid = md5(uniqid(rand(), true)); #    32 ;
system('sox '.$audio.'.wav -r 16000 -b 16 -c 1 '.$audio.'-conv.wav'); #    ;
$cmd = exec('curl --silent -F "Content-Type=audio/x-pcm;bit=16;rate=16000;" -F "audio=@'.$audio.'-conv.wav" asr.yandex.net/asr_xml\?key='.$token.'\&uuid='.$uuid .'\&topic='.$theme.'\&lang='.$lang, $result); # CURL   API   ;
$result_asr = implode($result); #   ;
if (preg_match('!!si', $result_asr, $arr)) {
$asr_res = $arr[1];
} else {
$asr_res='';
} #     ;
if (intval(substr_count($asr_res, '')) > 0) {
$ress = 1; #     "",     1;
} elseif (intval(substr_count($asr_res, '')) > 0) {
$ress = 2; #     "",     2;
} elseif (intval(substr_count($asr_res, '')) > 0) {
$ress = 3; #     "",     3;
} else {
$ress = 0; #   ,  0;
}
$agi->set_variable("asr", $ress); #      ;
system('rm -f '.$audio.'.wav');
system('rm -f '.$audio.'-conv.wav'); #  ,     ;
?>

, (, ). , .

. , :

ASR
, .php

asr.php /var/lib/asterisk/agi-bin :

dos2unix /var/lib/asterisk/agi-bin/asr.php 
chown asterisk:asterisk /var/lib/asterisk/agi-bin/asr.php 
chmod 775 /var/lib/asterisk/agi-bin/asr.php

. /etc/asterisk/extensions_custom.conf :

[asr_menu]
exten => s,1,Answer()
exten => s,n,Playback(custom/asr)
exten => s,n,Wait(1)
exten => s,n,Record(/tmp/${UNIQUEID}.wav,3,20)
exten => s,n,AGI(asr.php,/tmp/${UNIQUEID})
exten => s,n,Set(varasr=${asr})
exten => s,n,GotoIf($["${varasr}" = "1"]?dial111:zakazcheck)
same => n(dial111),Dial(SIP/111,15,rt)
same => n,Hangup()
exten => s,n(zakazcheck),GotoIf($["${varasr}" = "2"]?dial222:sekratarcheck)
same => n(dial222),Dial(SIP/222,15,rt)
same => n,Hangup()
exten => s,n(sekratarcheck),GotoIf($["${varasr}" = "3"]?dial333)
same => n(dial333),Dial(SIP/333,15,rt)
same => n,Hangup()

( , /var/lib/asterisk/sounds/ru/custom/asr.wav), , , , , . , , 111, , 222, , 333. .

. FreePBX. Custom Destinations. AdminCustom Destinations Add Destination:

Custom Destinations     FreePBX

, . Submit Apply Config. IVR ( ). 1 :

Yandex ASR  FreePBX

. () open source .


?