Пример #1
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;
}
Пример #2
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
Пример #3
0
void MakeVowelLists(void)
{//======================
// For each phoneme table, make a list of its vowels and their
// formant frequencies (f1,f2,f3) for use by VowelChart()

	int table;
	int ix;
	int phcode;
	PHONEME_TAB *ph;
	FILE *f;
	FILE *f_prog_log;
	SPECT_SEQ *seq;
	SPECT_SEQK *seqk;
	frame_t *frame;
	int n_prog_log;
	int vowelfmt_ix;
	int colour;
	int voice_found;
	PHONEME_PROG_LOG *prog_log_table;
	PHONEME_PROG_LOG *found_prog;
	PHONEME_PROG_LOG this_prog;
	char dirname[sizeof(path_source)+20];
	char fname[sizeof(dirname)+40];
	char save_voice_name[80];

	strcpy(save_voice_name,voice_name2);

	sprintf(fname,"%s%s",path_source,"compile_prog_log");
	if((f_prog_log = fopen(fname,"rb")) == NULL)
	{
		wxLogError(_T("Can't read 'compile_prog_log;"));
		return;
	}
	ix = GetFileLength(fname);
	prog_log_table = (PHONEME_PROG_LOG *)malloc(ix);
	if(prog_log_table == NULL)
	{
		fclose(f_prog_log);
		return;
	}
	ix = fread(prog_log_table, 1, ix, f_prog_log);
	fclose(f_prog_log);
	n_prog_log = ix / sizeof(PHONEME_PROG_LOG);

	progress = new wxProgressDialog(_T("Vowel charts"),_T(""),n_phoneme_tables);

	sprintf(dirname,"%s%s",path_source,"vowelcharts");
	mkdir(dirname,S_IRWXU | S_IRGRP | S_IROTH);

	sprintf(fname,"%s/vowel_log",dirname);

	for(table=0; table<n_phoneme_tables; table++)
	{
		sprintf(fname,"%s/%s",dirname,phoneme_tab_list[table].name);
		if((f = fopen(fname,"w"))==NULL) continue;

		progress->Update(table);

		// select the phoneme table by name
//		if(SetVoiceByName(phoneme_tab_list[table].name) != 0) continue;
		if(SelectPhonemeTableName(phoneme_tab_list[table].name) < 0)
		{
			fclose(f);
			continue;
		}

		voice_found = 0;
		if((LoadVoice(phoneme_tab_list[table].name, 0) != NULL) && (translator->data_dictrules != NULL))
		{
			voice_found = 1;
			FindPhonemesUsed();
		}

		// phoneme table is terminated by a phoneme with no name (=0)
		for(phcode=1; phcode < n_phoneme_tab; phcode++)
		{
			ph = phoneme_tab[phcode];

			if((ph==NULL) || (ph->type != phVOWEL) || (ph->program == 0))
				continue;

			if(voice_found && (phoneme_tab_flags[phcode] & 3) == 0)
			{
				continue;   // inherited, and not used 
			}

			// find the size of this program
			this_prog.addr = ph->program;
			found_prog = (PHONEME_PROG_LOG *)bsearch((void *)&this_prog, (void *)prog_log_table, n_prog_log, sizeof(PHONEME_PROG_LOG), (int(*)(const void *,const void *))prog_log_sorter);

			FindVowelFmt(ph->program, found_prog->length);

			for(vowelfmt_ix=0; vowelfmt_ix < n_vowelfmt_addr; vowelfmt_ix++)
			{
				ix = vowelfmt_addr[vowelfmt_ix];

				seq = (SPECT_SEQ *)(&phondata_ptr[ix]);
				seqk = (SPECT_SEQK *)seq;
	
				if(seq->frame[0].frflags & FRFLAG_KLATT)
					frame = &seqk->frame[1];
				else
					frame = (frame_t *)&seq->frame[1];

				if((n_vowelfmt_addr - vowelfmt_ix) == 1)
					colour = 0;
				else
					colour = 1;

				fprintf(f,"%s\t %d %3d %4d %4d",WordToString(ph->mnemonic), colour,
						frame->ffreq[1],frame->ffreq[2],frame->ffreq[3]);
	
				if(seq->frame[0].frflags & FRFLAG_KLATT)
					frame = &seqk->frame[seqk->n_frames-1];
				else
					frame = (frame_t *)&seq->frame[seq->n_frames-1];
				fprintf(f,"   %3d %4d %4d\n",frame->ffreq[1],frame->ffreq[2],frame->ffreq[3]);
			}
		}
		fclose(f);

		VowelChart(1,fname);  // draw the vowel chart
	}
	free(prog_log_table);
	LoadVoice(voice_name2,0);  // reset the original phoneme table
	delete progress;
	LoadVoiceVariant(save_voice_name,0);
}