Realtime voice to voice Streaming

Hi guys,
I am the new one for the astersk application, Realtime voice to voice streaming is possible asterisk ?

i have the call the asterisk extension example 200 connect the asterisk then call going to live streaming user can ask questions i have convert audio to text using google cloud speech api and i have send the converted text to our api then api should return the text reponse i have convert the audio file then play to the user this i have achived .

but my requirement continuously voice streaming application when user ask question until user end the call asterisk detect the user voice then record the audio user make 3s silence convert the text then working on above same logics.

but conituously streaming this is possible ? if this is possible anybody can help me .

This is almost a daily question at this point…

All of the pieces exist, it’s up to you to put them together.

but how do i know user speaking or not, I am creating a script file using perl now i am ony record the audio and i am every 3s calling the record() user speaking or not but i am calling because I need a continously streaming websocket also not working properly connect initial time only after I am asking second question its closed. using aeap.conf also failed what i do

Asterisk provides a TALK_DETECT dialplan function[1] that can be placed on a channel which will raise events over ARI for when talking and silence is detected.

All of the building blocks are available in ARI to do this, but it’s up to you to learn/try/put them together to do what you want. There is no out of the box complete solution to do exactly what you want.

[1] TALK_DETECT - Asterisk Documentation

but i need a continuously streaming like human to human interactions i have tried many things websokets,audio stream perl modules but no i cannot able to control continuously streaming.

we are creating like customer care user ask question will our api response againist the user questions Talk_detect also i am using but i dont know what i do program level can please provide example code

and i am only know perl.

It sounds like this is outside the scope of your abilities and knowledge I’m afraid.

okay can you please tell me what about EAGI because i dont know and how can i use.

What about it? It sends audio from Asterisk to the AGI. That’s it.

