\param session the session to speak on
\param tts_name the desired tts module
\param voice_name the desired voice
- \param rate the sample rate
\param text the text to speak
\param args arguements to pass for callbacks etc
\return SWITCH_STATUS_SUCCESS if all is well
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session,
- char *tts_name, char *voice_name, uint32_t rate, char *text, switch_input_args_t *args);
+ char *tts_name, char *voice_name, char *text, switch_input_args_t *args);
/*!
\brief Make an outgoing call
if (!(conference->tts_engine && conference->tts_voice)) {
status = SWITCH_STATUS_FALSE;
} else {
- status = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, 0, path + 4, NULL);
+ status = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, path + 4, NULL);
}
goto done;
}
args.input_callback = on_dtmf;
args.buf = buf;
args.buflen = sizeof(buf);
- switch_ivr_speak_text(session, engine, voice, codec->implementation->samples_per_second, text, &args);
+ switch_ivr_speak_text(session, engine, voice, text, &args);
}
args.input_callback = show_dtmf;
args.buf = buf;
args.buflen = sizeof(buf);
- switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, &args);
+ switch_ivr_speak_text(session, tts_name, voice_name, text, &args);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Done\n");
}
}
snprintf(say, sizeof(say), "You Dialed [%s]\n", buf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, say);
- switch_ivr_speak_text(session, "cepstral", "david", codec->implementation->samples_per_second, say, NULL);
+ switch_ivr_speak_text(session, "cepstral", "david", say, NULL);
}
}
int CoreSession::speak(char *text)
{
switch_status_t status;
- switch_codec_t *codec;
sanity_check(-1);
return SWITCH_STATUS_FALSE;
}
- codec = switch_core_session_get_read_codec(session);
+
begin_allow_threads();
- status = switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, ap);
+ status = switch_ivr_speak_text(session, tts_name, voice_name, text, ap);
end_allow_threads();
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
} else {
if (strlen(sound) > 4 && strncmp(sound, "say:", 4) == 0) {
if (menu->tts_engine && menu->tts_voice) {
- status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, 0, sound + 4, &args);
+ status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, sound + 4, &args);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No TTS engine to play sound\n");
}
status = switch_ivr_play_file(session, NULL, aptr, NULL);
break;
case SWITCH_IVR_ACTION_SAYTEXT:
- status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, 0, aptr, NULL);
+ status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, aptr, NULL);
break;
case SWITCH_IVR_ACTION_SAYPHRASE:
status = switch_ivr_phrase_macro(session, aptr, "", menu->phrase_lang, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", chan_lang);
}
} else if (!strcasecmp(func, "speak-text")) {
- switch_codec_t *read_codec;
- if ((read_codec = switch_core_session_get_read_codec(session))) {
-
- status = switch_ivr_speak_text(session, tts_engine, tts_voice, read_codec->implementation->samples_per_second, odata, args);
- }
+ status = switch_ivr_speak_text(session, tts_engine, tts_voice, odata, args);
}
}
}
SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session,
- char *tts_name, char *voice_name, uint32_t rate, char *text, switch_input_args_t *args)
+ char *tts_name, char *voice_name, char *text, switch_input_args_t *args)
{
switch_channel_t *channel;
+ uint32_t rate = 0;
int interval = 0;
switch_frame_t write_frame = { 0 };
switch_timer_t timer;
switch_core_session_reset(session);
read_codec = switch_core_session_get_read_codec(session);
- if (rate == 0) {
- rate = read_codec->implementation->samples_per_second;
- }
+ rate = read_codec->implementation->samples_per_second;
+ interval = read_codec->implementation->microseconds_per_frame / 1000;
memset(&sh, 0, sizeof(sh));
if (switch_core_speech_open(&sh, tts_name, voice_name, (uint32_t) rate, interval,
switch_channel_answer(channel);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OPEN TTS %s\n", tts_name);
- interval = read_codec->implementation->microseconds_per_frame / 1000;
+
codec_name = "L16";
if (switch_core_codec_init(&codec,
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
-int fs_switch_ivr_speak_text(switch_core_session_t *session, char *tts_name, char *voice_name, uint32_t rate, char *text)
+int fs_switch_ivr_speak_text(switch_core_session_t *session, char *tts_name, char *voice_name, char *text)
{
switch_status_t status;
- status = switch_ivr_speak_text(session, tts_name, voice_name, rate, text, NULL);
+ status = switch_ivr_speak_text(session, tts_name, voice_name, text, NULL);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}