Пустая переменная при запуске из AGI (но не пустая из bash)

Пожалуйста, помогите мне, почему класс Sphinx дает мне пустой $ result, когда я запускаю его из AGI, но дает мне не пустой $ result, когда я запускаю его из bash. Также класс Яндекс дает не пустой корректный $ результат в обеих ситуациях.
Начальный voice_rec.php

#!/usr/bin/php5
<?php

$start = microtime(true);

spl_autoload_register(function ($class) {
include 'Classes/' . $class . '.php';
});

$stdin = fopen('php://stdin', 'r');
$stdout = fopen('php://stdout', 'w');
$stdlog = fopen('my_agi.log', 'w');$filename = $argv[1];
$table = $argv[2];
$number = $argv[3];$VoiceClass = new Sphinx();
$result = $VoiceClass->voice2Text($filename);

echo "VERBOSE $result\n";

return $result;
?>

Sphinx.php

<?php

/**
*
*/
class Sphinx
{
public $dict, $grammar;
function __construct($dict = "/home/asterisk/baltartek/cmusphinx/dict.dic", $grammar = "/home/asterisk/baltartek/cmusphinx/grammar.jsgf")
{
$this->dict = $dict;
$this->grammar = $grammar;
}

public function voice2Text($filename)
{
$command = "pocketsphinx_continuous -samprate 8000 -logfn /dev/null -hmm /root/zero_ru_cont_8k_v3/zero_ru.cd_cont_4000 ".
"-dict ".$this->dict." -jsgf ".$this->grammar." -infile $filename";

exec($command, $ans);$result = implode("",$ans);

return $result;

}

}
?>

Яндекс.php (который хорошо работает как в AGI, так и в Bash)

<?php

/**
*
*/
class Yandex
{
public $key = '****';
public $topic = "freeform";
public $lang = "ru-RU";
public $uuid;

function __construct()
{
$this->uuid = md5(time());
}

public function voice2Text($filename)
{
$cmd = exec('curl --silent -F "Content-Type=audio/x-wav" -F "audio=@'.$filename.'" asr.yandex.net/asr_xml\?key='.$this->key.'\&uuid='.$this->uuid .'\&topic='.$this->topic.'\&lang='.$this->lang, $xml);$res_xml = implode($xml);
if (preg_match('!<variant .*?>(.*)</variant>!si', $res_xml, $arr)) $voice_text = $arr[1];
else $voice_text='';$result = strtolower($res_xml);return $result;
}

}
?>

0

Решение

Проблема была в разрешении папки с акустическими файлами. Просто переместил его в / home / звездочку и запустил

chown -R asterisk:asterisk /home/asterisk
0

Другие решения

Других решений пока нет …