mirror of
https://github.com/jambonz/freeswitch-modules.git
synced 2025-12-19 08:57:44 +00:00
deepgram tts support on-premise (#95)
* deepgram tts support on-premise Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * wip * fix review comment Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> --------- Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com>
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
typedef struct deepgram_data {
|
||||
char *voice_name;
|
||||
char *api_key;
|
||||
char *endpoint;
|
||||
|
||||
/* result data */
|
||||
long response_code;
|
||||
|
||||
Reference in New Issue
Block a user