S
S
SteepNET2021-04-02 18:37:49
PHP
SteepNET, 2021-04-02 18:37:49

Is Asterisk converting sox to ogg real?

Good afternoon!
The plan is that you need to convert wav to ogg through AGI, I do this

[asr_menu]
exten => s,1,Answer()
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})


I see in the console when calling
-- Executing [3@ivr-9:2] Goto("SIP/88005550555-00010a97", "asr_menu,s,1") in new stack
    -- Goto (asr_menu,s,1)
    -- Executing [[email protected]_menu:1] Answer("SIP/88005550555-00010a97", "") in new stack
    -- Executing [[email protected]_menu:2] Wait("SIP/88005550555-00010a97", "1") in new stack
    -- Executing [[email protected]_menu:3] Record("SIP/88005550555-00010a97", "/tmp/1617377185.1436643.wav,3,20") in new stack
    -- <SIP/88007550775-00010a97> Playing 'beep.ulaw' (language 'ru')
    -- PJSIP/805-00046690 answered
Executing [[email protected]_menu:4] AGI("SIP/88005550555-00010a97", "asr.php,/tmp/1617377185.1436643") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/asr.php
    -- <SIP/88005550555-00010a97>AGI Script asr.php completed, returning 0


That is, here the file in /tmp/1617377185.1436643.wav is created normally, and, as planned, it should be converted to
/var/lib/asterisk/agi-bin/asr.php in this way

#!/usr/bin/php -q 
<?php
require('phpagi.php'); 
$agi = new AGI(); 
$audio = $argv[1];
shell_exec('sox '.$audio.'.wav '.$audio.'-conv.ogg -G rate 8000');


But it was not there, the file
1617377185.1436643-conv.ogg does not appear! which means that the conversion does not work, I lost my head why it does not work ???

Hands in the console sox '.$audio.'.wav '.$audio.'-conv.ogg -G rate 8000 works, everything converts,
I made a php script separately, it also converts normally, what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
R
Rsa97, 2021-04-02
@Rsa97

Why do you need AGI? Use System

same => n,System(sox /tmp/${UNIQUEID}.wav /tmp/${UNIQUEID}-conv.ogg -G rate 8000)

I would also register the full path to sox for a guarantee.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question