# How Can Asterisk Play the Real-Time Audio Stream?

**URL:** <https://community.asterisk.org/t/how-can-asterisk-play-the-real-time-audio-stream/105166>\
**Category:** Asterisk Support\
**Created:** [October 30, 2024, 7:13am UTC](https://community.asterisk.org/t/how-can-asterisk-play-the-real-time-audio-stream/105166 "2024-10-30T07:13:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zzoah](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/zzoah/32/6573_2.png) [@zzoah](https://community.asterisk.org/u/zzoah)\
**Post date:** [October 30, 2024, 7:13am UTC](https://community.asterisk.org/t/how-can-asterisk-play-the-real-time-audio-stream/105166/1 "2024-10-30T07:13:45Z")

</div>

Hi everyone,

I’m currently using AEAP to handle speech processing for Asterisk, which includes speech-to-text (STT) and text-to-speech (TTS) conversion for Asterisk playback. The setup works well, but I’d like to enhance it to create more seamless voice AI conversations with users and reduce latency.

I’ve come across OpenAI’s Realtime API, which seems promising for low-latency interactions ([OpenAI Realtime API](https://platform.openai.com/docs/guides/realtime?text-generation-quickstart-example=audio)). My goal is to stream audio from Asterisk to OpenAI (using AEAP), receive the audio response in real-time, and then immediately play that streamed audio response to the user—all without saving it as a file.

### Question:

- **How can Asterisk play the audio response stream directly from the Realtime API without saving it as a file?**

I would be grateful for any insights, advice, or implementation examples that could help me achieve this real-time streaming solution!

Thank you!

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [October 30, 2024, 8:08am UTC](https://community.asterisk.org/t/how-can-asterisk-play-the-real-time-audio-stream/105166/2 "2024-10-30T08:08:08Z")

</div>

You can’t easily simultaneously use AEAP and also do this. Trying to do that is going beyond what it was intended to do and what the dialplan functionality for it was intended to do. I’m a broken record, but external media in ARI provides a bidirectional realtime RTP stream that you can do whatever you want with. Stream audio out of Asterisk, stream audio in, attach it to a snoop channel and do live transcription, stick a caller and the external media channel in a bridge and do some kind of conversational thing, up to you. When the external media channel is created, the target for RTP for the ARI application is provided.

> [@Asterisk Server Configurations for Real-Time External Media Listening](https://community.asterisk.org/t/asterisk-server-configurations-for-real-time-external-media-listening/104367):
>
> [stream-audio] ; Handle calls between any two extensions in the 7000 range using external media exten =\> \_7XXX,1,NoOp(Starting call to ${EXTEN} from ${CALLERID(num)}) same =\> n,ExternalMedia(rtp,3.252.149.9:3000/3.252.149.9:3001,slin16) ; Send RTP to your Node.js server ports same =\> n,Hangup() ; Voicemail handling for any extensions in the 8000 range exten =\> \_8XXX,1,VoicemailMain(${EXTEN}@main) same =\> n,Hangup()

> [@Is it possible to transcribe live calls with asterisk?](https://community.asterisk.org/t/is-it-possible-to-transcribe-live-calls-with-asterisk/98992/7):
>
> All of the components are present to be able to do so. It’s up to you to put the pieces together. ARI has the ability to snoop on a channel for example[1] which can be used to passively fork audio. Once done ARI also provides external media[2] functionality to direct media outside of Asterisk to an application. What happens there is up to you. There is an example of an external media implementation on Github[3]. If you’re wanting a complete out of the box solution though, then that doesn’t exist…

---

<div class="post-metadata">

**Author:** ![zzoah](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/zzoah/32/6573_2.png) [@zzoah](https://community.asterisk.org/u/zzoah)\
**Post date:** [October 30, 2024, 8:19am UTC](https://community.asterisk.org/t/how-can-asterisk-play-the-real-time-audio-stream/105166/3 "2024-10-30T08:19:00Z")

</div>

Thanks, @jcolp, that’s all I need.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [November 29, 2024, 8:19am UTC](https://community.asterisk.org/t/how-can-asterisk-play-the-real-time-audio-stream/105166/4 "2024-11-29T08:19:18Z")

</div>

Closed on November 29, 2024, 8:19am UTC

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