support elevenlabs previous_text, next_text (#75)

This commit is contained in:
Hoan Luu Huu
2024-07-19 21:22:59 +07:00
committed by GitHub
parent 911ace221c
commit 56df923cdb
3 changed files with 20 additions and 0 deletions

View File

@@ -809,6 +809,12 @@ extern "C" {
cJSON * jResult = cJSON_CreateObject(); cJSON * jResult = cJSON_CreateObject();
cJSON_AddStringToObject(jResult, "model_id", el->model_id); cJSON_AddStringToObject(jResult, "model_id", el->model_id);
cJSON_AddStringToObject(jResult, "text", text); cJSON_AddStringToObject(jResult, "text", text);
if (el->previous_text) {
cJSON_AddStringToObject(jResult, "previous_text", el->previous_text);
}
if (el->next_text) {
cJSON_AddStringToObject(jResult, "next_text", el->next_text);
}
if (el->similarity_boost || el->style || el->use_speaker_boost || el->stability) { if (el->similarity_boost || el->style || el->use_speaker_boost || el->stability) {
cJSON * jVoiceSettings = cJSON_CreateObject(); cJSON * jVoiceSettings = cJSON_CreateObject();
cJSON_AddItemToObject(jResult, "voice_settings", jVoiceSettings); cJSON_AddItemToObject(jResult, "voice_settings", jVoiceSettings);

View File

@@ -19,6 +19,8 @@ static void clearElevenlabs(elevenlabs_t* el, int freeAll) {
if (el->style) free(el->style); if (el->style) free(el->style);
if (el->use_speaker_boost) free(el->use_speaker_boost); if (el->use_speaker_boost) free(el->use_speaker_boost);
if (el->optimize_streaming_latency) free(el->optimize_streaming_latency); if (el->optimize_streaming_latency) free(el->optimize_streaming_latency);
if (el->previous_text) free(el->previous_text);
if (el->next_text) free(el->next_text);
if (el->ct) free(el->ct); if (el->ct) free(el->ct);
if (el->reported_latency) free(el->reported_latency); if (el->reported_latency) free(el->reported_latency);
if (el->request_id) free(el->request_id); if (el->request_id) free(el->request_id);
@@ -36,6 +38,8 @@ static void clearElevenlabs(elevenlabs_t* el, int freeAll) {
el->style = NULL; el->style = NULL;
el->use_speaker_boost = NULL; el->use_speaker_boost = NULL;
el->optimize_streaming_latency = NULL; el->optimize_streaming_latency = NULL;
el->previous_text = NULL;
el->next_text = NULL;
el->ct = NULL; el->ct = NULL;
el->reported_latency = NULL; el->reported_latency = NULL;
el->request_id = NULL; el->request_id = NULL;
@@ -174,6 +178,14 @@ static void ell_text_param_tts(switch_speech_handle_t *sh, char *param, const ch
if (el->optimize_streaming_latency) free(el->optimize_streaming_latency); if (el->optimize_streaming_latency) free(el->optimize_streaming_latency);
el->optimize_streaming_latency = strdup(val); el->optimize_streaming_latency = strdup(val);
} }
else if (0 == strcmp(param, "next_text")) {
if (el->next_text) free(el->next_text);
el->next_text = strdup(val);
}
else if (0 == strcmp(param, "previous_text")) {
if (el->previous_text) free(el->previous_text);
el->previous_text = strdup(val);
}
else if (0 == strcmp(param, "write_cache_file") && switch_true(val)) { else if (0 == strcmp(param, "write_cache_file") && switch_true(val)) {
el->cache_audio = 1; el->cache_audio = 1;
} }

View File

@@ -17,6 +17,8 @@ struct elevenlabs_data {
char* style; char* style;
char* use_speaker_boost; char* use_speaker_boost;
char* optimize_streaming_latency; char* optimize_streaming_latency;
char* previous_text;
char* next_text;
/* result data */ /* result data */
long response_code; long response_code;