Пример #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
Пример #2
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);
	}
}
Пример #3
0
voice_t *LoadVoiceVariant(const char *vname, int variant_num)
{
	// Load a voice file.
	// Also apply a voice variant if specified by "variant", or by "+number" or "+name" in the "vname"

	voice_t *v;
	char *variant_name;
	char buf[60];

	strncpy0(buf, vname, sizeof(buf));
	variant_name = ExtractVoiceVariantName(buf, variant_num, 1);

	if ((v = LoadVoice(buf, 0)) == NULL)
		return NULL;

	if (variant_name[0] != 0)
		v = LoadVoice(variant_name, 2);
	return v;
}
Пример #4
0
int CFITOM::LoadVoiceConfig(FILE* fp)
{
	int ret = 0;
	TCHAR tmp[512];
	TCHAR filename[MAX_PATH];
	TCHAR bankname[80];
	TCHAR devname[80];
	int bank;
	while(fgets(tmp, 80, fp) != NULL) {
		sscanf(tmp, _T(" %[^:] : %i : %[^:,\n] , %[^\n]"), devname, &bank, filename, bankname);
		UINT8 vtype = GetVoiceType(GetDeviceIDFromName(devname));
		switch (vtype) {
		case VOICE_TYPE_OPN:
		case VOICE_TYPE_OPNA:
			if (bank < MAX_BANK) {
				fprintf(stderr, _T("Loading OPN/OPN2/OPNA voice bank \"%s\"\n"), filename);
				LoadVoice(vtype, bank, opnabank, filename, bankname);
			}
			break;
		case VOICE_TYPE_OPM:
			if (bank < MAX_BANK) {
				fprintf(stderr, _T("Loading OPM voice bank \"%s\"\n"), filename);
				LoadVoice(vtype, bank, opmbank, filename, bankname);
			}
			break;
		case VOICE_TYPE_OPL3:
			if (bank < MAX_BANK) {
				fprintf(stderr, _T("Loading OPL3(4op) voice bank \"%s\"\n"), filename);
				LoadVoice(vtype, bank, opl3bank, filename, bankname);
			}
			break;
		case VOICE_TYPE_OPL2:
			if (bank < MAX_BANK) {
				fprintf(stderr, _T("Loading OPL/OPL2 voice bank \"%s\"\n"), filename);
				LoadVoice(vtype, bank, opl2bank, filename, bankname);
			}
			break;
		case VOICE_TYPE_OPLL:
			if (bank < MAX_BANK) {
				fprintf(stderr, _T("Loading OPLL voice bank \"%s\"\n"), filename);
				LoadVoice(vtype, bank, opllbank, filename, bankname);
			}
			break;
		case VOICE_TYPE_SSG:
			if (bank == 0) {
				fprintf(stderr, "Loading PSG voice bank \"%s\"\n", filename);
				LoadVoice(vtype, bank, psgbank, filename, bankname);
			}
			break;
		default:
			if ((lstrcmp(_T("SSGDRUM:"), devname) == 0 ||
				lstrcmp(_T("PSGDRUM"), devname) == 0)) {
			}
			if (lstrcmp(_T("RHYTHM"), devname) == 0) {
				fprintf(stderr, _T("Loading Rhythm bank \"%s\"\n"), filename);
				LoadDrumMap(bank, filename, bankname);
			}
			break;
		}
	}
	return ret;
}
Пример #5
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);
}
Пример #6
0
// Initialise this in OnInit, not statically
bool MyApp::OnInit(void)
{//=====================

int j;
const wxChar *p;
char param[120];


if(argc > 1)
{
	p = argv[1];
	j = 0;
	while((param[j] = p[j]) != 0) j++;

	if((strcmp(param,"--help")==0) || (strcmp(param,"-h")==0))
	{
		printf(about_string2,espeak_Info(NULL));
		printf("%s", help_text);
		exit(0);
	}

	ConfigInit(true);

	if(strcmp(param,"--compile")==0)
	{
        samplerate_native = samplerate = 22050;
	    LoadPhData(NULL);
		if(LoadVoice("", 0) == NULL)
		{
			fprintf(stderr, "Failed to load default voice\n");
			exit(1);
		}
		CompilePhonemeData();
		CompileIntonation();
	}
    exit(0);
}

	ConfigInit(false);
	gui_flag = 1;
	// 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.
	if(setlocale(LC_CTYPE,"en_US.UTF-8") == NULL)
	{
		if(setlocale(LC_CTYPE,"UTF-8") == NULL)
			setlocale(LC_CTYPE,"");
	}

	if((frame_w == 0) || (frame_h == 0))
	{
		frame_w = 800;
		frame_h = 768;
	}

  // Create the main frame window
	myframe = new MyFrame(NULL, -1, AppName, wxPoint(frame_x, frame_y), wxSize(frame_w, frame_h),
                      wxDEFAULT_FRAME_STYLE |
                      wxNO_FULL_REPAINT_ON_RESIZE |
                      wxHSCROLL | wxVSCROLL);


	// Make a menubar
	myframe->SetMenuBar(MakeMenu(0, voice_name2));
	myframe->CreateStatusBar();
	myframe->SetVoiceTitle(voice_name2);

//	myframe->Maximize();
	myframe->Show(TRUE);

	SetTopWindow(myframe);
	wxInitAllImageHandlers();
//	wxImage::AddHandler(wxPNGHandler);
	wxLogStatus(_T("Using espeak_data at: ")+wxString(path_home, wxConvLocal));
  return TRUE;
}