Externalmedia ari to speechto text not working

Hello,
I am using asterisk ari externalmedia to send rtp to the remote server and in remote server I listen for udp port and capture udp and streaming it to google speechtotext api. But i am getting null response from speechtotext api. I tried with audiofork and its working fine, but the audio fork cannot play back to asterisk. In that case kindly help me on sorting external medi. I have done as follows using externalmedia ari and nodejs
step1: Softphone(channel A) dials from asterisk dialplan, answered it and forwarded to stasis app
step2: created an externalmedia channel for udp to remote server 10.13.1.202:41234
step3: Added channelA and externamlmedia channel to a newly created bridge

So the bridge is having channel A and external media channel. As per the documentation conversation from channelA should be forwarded to external media channel in the same bridge to remote server 10.13.1.202:41234
I can see in asterisk logs rtp is flowing to 10.13.1.202

in remote server i caputed using nodejs udp:dgram
server.on(‘message’, async (message, rinfo) => {

    outstream.write(message);
    await wait();
    recv += message.length;
    buffers.push(message);
    if (recv >= bytesThreshold) {
        // tell next messages to wait
        waiting = true;
        var sending = Buffer.concat(buffers);
        recv = 0;
        buffers = [];
        var data = await stt(sending);
            console.log(data[0]);
        const results = data[0].results;
        const part = results.map(function(result) {
            return result.alternatives[0].transcript;
        }).join('\n');
        processTranscriptionPart(part);
        console.log("Updated transription: " + transcription);
        // complete the wait
        waiting = false;
            console.log("part recieved is",part);
        if(part != ""){
           console.log("transcription is there");

function stt used for speech to text

async function stt(file) {
console.log(“calling stt”);
const speechClient = new speech.SpeechClient();
const audioBytes = file.toString(‘base64’);

     const audio = {
         content: audioBytes,
     };
     const config = {
     encoding: 'LINEAR16',
     sampleRateHertz: 8000,
     Model: 'telephony',
     languageCode: 'en-IN'
     //languageCode: 'en-US'
     };
     const request = {
         audio,
         config
     };
     console.log("calling API");
     return await speechClient.recognize(request);

}

using wireshark i can see udp reaches in the destination server, but no rtp. it seems like its not the actual conversation is sending to google speech. Kindly help on this.

can anyone help on this. I am trying to convert speech to text and then the response from chatgpt as text to speech and playback to asterisk

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