Skip to content

Commit 6a68683

Browse files
Merge 'develop' for release 2.2.0
Merge 'develop' for release 2.2.0: - refactor align forward-stream logic with improvements from the original mod_audio_stream repo (#24) - refactor api command cli helper (#24) - fix both safety issues and performance improvements in stream_frame (#24) - fix avoid per-frame heap allocations of support buffers #24 - update docs references for project rename to mod_openai_realtime
2 parents c2886ef + 31d9b4b commit 6a68683

File tree

7 files changed

+162
-337
lines changed

7 files changed

+162
-337
lines changed

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.18)
22
project(mod_openai_audio_stream
33
VERSION 1.0.0
44
DESCRIPTION "Audio streaming module for FreeSWITCH."
5-
HOMEPAGE_URL "https://github.com/VoiSmart/mod_openai_audio_stream")
5+
HOMEPAGE_URL "https://github.com/VoiSmart/mod_openai_realtime")
66

77
include(GNUInstallDirs)
88

@@ -34,7 +34,13 @@ if(CMAKE_BUILD_TYPE MATCHES "Release")
3434
set_target_properties(ixwebsocket PROPERTIES LINK_FLAGS_RELEASE "-s -w") #-static-libgcc -static-libstdc++
3535
endif()
3636

37-
add_library(mod_openai_audio_stream SHARED mod_openai_audio_stream.c mod_openai_audio_stream.h openai_audio_streamer_glue.h openai_audio_streamer_glue.cpp buffer/ringbuffer.c base64.cpp)
37+
add_library(mod_openai_audio_stream SHARED
38+
mod_openai_audio_stream.c
39+
mod_openai_audio_stream.h
40+
openai_audio_streamer_glue.h
41+
openai_audio_streamer_glue.cpp
42+
base64.cpp
43+
)
3844

3945
set_property(TARGET mod_openai_audio_stream PROPERTY POSITION_INDEPENDENT_CODE ON)
4046

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# mod_openai_audio_stream
1+
# mod_openai_realtime
22

