mirror of
https://github.com/jambonz/freeswitch-modules.git
synced 2026-01-25 02:08:27 +00:00
add properties to tts span for mod_*_tts (#45)
* add properties to tts span for mod_*_tts Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * support deepgram tts span Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * support tts span for playht Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * support rimelabs tts span Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> --------- Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com>
This commit is contained in:
@@ -12,6 +12,10 @@ static void clearWhisper(whisper_t* w, int freeAll) {
|
||||
if (w->speed) free(w->speed);
|
||||
if (w->request_id) free(w->request_id);
|
||||
if (w->reported_latency) free(w->reported_latency);
|
||||
if (w->reported_organization) free(w->reported_organization);
|
||||
if (w->reported_ratelimit_requests) free(w->reported_ratelimit_requests);
|
||||
if (w->reported_ratelimit_remaining_requests) free(w->reported_ratelimit_remaining_requests);
|
||||
if (w->reported_ratelimit_reset_requests) free(w->reported_ratelimit_reset_requests);
|
||||
if (w->ct) free(w->ct);
|
||||
if (w->err_msg) free(w->err_msg);
|
||||
if (w->name_lookup_time_ms) free(w->name_lookup_time_ms);
|
||||
@@ -25,6 +29,10 @@ static void clearWhisper(whisper_t* w, int freeAll) {
|
||||
w->speed = NULL;
|
||||
w->request_id = NULL;
|
||||
w->reported_latency = NULL;
|
||||
w->reported_organization = NULL;
|
||||
w->reported_ratelimit_requests = NULL;
|
||||
w->reported_ratelimit_remaining_requests = NULL;
|
||||
w->reported_ratelimit_reset_requests = NULL;
|
||||
w->ct = NULL;
|
||||
w->err_msg = NULL;
|
||||
w->name_lookup_time_ms = NULL;
|
||||
|
||||
@@ -11,7 +11,18 @@ typedef struct whisper_data {
|
||||
/* result data */
|
||||
long response_code;
|
||||
char *ct;
|
||||
//whisper headers
|
||||
//openai-organization
|
||||
char *reported_organization;
|
||||
//openai-processing-ms
|
||||
char *reported_latency;
|
||||
//x-ratelimit-limit-requests
|
||||
char *reported_ratelimit_requests;
|
||||
//x-ratelimit-remaining-requests
|
||||
char *reported_ratelimit_remaining_requests;
|
||||
//x-ratelimit-reset-requests
|
||||
char *reported_ratelimit_reset_requests;
|
||||
//x-request-id
|
||||
char *request_id;
|
||||
char *name_lookup_time_ms;
|
||||
char *connect_time_ms;
|
||||
|
||||
@@ -495,6 +495,18 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, ConnInfo_t *conn) {
|
||||
if (w->request_id) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_whisper_request_id", w->request_id);
|
||||
}
|
||||
if (w->reported_organization) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_whisper_reported_organization", w->reported_latency);
|
||||
}
|
||||
if (w->reported_ratelimit_requests) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_whisper_reported_ratelimit_requests", w->reported_ratelimit_requests);
|
||||
}
|
||||
if (w->reported_ratelimit_remaining_requests) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_whisper_reported_ratelimit_remaining_requests", w->reported_ratelimit_remaining_requests);
|
||||
}
|
||||
if (w->reported_ratelimit_reset_requests) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_whisper_reported_ratelimit_reset_requests", w->reported_ratelimit_reset_requests);
|
||||
}
|
||||
if (w->name_lookup_time_ms) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_whisper_name_lookup_time_ms", w->name_lookup_time_ms);
|
||||
}
|
||||
@@ -572,6 +584,10 @@ static size_t header_callback(char *buffer, size_t size, size_t nitems, ConnInfo
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "recv header: %s with value %s\n", header.c_str(), value.c_str());
|
||||
if (0 == header.compare("openai-processing-ms")) w->reported_latency = strdup(value.c_str());
|
||||
else if (0 == header.compare("x-request-id")) w->request_id = strdup(value.c_str());
|
||||
else if (0 == header.compare("openai-organization")) w->reported_organization = strdup(value.c_str());
|
||||
else if (0 == header.compare("x-ratelimit-limit-requests")) w->reported_ratelimit_requests = strdup(value.c_str());
|
||||
else if (0 == header.compare("x-ratelimit-remaining-requests")) w->reported_ratelimit_remaining_requests = strdup(value.c_str());
|
||||
else if (0 == header.compare("x-ratelimit-reset-requests")) w->reported_ratelimit_reset_requests = strdup(value.c_str());
|
||||
}
|
||||
else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "header_callback: %s\n", input.c_str());
|
||||
|
||||
Reference in New Issue
Block a user