[ilay_calls]
exten => 0441234567,1,NoOp(“Ringing”)
same => n,Answer()
same => n,Set(sender_id=${RAND(1000,9999)}-${UNIQUEID}) ; Generate a random sender_id
same => n,agi(aravindh-speech.agi, en-US, 3)
same => n,Verbose(1,You said Is : ${utterance})
same => n,Verbose(1,Speech Recognation Status: ${confidence})
same => n,Verbose(1,“Sending API Data to API”)
same => n,System(rm /tmp/api_response.txt /tmp/extracted_text.txt)
same => n,Verbose(1,“Generated sender_id: ${sender_id}”)
same => n,System(curl -X POST https://analytics.twixor.com/analytics_apis/chat -H “Content-Type: application/json” -d ‘{“message”:“${utterance}”,“sender_id”:“${sender_id}”}’> /tmp/api_response.txt)
same => n,System(cat /tmp/api_response.txt | jq -r ‘map(.text) | join(", ")’ > /tmp/extracted_text.txt)
same => n,Set(language=en)
;same => n,Set(text=“Greetings! I’m Twilight. How may I be of service to you today?”)
same => n,ExecIf($[${STAT(s,/tmp/extracted_text.txt)}]?Set(API_RESPONSE=${FILE(/tmp/extracted_text.txt)}):Set(API_RESPONSE=“Sorry, I couldn’t Reach You.”))
same => n,Set(API_RESPONSE_STR=(${API_RESPONSE})); Explicitly set to ensure it’s handled as a string
same => n,Verbose(1,API: “${API_RESPONSE_STR}”)
;same => n,agi(googletts.agi,“${text}”,en)
same => n,agi(googletts.agi,“${API_RESPONSE_STR}”,${language})
same => n,System(rm /tmp/api_response.txt /tmp/extracted_text.txt);

same => n,agi(aravindh-speech.agi, en-US)
same => n,Verbose(1,You said Is : ${utterance})
same => n,Verbose(1,Speech Recognation Status: ${confidence})
same => n,Verbose(1,“Sending API Data to API”)
same => n,System(rm /tmp/api_response.txt /tmp/extracted_text.txt)
same => n,Verbose(1,“Generated sender_id: ${sender_id}”)
same => n,System(curl -X POST https://analytics.twixor.com/analytics_apis/chat -H “Content-Type: application/json” -d ‘{“message”:“${utterance}”,“sender_id”:“${sender_id}”}’> /tmp/api_response.txt)
same => n,System(cat /tmp/api_response.txt | jq -r ‘map(.text) | join(", ")’ > /tmp/extracted_text.txt)
same => n,Set(language=en)
;same => n,Set(text=“Greetings! I’m Twilight. How may I be of service to you today?”)
same => n,ExecIf($[${STAT(s,/tmp/extracted_text.txt)}]?Set(API_RESPONSE=${FILE(/tmp/extracted_text.txt)}):Set(API_RESPONSE=“Sorry, I couldn’t Reach You.”))
same => n,Set(API_RESPONSE_STR=(${API_RESPONSE})); Explicitly set to ensure it’s handled as a string
same => n,Verbose(1,API: “${API_RESPONSE_STR}”)
;same => n,agi(googletts.agi,“${text}”,en)
same => n,agi(googletts.agi,“${API_RESPONSE_STR}”,${language})
same => n,System(rm /tmp/api_response.txt /tmp/extracted_text.txt);

same => n,agi(aravindh-speech.agi, en-US)
same => n,Verbose(1,You said Is : ${utterance})
same => n,Verbose(1,Speech Recognation Status: ${confidence})
same => n,Verbose(1,“Sending API Data to API”)
same => n,System(rm /tmp/api_response.txt /tmp/extracted_text.txt)
same => n,Verbose(1,“Generated sender_id: ${sender_id}”)
same => n,System(curl -X POST https://analytics.twixor.com/analytics_apis/chat -H “Content-Type: application/json” -d ‘{“message”:“${utterance}”,“sender_id”:“${sender_id}”}’> /tmp/api_response.txt)
same => n,System(cat /tmp/api_response.txt | jq -r ‘map(.text) | join(", ")’ > /tmp/extracted_text.txt)
same => n,Set(language=en)
;same => n,Set(text=“Greetings! I’m Twilight. How may I be of service to you today?”)
same => n,ExecIf($[${STAT(s,/tmp/extracted_text.txt)}]?Set(API_RESPONSE=${FILE(/tmp/extracted_text.txt)}):Set(API_RESPONSE=“Sorry, I couldn’t Reach You.”))
same => n,Set(API_RESPONSE_STR=(${API_RESPONSE})); Explicitly set to ensure it’s handled as a string
same => n,Verbose(1,API: “${API_RESPONSE_STR}”)
;same => n,agi(googletts.agi,“${text}”,en)
same => n,agi(googletts.agi,“${API_RESPONSE_STR}”,${language})
same => n,System(rm /tmp/api_response.txt /tmp/extracted_text.txt);

this is my extension.conf file. but one thing i dont know why websocket connection is closed when i am speaking after one time

Presumably because the AGI is returning, at which point the AGI ends and the websocket is closed?

when i am speaking after making silence 3s generate the text using google tts after its closed

When an AGI returns, that AGI is no longer running so any connections such as websockets would be closed.

ohh but i need continuously streaming my application any other way possible this

We’re going in circles at this point. Others may provide further help or options, but I’ve given mine.

Yeah! you are really spend with time and great help for me. Thank you.

I am working on a similar scenario, but I haven’t made much progress. Could you provide information on how you set up the structure and code, if possible? @aravindh-itgalax

okay. I am using SIP Trunk and speech to text and text to speech convert using google apis and those thing connect via asterisk agi. one time is working.

[ilay_calls]
exten => 0441234567,1,NoOp(“Ringing”)
same => n,Answer()
same => n,Set(sender_id=${RAND(1000,9999)}-${UNIQUEID}) ; Generate a random sender_id
same => n,agi(aravindh-speech.agi, en-US, 3)
same => n,Verbose(1,You said Is : ${utterance})
same => n,Verbose(1,Speech Recognation Status: ${confidence})
same => n,Verbose(1,“Sending API Data to API”)
same => n,System(rm /tmp/api_response.txt /tmp/extracted_text.txt)
same => n,Verbose(1,“Generated sender_id: ${sender_id}”)
same => n,System(curl -X POST https://analytics.twixor.com/analytics_apis/chat -H “Content-Type: application/json” -d ‘{“message”:“${utterance}”,“sender_id”:“${sender_id}”}’> /tmp/api_response.txt)
same => n,System(cat /tmp/api_response.txt | jq -r ‘map(.text) | join(", ")’ > /tmp/extracted_text.txt)
same => n,Set(language=en)
;same => n,Set(text=“Greetings! I’m Twilight. How may I be of service to you today?”)
same => n,ExecIf($[${STAT(s,/tmp/extracted_text.txt)}]?Set(API_RESPONSE=${FILE(/tmp/extracted_text.txt)}):Set(API_RESPONSE=“Sorry, I couldn’t Reach You.”))
same => n,Set(API_RESPONSE_STR=(${API_RESPONSE})); Explicitly set to ensure it’s handled as a string
same => n,Verbose(1,API: “${API_RESPONSE_STR}”)
;same => n,agi(googletts.agi,“${text}”,en)
same => n,agi(googletts.agi,“${API_RESPONSE_STR}”,${language})
same => n,System(rm /tmp/api_response.txt /tmp/extracted_text.txt);

this is my extensions.conf file.

but in my requirements continuously streaming until user hangup the call. am using perl

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