Can not get @billsimon Transcribe with Azure working

I have just installed and got limping @billsimon script (https://github.com/simontelephonics/transcribe-with-azure). I can verify the script is limping. I have added some diagnostic code to get a status back. So I can see the main body of the code is being executed, but I am not getting back anything for the transcription.

Not exactly sure why it is not transcribing. When I get a voice mail, the eMail has the following line:
Transcription Voice Mail Found
I am not sure where to start looking for the issue.

Greg

#!/usr/bin/php
<?php

// (c) 2022 Bill Simon. Permissions given according to MIT license.
// File stored in FreePBX Server  /usr/local/bin  Folder

$msSpeechUrl = 'https://canadacentral.api.cognitive.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US';
$apiKey = 'AtY7 --- The very long API Key --- SIY';

$maildata = file_get_contents("php://stdin");
$msg = preg_split("/\r\n|\n|\r/", $maildata);
$att = '';
$vmexist = 'No Voice Mail';
for($i = 0; $i < count($msg); $i++) {
        if (preg_match('/Content-Disposition: attachment/', $msg[$i])) {
                $i++; // skip to next line
                while (! preg_match('/----/', $msg[$i])) {
                        $att .= $msg[$i] . "\n";
                        $i++;
                }
        }
}

if ($att) {
        $opts = array('http' =>
                array(
                        'method' => 'POST',
                        'header' => array(
                                "Ocp-Apim-Subscription-Key: $apiKey",
                                'Content-Type: audio/wav'
                                ),
                        'content' => base64_decode($att)
                )
        );
        $context = stream_context_create($opts);
        $result = json_decode(file_get_contents($msSpeechUrl, false, $context));
		$vmexist = 'Voice Mail Found';
}

if (! empty($result->{"DisplayText"})) {
        $maildata = str_replace('(TRANSCRIPTION)', $result->{"DisplayText"}, $maildata);
} else {
        $maildata = str_replace('(TRANSCRIPTION)', $vmexist, $maildata);
}

$mailproc = popen('/usr/sbin/sendmail -t', 'w');
fwrite($mailproc, $maildata);
pclose($mailproc);

exit;
?>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.