3-
![Build](https://github.com/VoiSmart/mod_openai_audio_stream/actions/workflows/build.yml/badge.svg?branch=main)
4-
![Code-Checks](https://github.com/VoiSmart/mod_openai_audio_stream/actions/workflows/code-checks.yml/badge.svg?branch=main)
3+
![Build](https://github.com/VoiSmart/mod_openai_realtime/actions/workflows/build.yml/badge.svg?branch=main)
4+
![Code-Checks](https://github.com/VoiSmart/mod_openai_realtime/actions/workflows/code-checks.yml/badge.svg?branch=main)
55
[![License: MIT](https://img.shields.io/badge/license-MIT-blue?style=flat)](LICENSE)
66

7-
**mod_openai_audio_stream** is a FreeSWITCH module that streams L16 audio from a channel to an OpenAI Realtime WebSocket endpoint. The stream follows OpenAI's Realtime API specification and enables real-time audio playback directly in the channel.
7+
**mod_openai_realtime** is a FreeSWITCH module that streams L16 audio from a channel to an OpenAI Realtime WebSocket endpoint. The stream follows OpenAI's Realtime API specification and enables real-time audio playback directly in the channel.
8+
9+
> [!WARNING]
10+
> This is a standalone fork of `mod_audio_stream`, not affiliated with the original project.
11+
> Legacy naming (`mod_openai_audio_stream`) is retained for backward compatibility but will be updated in a future major release.
812
913
It is a fork of [mod_audio_stream](https://github.com/amigniter/mod_audio_stream), specifically adapted for streaming audio to OpenAI's Realtime API and playing the responses back to the user via FreeSWITCH and WebSocket.
1014

11-
The goal of **mod_openai_audio_stream** is to provide a simple, lightweight, yet effective module for streaming audio and receiving responses directly from OpenAI’s Realtime WebSocket into the call through FreeSWITCH. It uses [ixwebsocket](https://machinezone.github.io/IXWebSocket/), a C++ WebSocket library compiled as a static library.
15+
The goal of **mod_openai_realtime** is to provide a simple, lightweight, yet effective module for streaming audio and receiving responses directly from OpenAI’s Realtime WebSocket into the call through FreeSWITCH. It uses [ixwebsocket](https://machinezone.github.io/IXWebSocket/), a C++ WebSocket library compiled as a static library.
1216

1317

1418
## Important Notes
@@ -76,7 +80,7 @@ The following is **a simple dialplan example** that demonstrates how to use the
7680

7781
* Make sure to replace `sk-xxxxxxxxxxxxxxxxxx` with your actual OpenAI API key.
7882
* The dialplan answers the call and starts streaming audio to OpenAI's Realtime API using `uuid_openai_audio_stream`, so you can try it out and see the OpenAI events in the FreeSWITCH console within the `mod_openai_audio_stream::json` events and other module events.
79-
* The playback action with `silence_stream://-1//` is needed for audio playback to work properly. For more details, check issue [#16](https://github.com/VoiSmart/mod_openai_audio_stream/issues/16).
83+
* The playback action with `silence_stream://-1//` is needed for audio playback to work properly. For more details, check issue [#16](https://github.com/VoiSmart/mod_openai_realtime/issues/16).
8084

8185
#### Next steps
8286

@@ -85,7 +89,7 @@ The **getting started** example is a basic demonstration of how to use the modul
8589
This way you can build more complex applications **allowing for function calls, updating instructions**, and other interactions with OpenAI's Realtime API. Check out the [OpenAI Realtime documentation](https://platform.openai.com/docs/guides/realtime) and [API reference](https://platform.openai.com/docs/api-reference/realtime) for more details on how to structure your requests and handle responses.
8690

8791
### Channel variables
88-
The following channel variables can be used to fine tune websocket connection and also configure mod_openai_audio_stream logging:
92+
The following channel variables can be used to fine-tune websocket connection and also configure mod_openai_realtime logging:
8993

9094
| Variable | Description | Default |
9195
| -------------------------------------- | ------------------------------------------------------- | ------- |

buffer/ringbuffer.c

Lines changed: 0 additions & 123 deletions
This file was deleted.

buffer/ringbuffer.h

Lines changed: 0 additions & 74 deletions
This file was deleted.

mod_openai_audio_stream.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ static switch_status_t send_json(switch_core_session_t *session, char* json) {
170170
#define STREAM_API_SYNTAX \
171171
"USAGE:\n" \
172172
"--------------------------------------------------------------------------------\n" \
173-
"uuid_openai_audio_stream <uuid> [start | stop | send_json | pause | resume |\n" \
174-
" mute | unmute]\n" \
175-
" [wss-url | path | user | openai | all | base64json]\n" \
176-
" [mono | mixed | stereo]\n" \
177-
" [8000 | 16000 | 24000]\n" \
178-
" [mute_user]\n" \
173+
"uuid_openai_audio_stream <uuid> start <wss-url> <mono | mixed | stereo>\n" \
174+
" [8k | 16k | 24k | <other rate>] [mute_user]\n" \
175+
" where <rate> = 8k|16k|24k or any multiple of 8000 (default: 8k)\n" \
176+
"uuid_openai_audio_stream <uuid> [stop | pause | resume]\n" \
177+
"uuid_openai_audio_stream <uuid> [mute | unmute] [user | openai | all]\n" \
178+
"uuid_openai_audio_stream <uuid> send_json <base64json>\n" \
179179
"--------------------------------------------------------------------------------\n"
180180

181181
typedef enum {

mod_openai_audio_stream.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <switch.h>
55
#include <limits.h>
66
#include <speex/speex_resampler.h>
7-
#include "buffer/ringbuffer.h"
87

98
#define MY_BUG_NAME "audio_stream"
109
#define MAX_SESSION_ID (256)
@@ -33,11 +32,10 @@ struct private_data {
3332
int user_audio_muted:1;
3433
int openai_audio_muted:1;
3534
int close_requested:1;
36-
RingBuffer *buffer;
3735
switch_buffer_t *sbuffer;
38-
uint8_t *data;
3936
int rtp_packets;
4037
switch_buffer_t *playback_buffer;
38+
void *stream_buffers;
4139
};
4240

4341
typedef struct private_data private_t;

0 commit comments

Comments
 (0)