| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2005 to 2014 by Jonathan Duddington * | * Copyright (C) 2005 to 2014 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2013 by Reece H. Dunn * | |||||
| * Copyright (C) 2013-2015 by Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| if(stream.Ok() == FALSE) | if(stream.Ok() == FALSE) | ||||
| { | { | ||||
| error("Failed to open: '%s'",path); | error("Failed to open: '%s'",path); | ||||
| delete spectseq; | |||||
| return(0); | return(0); | ||||
| } | } | ||||
| spectseq->Load(stream); | spectseq->Load(stream); | ||||
| if(spectseq->frames == NULL) | if(spectseq->frames == NULL) | ||||
| { | { | ||||
| error("Bad vowel file, no frames: '%s'",path); | error("Bad vowel file, no frames: '%s'",path); | ||||
| delete spectseq; | |||||
| return(0); | return(0); | ||||
| } | } | ||||
| { | { | ||||
| fclose(f_in); | fclose(f_in); | ||||
| fclose(f_errors); | fclose(f_errors); | ||||
| free(tune_data); | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| fwrite(tune_data, n_tune_names, sizeof(TUNE), f_out); | fwrite(tune_data, n_tune_names, sizeof(TUNE), f_out); | ||||
| free(tune_data); | |||||
| fclose(f_in); | fclose(f_in); | ||||
| fclose(f_out); | fclose(f_out); | ||||
| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2005 to 2014 by Jonathan Duddington * | * Copyright (C) 2005 to 2014 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2015 by Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| return(-1); | return(-1); | ||||
| } | } | ||||
| fprintf(f_log,"Compiling: '%s'\n",fname); | |||||
| if(f_log != NULL) | |||||
| fprintf(f_log,"Compiling: '%s'\n",fname); | |||||
| linenum=0; | linenum=0; | ||||
| count++; | count++; | ||||
| } | } | ||||
| fprintf(f_log,"\t%d entries\n",count); | |||||
| if(f_log != NULL) | |||||
| fprintf(f_log,"\t%d entries\n",count); | |||||
| fclose(f_in); | fclose(f_in); | ||||
| return(0); | return(0); | ||||
| } /* end of compile_dictlist_file */ | } /* end of compile_dictlist_file */ | ||||
| { | { | ||||
| if(fname_err) | if(fname_err) | ||||
| strcpy(fname_err,fname_out); | strcpy(fname_err,fname_out); | ||||
| fclose(f_in); | |||||
| return(-1); | return(-1); | ||||
| } | } | ||||
| sprintf(fname_temp,"%s%ctemp",path_home,PATHSEP); | sprintf(fname_temp,"%s%ctemp",path_home,PATHSEP); |
| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2005 to 2014 by Jonathan Duddington * | * Copyright (C) 2005 to 2014 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2013 Reece H. Dunn * | |||||
| * Copyright (C) 2013-2015 Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| { | { | ||||
| fprintf(stderr,"Can't read dictionary file: '%s'\n",fname); | fprintf(stderr,"Can't read dictionary file: '%s'\n",fname); | ||||
| } | } | ||||
| if (f != NULL) | |||||
| fclose(f); | |||||
| return(1); | return(1); | ||||
| } | } | ||||
| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2005 to 2015 by Jonathan Duddington * | * Copyright (C) 2005 to 2015 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2013 by Reece H. Dunn * | |||||
| * Copyright (C) 2013-2015 by Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| "\tCompile phoneme data in espeak-data/phsource\n" | "\tCompile phoneme data in espeak-data/phsource\n" | ||||
| "\tand dictionary data in espeak-data/dictsource\n"; | "\tand dictionary data in espeak-data/dictsource\n"; | ||||
| // Initialise this in OnInit, not statically | // Initialise this in OnInit, not statically | ||||
| bool MyApp::OnInit(void) | bool MyApp::OnInit(void) | ||||
| {//===================== | {//===================== | ||||
| int j; | int j; | ||||
| const wxChar *p; | |||||
| char param[120]; | char param[120]; | ||||
| if(argc > 1) | if(argc > 1) | ||||
| { | { | ||||
| p = argv[1]; | |||||
| j = 0; | |||||
| #if wxUSE_UNICODE == 1 | |||||
| wcstombs(param, argv[1], sizeof(param)); | |||||
| #else | |||||
| const char *p = argv[1]; | |||||
| while((param[j] = p[j]) != 0) j++; | while((param[j] = p[j]) != 0) j++; | ||||
| #endif | |||||
| if((strcmp(param,"--help")==0) || (strcmp(param,"-h")==0)) | if((strcmp(param,"--help")==0) || (strcmp(param,"-h")==0)) | ||||
| { | { | ||||
| char buf[300]; | char buf[300]; | ||||
| wxString url_docs; | wxString url_docs; | ||||
| wxBoxSizer *topsizer; | |||||
| HtmlWindow *html; | |||||
| wxDialog dlg(this, wxID_ANY, wxString(_("About"))); | |||||
| topsizer = new wxBoxSizer(wxVERTICAL); | |||||
| switch(event.GetId()) | switch(event.GetId()) | ||||
| { | { | ||||
| case MENU_ABOUT: | case MENU_ABOUT: | ||||
| { | { | ||||
| wxDialog dlg(this, wxID_ANY, wxString(_("About"))); | |||||
| sprintf(buf,about_string,espeak_Info(NULL)); | sprintf(buf,about_string,espeak_Info(NULL)); | ||||
| html = new HtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER); | |||||
| HtmlWindow *html = new HtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER); | |||||
| html -> SetBorders(0); | html -> SetBorders(0); | ||||
| html -> SetPage(wxString(buf,wxConvLocal)); | html -> SetPage(wxString(buf,wxConvLocal)); | ||||
| html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(), | html -> SetSize(html -> GetInternalRepresentation() -> GetWidth(), | ||||
| html -> GetInternalRepresentation() -> GetHeight()); | html -> GetInternalRepresentation() -> GetHeight()); | ||||
| wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); | |||||
| topsizer -> Add(html, 1, wxALL, 10); | topsizer -> Add(html, 1, wxALL, 10); | ||||
| //#if wxUSE_STATLINE | //#if wxUSE_STATLINE |
| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2006 to 2011 by Jonathan Duddington * | * Copyright (C) 2006 to 2011 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2013 by Reece H. Dunn * | |||||
| * Copyright (C) 2013-2015 by Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| { | { | ||||
| str = wxString(buf, wxConvLocal); | str = wxString(buf, wxConvLocal); | ||||
| wxLogError(_T("Can't write file: ") + str); | wxLogError(_T("Can't write file: ") + str); | ||||
| fclose(f_in); | |||||
| return; | return; | ||||
| } | } | ||||
| f_listx = fopen(buf,"w"); | f_listx = fopen(buf,"w"); | ||||
| wxLogStatus(_T("Pass 1")); | wxLogStatus(_T("Pass 1")); | ||||
| } | } | ||||
| else | |||||
| else if(pass == 2) | |||||
| { | { | ||||
| CompileDictionary(path_dsource,"it",NULL,NULL,0); | CompileDictionary(path_dsource,"it",NULL,NULL,0); | ||||
| sprintf(buf,"%s/it_listx2",path_dsource); | sprintf(buf,"%s/it_listx2",path_dsource); | ||||
| if((f_out = fopen("compare_de","w")) == NULL) | if((f_out = fopen("compare_de","w")) == NULL) | ||||
| { | { | ||||
| wxLogError(_T("Can't write file ")); | wxLogError(_T("Can't write file ")); | ||||
| fclose(f_out); | |||||
| return; | return; | ||||
| } | } | ||||
| LoadVoice("de",0); | LoadVoice("de",0); | ||||
| free(p); | free(p); | ||||
| } | } | ||||
| fclose(f_out); | fclose(f_out); | ||||
| free(w_list); | |||||
| } // end of Make WorkFreqList | } // end of Make WorkFreqList | ||||
| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2005 to 2014 by Jonathan Duddington * | * Copyright (C) 2005 to 2014 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2015 by Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| } | } | ||||
| if((manifest = (NAMETAB *)realloc(manifest, n_lines * sizeof(NAMETAB))) == NULL) | if((manifest = (NAMETAB *)realloc(manifest, n_lines * sizeof(NAMETAB))) == NULL) | ||||
| { | |||||
| fclose(f); | |||||
| return; | return; | ||||
| } | |||||
| n_manifest = 0; | n_manifest = 0; | ||||
| while(fgets(buf, sizeof(buf), f) != NULL) | while(fgets(buf, sizeof(buf), f) != NULL) |
| if(cy.flags & 0x04) | if(cy.flags & 0x04) | ||||
| markers |= 8; | markers |= 8; | ||||
| spect_data = new USHORT[nx]; | |||||
| if(spect_data == NULL) | |||||
| if(nx>0) | |||||
| { | { | ||||
| wxLogError(_T("Failed to allocate memory")); | |||||
| return(1); | |||||
| } | |||||
| spect_data = new USHORT[nx]; | |||||
| max_y = 0; | |||||
| for(ix=0; ix<nx; ix++) | |||||
| { | |||||
| spect_data[ix] = p->data[ix]; | |||||
| if(spect_data[ix] > max_y) | |||||
| max_y = spect_data[ix]; | |||||
| if(spect_data == NULL) | |||||
| { | |||||
| wxLogError(_T("Failed to allocate memory")); | |||||
| return(1); | |||||
| } | |||||
| max_y = 0; | |||||
| for(ix=0; ix<nx; ix++) | |||||
| { | |||||
| spect_data[ix] = p->data[ix]; | |||||
| if(spect_data[ix] > max_y) | |||||
| max_y = spect_data[ix]; | |||||
| } | |||||
| } | } | ||||
| if(nx==0) | |||||
| else | |||||
| { | { | ||||
| nx = int(8000/dx); | nx = int(8000/dx); | ||||
| spect_data = new USHORT[nx]; | spect_data = new USHORT[nx]; | ||||
| if(spect_data == NULL) | |||||
| { | |||||
| wxLogError(_T("Failed to allocate memory")); | |||||
| return(1); | |||||
| } | |||||
| for(ix=0; ix<nx; ix++) | for(ix=0; ix<nx; ix++) | ||||
| spect_data[ix] = 1; | spect_data[ix] = 1; | ||||
| max_y = 1; | max_y = 1; |
| if(stream.Ok() == FALSE) | if(stream.Ok() == FALSE) | ||||
| { | { | ||||
| wxLogError(_T("Failed to open '%s'"),filename.c_str()); | wxLogError(_T("Failed to open '%s'"),filename.c_str()); | ||||
| delete spectseq; | |||||
| return; | return; | ||||
| } | } | ||||
| wxFileName path = wxFileName(filename); | wxFileName path = wxFileName(filename); |
| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2005 to 2007 by Jonathan Duddington * | * Copyright (C) 2005 to 2007 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2013 Reece H. Dunn * | |||||
| * Copyright (C) 2013-2015 Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| if(import==1) | if(import==1) | ||||
| { | { | ||||
| if(frame->Import(stream) != 0) break; | |||||
| if(frame->Import(stream) != 0) | |||||
| { | |||||
| delete frame; | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| else | else | ||||
| if(import==2) | if(import==2) | ||||
| { | { | ||||
| if(frame->ImportSPC2(stream,time_acc) != 0) break; | |||||
| if(frame->ImportSPC2(stream,time_acc) != 0) | |||||
| { | |||||
| delete frame; | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if(frame->Load(stream, file_format) != 0) break; | |||||
| if(frame->Load(stream, file_format) != 0) | |||||
| { | |||||
| delete frame; | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| frames[numframes++] = frame; | frames[numframes++] = frame; |
| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2005 to 2014 by Jonathan Duddington * | * Copyright (C) 2005 to 2014 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2015 by Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| if(fread(p,1,length,f_in) != length) | if(fread(p,1,length,f_in) != length) | ||||
| { | { | ||||
| fclose(f_in); | fclose(f_in); | ||||
| Free(p); | |||||
| return(NULL); | return(NULL); | ||||
| } | } | ||||
| if(memcmp(buf,"log",3)==0) | if(memcmp(buf,"log",3)==0) | ||||
| { | { | ||||
| if(sscanf(&buf[4],"%d %s",&logging_type,string)==2) | if(sscanf(&buf[4],"%d %s",&logging_type,string)==2) | ||||
| { | |||||
| if (f_logespeak) | |||||
| fclose(f_logespeak); | |||||
| f_logespeak = fopen(string,"w"); | f_logespeak = fopen(string,"w"); | ||||
| } | |||||
| } | } | ||||
| else | else | ||||
| if(memcmp(buf,"tone",4)==0) | if(memcmp(buf,"tone",4)==0) |
| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2005 to 2015 by Jonathan Duddington * | * Copyright (C) 2005 to 2015 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2015 by Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| new_translator->dict_min_size = dict_min; | new_translator->dict_min_size = dict_min; | ||||
| LoadDictionary(new_translator, new_dictionary, control & 4); | LoadDictionary(new_translator, new_dictionary, control & 4); | ||||
| if(dictionary_name[0]==0) | if(dictionary_name[0]==0) | ||||
| { | |||||
| DeleteTranslator(new_translator); | |||||
| return(NULL); // no dictionary loaded | return(NULL); // no dictionary loaded | ||||
| } | |||||
| new_translator->dict_condition = conditional_rules; | new_translator->dict_condition = conditional_rules; | ||||
| /*************************************************************************** | /*************************************************************************** | ||||
| * Copyright (C) 2005 to 2013 by Jonathan Duddington * | * Copyright (C) 2005 to 2013 by Jonathan Duddington * | ||||
| * email: [email protected] * | * email: [email protected] * | ||||
| * Copyright (C) 2013 Reece H. Dunn * | |||||
| * Copyright (C) 2013-2015 Reece H. Dunn * | |||||
| * * | * * | ||||
| * This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | ||||
| * it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | ||||
| if(stream.Ok() == FALSE) | if(stream.Ok() == FALSE) | ||||
| { | { | ||||
| path = wxFindNextFile(); | path = wxFindNextFile(); | ||||
| delete spectseq; | |||||
| continue; | continue; | ||||
| } | } | ||||
| spectseq->Load(stream); | spectseq->Load(stream); | ||||
| filename.SetExt(_T("png")); | filename.SetExt(_T("png")); | ||||
| bitmap->SaveFile(filename.GetFullPath(),wxBITMAP_TYPE_PNG); | bitmap->SaveFile(filename.GetFullPath(),wxBITMAP_TYPE_PNG); | ||||
| fclose(f_in); | |||||
| return(count); | return(count); | ||||
| } | } | ||||
| ix = GetFileLength(fname); | ix = GetFileLength(fname); | ||||
| prog_log_table = (PHONEME_PROG_LOG *)malloc(ix); | prog_log_table = (PHONEME_PROG_LOG *)malloc(ix); | ||||
| if(prog_log_table == NULL) | if(prog_log_table == NULL) | ||||
| { | |||||
| fclose(f_prog_log); | |||||
| return; | return; | ||||
| } | |||||
| ix = fread(prog_log_table, 1, ix, f_prog_log); | ix = fread(prog_log_table, 1, ix, f_prog_log); | ||||
| fclose(f_prog_log); | fclose(f_prog_log); | ||||
| n_prog_log = ix / sizeof(PHONEME_PROG_LOG); | n_prog_log = ix / sizeof(PHONEME_PROG_LOG); | ||||
| // select the phoneme table by name | // select the phoneme table by name | ||||
| // if(SetVoiceByName(phoneme_tab_list[table].name) != 0) continue; | // if(SetVoiceByName(phoneme_tab_list[table].name) != 0) continue; | ||||
| if(SelectPhonemeTableName(phoneme_tab_list[table].name) < 0) continue; | |||||
| if(SelectPhonemeTableName(phoneme_tab_list[table].name) < 0) | |||||
| { | |||||
| fclose(f); | |||||
| continue; | |||||
| } | |||||
| voice_found = 0; | voice_found = 0; | ||||
| if((LoadVoice(phoneme_tab_list[table].name, 0) != NULL) && (translator->data_dictrules != NULL)) | if((LoadVoice(phoneme_tab_list[table].name, 0) != NULL) && (translator->data_dictrules != NULL)) |