Skip to content

Commit dc0d181

Browse files
update to new realtime api events spec
Signed-off-by: Dario Pellegrino <[email protected]>
1 parent db0943f commit dc0d181

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ The following channel variables can be used to fine tune websocket connection an
7171
| STREAM_TLS_DISABLE_HOSTNAME_VALIDATION | true or 1 disable hostname check in WSS connections | false |
7272
| STREAM_DISABLE_AUDIOFILES | true or 1, disables debug audio files generation in tmp | false |
7373
| STREAM_OPENAI_API_KEY | OpenAI API key, used for authentication with OpenAI's | none |
74-
| STREAM_OPENAI_REALTIME_VERSION | OpenAI Realtime API version, e.g. "v1" | v1 |
7574

7675
- Per message deflate compression option is enabled by default. It can lead to a very nice bandwidth savings. To disable it set the channel var to `true|1`.
7776
- Heart beat, sent every xx seconds when there is no traffic to make sure that load balancers do not kill an idle connection.

openai_audio_streamer_glue.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class AudioStreamer {
295295

296296
status = SWITCH_TRUE;
297297

298-
} else if(jsType && strcmp(jsType, "response.audio.delta") == 0) {
298+
} else if(jsType && strcmp(jsType, "response.output_audio.delta") == 0) {
299299
const char* jsonAudio = cJSON_GetObjectCstr(json, "delta");
300300
playback_clear_requested = false;
301301
m_response_audio_done = false;
@@ -335,9 +335,9 @@ class AudioStreamer {
335335
status = SWITCH_TRUE;
336336

337337
} else {
338-
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "(%s) processMessage - response.audio.delta no audio data\n", m_sessionId.c_str());
338+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "(%s) processMessage - response.output_audio.delta no audio data\n", m_sessionId.c_str());
339339
}
340-
} else if(jsType && strcmp(jsType, "response.audio.done") == 0) {
340+
} else if(jsType && strcmp(jsType, "response.output_audio.done") == 0) {
341341
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "(%s) processMessage - audio done\n", m_sessionId.c_str());
342342
m_response_audio_done = true;
343343
}
@@ -806,8 +806,6 @@ extern "C" {
806806
tls_keyfile = switch_channel_get_variable(channel, "STREAM_TLS_KEY_FILE");
807807
tls_certfile = switch_channel_get_variable(channel, "STREAM_TLS_CERT_FILE");
808808
openai_api_key = switch_channel_get_variable(channel, "STREAM_OPENAI_API_KEY");
809-
openai_realtime_version = switch_channel_get_variable(channel, "STREAM_OPENAI_REALTIME_VERSION");
810-
811809

812810
if (switch_channel_var_true(channel, "STREAM_TLS_DISABLE_HOSTNAME_VALIDATION")) {
813811
tls_disable_hostname_validation = true;
@@ -837,17 +835,9 @@ extern "C" {
837835
}
838836

839837
if (openai_api_key) {
840-
const char* api_version;
841-
if (openai_realtime_version) {
842-
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Using OpenAI Realtime version: %s\n", openai_realtime_version);
843-
api_version = openai_realtime_version;
844-
} else {
845-
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "OPENAI_REALTIME_VERSION is not set. Using v1 as default.\n");
846-
api_version = "v1"; // default version
847-
}
848838
char headers_buf[1024] = {0};
849839
snprintf(headers_buf, sizeof(headers_buf),
850-
"{\"Authorization\": \"Bearer %s\", \"OpenAI-Beta\": \"realtime=%s\"}", openai_api_key, api_version);
840+
"{\"Authorization\": \"Bearer %s\"}", openai_api_key);
851841
extra_headers = headers_buf;
852842
} else {
853843
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "OPENAI_API_KEY is not set. Assuming you set STREAM_EXTRA_HEADERS variable.\n");

0 commit comments

Comments
 (0)