コード例 #1
0
static void cepstral_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val)
{
	cepstral_t *cepstral;

	cepstral = sh->private_info;
	assert(cepstral != NULL);

	if (!strcasecmp(param, "voice")) {
		const char *voice_name = val;
		if (!strcasecmp(voice_name, "next")) {
			if ((cepstral->voice = swift_port_find_next_voice(cepstral->port))) {
				if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
					cepstral->done = cepstral->done_gen = 1;
					return;
				}
				voice_name = swift_voice_get_attribute(cepstral->voice, "name");
			} else {
				voice_name = NULL;
			}
		} else {
			if (voice_name && SWIFT_FAILED(swift_port_set_voice_by_name(cepstral->port, voice_name))) {
				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid voice %s!\n", voice_name);
				voice_name = NULL;
			}
		}

		if (!voice_name) {
			/* Find the first voice on the system */
			if ((cepstral->voice = swift_port_find_first_voice(cepstral->port, NULL, NULL)) == NULL) {
				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find any voices!\n");
				cepstral->done = cepstral->done_gen = 1;
				return;
			}

			/* Set the voice found by find_first_voice() as the port's current voice */
			if (SWIFT_FAILED(swift_port_set_voice(cepstral->port, cepstral->voice))) {
				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set voice.\n");
				cepstral->done = cepstral->done_gen = 1;
				return;
			}

			voice_name = swift_voice_get_attribute(cepstral->voice, "name");
		}

		if (voice_name) {
			switch_copy_string(sh->voice, voice_name, sizeof(sh->voice));
		}

		return;
	}

	swift_port_set_param_string(cepstral->port, param, val, NULL);
}
コード例 #2
0
ファイル: mrcp_swift.c プロジェクト: Deepwalker/FreeSWITCH
/** Scan Swift available voices */
static apt_bool_t mrcp_swift_voices_scan(mrcp_swift_engine_t *engine)
{
	swift_port *port;
	swift_voice *voice;
	const char *license_status;
	const char *sample_rate;

	if(!engine->swift) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Invalid Swift Engine");
		return FALSE;
	}

	/* open swift port*/
	if((port = swift_port_open(engine->swift, NULL)) == NULL) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open Swift Port");
		return FALSE;
	}

	engine->sample_rates = MPF_SAMPLE_RATE_NONE;

	/* find the first voice on the system */
	if((voice = swift_port_find_first_voice(port, NULL, NULL)) == NULL) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"No Swift Voice Available");
		swift_port_close(port);
		return FALSE;
	}
	/* go through all of the voices on the system and print some info about each */
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Swift Available Voices:");
	for(; voice; voice = swift_port_find_next_voice(port)) {
		if(swift_voice_get_attribute(voice, "license/key")) {
			license_status = "licensed";
		}
		else {
			license_status = "unlicensed";
		}
		sample_rate = swift_voice_get_attribute(voice, "sample-rate");
		apt_log(APT_LOG_MARK,APT_PRIO_INFO,"%s: %s, age %s, %s, %sHz, %s, %s",
			swift_voice_get_attribute(voice, "name"),
			swift_voice_get_attribute(voice, "speaker/gender"),
			swift_voice_get_attribute(voice, "speaker/age"),
			swift_voice_get_attribute(voice, "language/name"),
			sample_rate,
			swift_voice_get_attribute(voice, "version"),
			license_status);

		mrcp_swift_sample_rates_set(engine,sample_rate);
	}

	swift_port_close(port);
	return TRUE;
}
コード例 #3
0
ファイル: mrcp_swift.c プロジェクト: Jared-Prime/UniMRCP
/** Show Swift available voices */
static void mrcp_swift_voices_show(swift_engine *engine) 
{
	swift_port *port;
	swift_voice *voice;
	const char *license_status;

	/* open swift port*/
	if((port = swift_port_open(engine, NULL)) == NULL) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Open Swift Port");
		return;    
	}

	/* find the first voice on the system */
	if((voice = swift_port_find_first_voice(port, NULL, NULL)) == NULL) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"No Swift Voice Available");
		swift_port_close(port);
		return;
	}
	/* go through all of the voices on the system and print some info about each */
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Swift Available Voices:");
	for(; voice; voice = swift_port_find_next_voice(port)) {
		if(swift_voice_get_attribute(voice, "license/key")) {
			license_status = "licensed";
		}
		else {
			license_status = "unlicensed";
		}
		apt_log(APT_LOG_MARK,APT_PRIO_INFO,"%s: %s, age %s, %s, %sHz, %s",
			swift_voice_get_attribute(voice, "name"),
			swift_voice_get_attribute(voice, "speaker/gender"),
			swift_voice_get_attribute(voice, "speaker/age"),
			swift_voice_get_attribute(voice, "language/name"),
			swift_voice_get_attribute(voice, "sample-rate"),
			license_status);
	}

	swift_port_close(port);
}