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:
Hoan Luu Huu
2024-04-14 20:13:54 +07:00
committed by GitHub
parent 622cb14957
commit 3f642467eb
12 changed files with 61 additions and 26 deletions
+11 -2
View File
@@ -470,8 +470,14 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, ConnInfo_t *conn) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "write_cb: firing playback-started\n");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-File-Type", "tts_stream");
if (d->reported_latency) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_deepgram_reported_latency_ms", d->reported_latency);
if (d->reported_model_name) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_deepgram_reported_model_name", d->reported_model_name);
}
if (d->reported_model_uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_deepgram_reported_model_uuid", d->reported_model_uuid);
}
if (d->reported_char_count) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_deepgram_reported_char_count", d->reported_char_count);
}
if (d->request_id) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_deepgram_request_id", d->request_id);
@@ -549,6 +555,9 @@ static size_t header_callback(char *buffer, size_t size, size_t nitems, ConnInfo
if (parseHeader(input, header, value)) {
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("dg-request-id")) d->request_id = strdup(value.c_str());
else if (0 == header.compare("dg-model-name")) d->reported_model_name = strdup(value.c_str());
else if (0 == header.compare("dg-model-uuid")) d->reported_model_uuid = strdup(value.c_str());
else if (0 == header.compare("dg-char-count")) d->reported_char_count = strdup(value.c_str());
}
else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "header_callback: %s\n", input.c_str());
+6 -2
View File
@@ -10,7 +10,9 @@ static void cleardeepgram(deepgram_t* d, int freeAll) {
if (d->api_key) free(d->api_key);
if (d->request_id) free(d->request_id);
if (d->reported_latency) free(d->reported_latency);
if (d->reported_model_name) free(d->reported_model_name);
if (d->reported_model_uuid) free(d->reported_model_uuid);
if (d->reported_char_count) free(d->reported_char_count);
if (d->ct) free(d->ct);
if (d->err_msg) free(d->err_msg);
if (d->name_lookup_time_ms) free(d->name_lookup_time_ms);
@@ -22,7 +24,9 @@ static void cleardeepgram(deepgram_t* d, int freeAll) {
d->api_key = NULL;
d->request_id = NULL;
d->reported_latency = NULL;
d->reported_model_name = NULL;
d->reported_model_uuid = NULL;
d->reported_char_count = NULL;
d->ct = NULL;
d->err_msg = NULL;
d->name_lookup_time_ms = NULL;
+8 -1
View File
@@ -11,7 +11,14 @@ typedef struct deepgram_data {
/* result data */
long response_code;
char *ct;
char *reported_latency;
// Deepgram hedaers
//dg-model-name
char *reported_model_name;
//dg-model-uuid
char *reported_model_uuid;
//dg-char-count
char *reported_char_count;
//dg-request-id
char *request_id;
char *name_lookup_time_ms;
char *connect_time_ms;