mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-16 00:41:41 +00:00
FS-11111 #resolve add handle params to specify tts engine and voice from command text
This commit is contained in:
parent
413ea14fd4
commit
e55212f5d8
@ -895,6 +895,7 @@ switch_status_t conference_say(conference_obj_t *conference, const char *text, u
|
||||
char *fp = NULL;
|
||||
int channels;
|
||||
const char *position = NULL;
|
||||
const char *tts_engine = NULL, *tts_voice = NULL;
|
||||
|
||||
switch_assert(conference != NULL);
|
||||
|
||||
@ -908,9 +909,6 @@ switch_status_t conference_say(conference_obj_t *conference, const char *text, u
|
||||
switch_mutex_lock(conference->mutex);
|
||||
switch_mutex_lock(conference->member_mutex);
|
||||
count = conference->count;
|
||||
if (!(conference->tts_engine && conference->tts_voice)) {
|
||||
count = 0;
|
||||
}
|
||||
switch_mutex_unlock(conference->member_mutex);
|
||||
switch_mutex_unlock(conference->mutex);
|
||||
|
||||
@ -951,7 +949,11 @@ switch_status_t conference_say(conference_obj_t *conference, const char *text, u
|
||||
fnode->type = NODE_TYPE_SPEECH;
|
||||
fnode->leadin = leadin;
|
||||
|
||||
if (params && (position = switch_event_get_header(params, "position"))) {
|
||||
if (params) {
|
||||
tts_engine = switch_event_get_header(params, "tts_engine");
|
||||
tts_voice = switch_event_get_header(params, "tts_voice");
|
||||
|
||||
if ((position = switch_event_get_header(params, "position"))) {
|
||||
if (conference->channels != 2) {
|
||||
position = NULL;
|
||||
} else {
|
||||
@ -964,6 +966,7 @@ switch_status_t conference_say(conference_obj_t *conference, const char *text, u
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (conference->sh && conference->last_speech_channels != channels) {
|
||||
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
|
||||
@ -971,9 +974,23 @@ switch_status_t conference_say(conference_obj_t *conference, const char *text, u
|
||||
conference->sh = NULL;
|
||||
}
|
||||
|
||||
if (!tts_engine) {
|
||||
tts_engine = conference->tts_engine;
|
||||
}
|
||||
|
||||
if (!tts_voice) {
|
||||
tts_voice = conference->tts_voice;
|
||||
}
|
||||
|
||||
if (zstr(tts_engine) || zstr(tts_voice)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing TTS engine or voice\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!conference->sh) {
|
||||
memset(&conference->lsh, 0, sizeof(conference->lsh));
|
||||
if (switch_core_speech_open(&conference->lsh, conference->tts_engine, conference->tts_voice,
|
||||
if (switch_core_speech_open(&conference->lsh, tts_engine, tts_voice,
|
||||
conference->rate, conference->interval, channels, &flags, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
@ -1005,7 +1022,7 @@ switch_status_t conference_say(conference_obj_t *conference, const char *text, u
|
||||
switch_core_speech_text_param_tts(fnode->sh, "voice", voice);
|
||||
}
|
||||
} else {
|
||||
switch_core_speech_text_param_tts(fnode->sh, "voice", conference->tts_voice);
|
||||
switch_core_speech_text_param_tts(fnode->sh, "voice", tts_voice);
|
||||
}
|
||||
|
||||
/* Begin Generation */
|
||||
|
Loading…
x
Reference in New Issue
Block a user