ARI-CLIENT SPEECH TO TEXT STREAMING

Hi,

Thank you for all the advices on the forum!
But, I can’t find the answer on what I need:

I use ari-client in node-js (that is asked by my company)

JavaScript:

ari.connect(url, username, password, clientLoaded);

async function clientLoaded (err, client) {if (err) {throw err;}

client.channels.originate(

    {app: 'asterisk_stasis', endpoint: 'SIP/MySIP',callerId :'99999',appArgs: 'dialed'},

    function (err, channel) {if(err){throw  err;}});



async function stasisStart(event, channel) {

    console.log(util.format('Channel %s has entered the application', channel.name));

    const wss = new WebSocket('ws://127.0.0.1:9099');

    wss.addEventListener('open', () => {

                  client.channels.record({

                                          channelId: channel.id,

                                          format: 'wav',

                                          name: 'me',

                                          beep: true,

                                          ifExists: 'overwrite',

                                          //maxSilenceSeconds: 1,

                                        }).then(function (liverecording) {

                                          console.log(liverecording._client._swagger.sounds.api.recordings.getLive({recordingName: 'getStored'}))

                                          console.log(liverecording._client.LiveRecording().getLive());

                                                                                    })

    function stasisEnd(event, channel) {console.log(util.format('Channel %s has left the application', channel.name), process.exit(0));}

    function channelStateChange(event, channel) {console.log(util.format('Channel %s is now: %s', channel.name, channel.state));}

 

    client.on('StasisStart', stasisStart);

    client.on('StasisEnd', stasisEnd);

    client.on('ChannelStateChange', channelStateChange);

    client.start('asterisk_stasis');}

I try to see what’s happen on the console.log because I want to find the flow that is sent to the wav file, to send it to goole speech to text and having the transcription instantly.

Is there someone who know how to catch this information? Or if using the ‘.record’ is not the good way?

Thanks a lot!

The correct way would be to use the external media support in ARI to send the audio to your application, which then forwards it on to Google and uses the result. There is an example on Github[1].

[1] GitHub - asterisk/asterisk-external-media

Thanks a lot! It is very helpful! I did not understand why we need a bridge to catch the audio data but I think that it is clear now :slight_smile:

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