Exemplo n.º 1
0
espeak_ERROR SetVoiceByName(const char *name)
{//=========================================
	espeak_VOICE *v;
	int ix;
	espeak_VOICE voice_selector;
	char *variant_name;
	static char buf[60];

	strncpy0(buf,name,sizeof(buf));

	variant_name = ExtractVoiceVariantName(buf, 0, 1);

	for(ix=0; ; ix++)
	{
		// convert voice name to lower case  (ascii)
		if((buf[ix] = tolower(buf[ix])) == 0)
			break;
	}

	memset(&voice_selector,0,sizeof(voice_selector));
	voice_selector.name = (char *)name;  // include variant name in voice stack ??

	// first check for a voice with this filename
	// This may avoid the need to call espeak_ListVoices().

	if(LoadVoice(buf,1) != NULL)
	{
		if(variant_name[0] != 0)
		{
			LoadVoice(variant_name,2);
		}

		DoVoiceChange(voice);
		voice_selector.languages = voice->language_name;
		SetVoiceStack(&voice_selector, variant_name);
		return(EE_OK);
	}

	if(n_voices_list == 0)
		espeak_ListVoices(NULL);   // create the voices list

	if((v = SelectVoiceByName(voices_list,buf)) != NULL)
	{
		if(LoadVoice(v->identifier,0) != NULL)
		{
			if(variant_name[0] != 0)
			{
				LoadVoice(variant_name,2);
			}
			DoVoiceChange(voice);
			voice_selector.languages = voice->language_name;
			SetVoiceStack(&voice_selector, variant_name);
			return(EE_OK);
		}
	}
	return(EE_INTERNAL_ERROR);   // voice name not found
}  // end of SetVoiceByName
Exemplo n.º 2
0
ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path, int options)
{//=============================================================================================================
ENTER("espeak_Initialize");
	int param;

	// It seems that the wctype functions don't work until the locale has been set
	// to something other than the default "C".  Then, not only Latin1 but also the
	// other characters give the correct results with iswalpha() etc.
#ifdef PLATFORM_RISCOS
	setlocale(LC_CTYPE,"ISO8859-1");
#else
	if(setlocale(LC_CTYPE,"en_US.UTF-8") == NULL)
	{
		if(setlocale(LC_CTYPE,"UTF-8") == NULL)
			setlocale(LC_CTYPE,"");
	}
#endif
	
	init_path(path);
	initialise();
	select_output(output_type);
	
	// buflength is in mS, allocate 2 bytes per sample
	if(buf_length == 0)
		buf_length = 200;
	outbuf_size = (buf_length * samplerate)/500;
	outbuf = (unsigned char*)realloc(outbuf,outbuf_size);
	if((out_start = outbuf) == NULL)
		return(EE_INTERNAL_ERROR);
	
	// allocate space for event list.  Allow 200 events per second.
	// Add a constant to allow for very small buf_length
	n_event_list = (buf_length*200)/1000 + 20;
	if((event_list = (espeak_EVENT *)realloc(event_list,sizeof(espeak_EVENT) * n_event_list)) == NULL)
		return(EE_INTERNAL_ERROR);
	
	option_phonemes = 0;
	option_phoneme_events = (options & 1);

	SetVoiceByName("default");
	
	for(param=0; param<N_SPEECH_PARAM; param++)
		param_stack[0].parameter[param] = param_defaults[param];
	
	SetParameter(espeakRATE,170,0);
	SetParameter(espeakVOLUME,100,0);
	SetParameter(espeakCAPITALS,option_capitals,0);
	SetParameter(espeakPUNCTUATION,option_punctuation,0);
	SetParameter(espeakWORDGAP,0,0);
	DoVoiceChange(voice);
	
#ifdef USE_ASYNC
	fifo_init();
#endif

  return(samplerate);
}
Exemplo n.º 3
0
static void espeakdata_SetVoiceByName (const char *name, const char *variantName)
{
	espeak_VOICE voice_selector;

	memset (& voice_selector, 0, sizeof voice_selector);
	voice_selector.name = Melder_peek32to8 (Melder_cat (Melder_peek8to32 (name), U"+", Melder_peek8to32 (variantName)));  // include variant name in voice stack ??

	if (LoadVoice (name, 1)) {
		LoadVoice (variantName, 2);
		DoVoiceChange (voice);
		SetVoiceStack (& voice_selector, variantName);
	}
}
Exemplo n.º 4
0
ESPEAK_NG_API espeak_ng_STATUS espeak_ng_SetVoiceByProperties(espeak_VOICE *voice_selector)
{
	const char *voice_id;
	int voice_found;

	voice_id = SelectVoice(voice_selector, &voice_found);
	if (voice_found == 0)
		return ENS_VOICE_NOT_FOUND;

	LoadVoiceVariant(voice_id, 0);
	DoVoiceChange(voice);
	SetVoiceStack(voice_selector, "");

	return ENS_OK;
}
Exemplo n.º 5
0
espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector)
{//============================================================
	const char *voice_id;
	int voice_found;

	voice_id = SelectVoice(voice_selector, &voice_found);

	if(voice_found == 0)
		return(EE_NOT_FOUND);

	LoadVoiceVariant(voice_id,0);
	DoVoiceChange(voice);
	SetVoiceStack(voice_selector, "");

	return(EE_OK);
}  //  end of SetVoiceByProperties