From fe1e4dcf11bfa01a7150078f8843f7aa1537a909 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:42:47 +0700 Subject: [PATCH] deepgram tts support on-premise (#95) * deepgram tts support on-premise Signed-off-by: Hoan HL * wip * fix review comment Signed-off-by: Hoan HL --------- Signed-off-by: Hoan HL --- mod_deepgram_tts/deepgram_glue.cpp | 2 +- mod_deepgram_tts/mod_deepgram_tts.c | 5 +++++ mod_deepgram_tts/mod_deepgram_tts.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mod_deepgram_tts/deepgram_glue.cpp b/mod_deepgram_tts/deepgram_glue.cpp index 7a943de..ab8a447 100644 --- a/mod_deepgram_tts/deepgram_glue.cpp +++ b/mod_deepgram_tts/deepgram_glue.cpp @@ -742,7 +742,7 @@ extern "C" { std::string url; std::ostringstream url_stream; // always use sample_rate=8000 for support jambonz caching system. - url_stream << "https://api.deepgram.com/v1/speak?model=" << d->voice_name << "&encoding=linear16&sample_rate=8000"; + url_stream << (d->endpoint != nullptr ? d->endpoint : "https://api.deepgram.com") << "/v1/speak?model=" << d->voice_name << "&encoding=linear16&sample_rate=8000"; url = url_stream.str(); /* create the JSON body */ diff --git a/mod_deepgram_tts/mod_deepgram_tts.c b/mod_deepgram_tts/mod_deepgram_tts.c index 68221bd..33a08d7 100644 --- a/mod_deepgram_tts/mod_deepgram_tts.c +++ b/mod_deepgram_tts/mod_deepgram_tts.c @@ -19,10 +19,12 @@ static void cleardeepgram(deepgram_t* d, int freeAll) { if (d->connect_time_ms) free(d->connect_time_ms); if (d->final_response_time_ms) free(d->final_response_time_ms); if (d->cache_filename) free(d->cache_filename); + if (d->endpoint) free(d->endpoint); d->api_key = NULL; d->request_id = NULL; + d->endpoint = NULL; d->reported_model_name = NULL; d->reported_model_uuid = NULL; @@ -121,6 +123,9 @@ static void d_text_param_tts(switch_speech_handle_t *sh, char *param, const char if (0 == strcmp(param, "api_key")) { if (d->api_key) free(d->api_key); d->api_key = strdup(val); + } else if (0 == strcmp(param, "endpoint")) { + if (d->endpoint) free(d->endpoint); + d->endpoint = strdup(val); } else if (0 == strcmp(param, "voice")) { if (d->voice_name) free(d->voice_name); d->voice_name = strdup(val); diff --git a/mod_deepgram_tts/mod_deepgram_tts.h b/mod_deepgram_tts/mod_deepgram_tts.h index dacf5f4..5c08ef9 100644 --- a/mod_deepgram_tts/mod_deepgram_tts.h +++ b/mod_deepgram_tts/mod_deepgram_tts.h @@ -7,6 +7,7 @@ typedef struct deepgram_data { char *voice_name; char *api_key; + char *endpoint; /* result data */ long response_code;