diff --git a/src/espeak-ng.c b/src/espeak-ng.c index a30a01db..c0313c0f 100644 --- a/src/espeak-ng.c +++ b/src/espeak-ng.c @@ -119,7 +119,7 @@ char wavefile[200]; int GetFileLength(const char *filename) -{//==================================== +{ struct stat statbuf; if(stat(filename,&statbuf) != 0) @@ -129,11 +129,11 @@ int GetFileLength(const char *filename) return(-2); // a directory return(statbuf.st_size); -} // end of GetFileLength +} void strncpy0(char *dest, const char *source, int size) -{//==================================================== +{ if(source!=NULL) { strncpy(dest,source,size); @@ -142,7 +142,7 @@ void strncpy0(char *dest, const char *source, int size) } int utf8_in(int *c, const char *buf) -{//================================= +{ // Read a unicode characater from a UTF8 string // Returns the number of UTF8 bytes used. // backwards: set if we are moving backwards through the UTF8 string @@ -174,7 +174,7 @@ int utf8_in(int *c, const char *buf) void DisplayVoices(FILE *f_out, char *language) -{//============================================ +{ int ix; const char *p; int len; @@ -242,13 +242,13 @@ void DisplayVoices(FILE *f_out, char *language) } fputc('\n',f_out); } -} // end of DisplayVoices +} static void Write4Bytes(FILE *f, int value) -{//================================= +{ // Write 4 bytes to a file, least significant first int ix; @@ -262,7 +262,6 @@ static void Write4Bytes(FILE *f, int value) int OpenWavFile(char *path, int rate) -//=================================== { static unsigned char wave_hdr[44] = { 'R','I','F','F',0x24,0xf0,0xff,0x7f,'W','A','V','E','f','m','t',' ', @@ -295,12 +294,11 @@ int OpenWavFile(char *path, int rate) Write4Bytes(f_wavfile,rate * 2); fwrite(&wave_hdr[32],1,12,f_wavfile); return(0); -} // end of OpenWavFile +} static void CloseWavFile() -//======================== { unsigned int pos; @@ -319,11 +317,11 @@ static void CloseWavFile() fclose(f_wavfile); f_wavfile = NULL; -} // end of CloseWavFile +} static int SynthCallback(short *wav, int numsamples, espeak_EVENT *events) -{//======================================================================== +{ char fname[210]; if(quiet) return(0); // -q quiet mode @@ -380,7 +378,7 @@ static int SynthCallback(short *wav, int numsamples, espeak_EVENT *events) static void PrintVersion() -{//======================= +{ const char *version; const char *path_data; espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS, 0, NULL, espeakINITIALIZE_DONT_EXIT); @@ -407,16 +405,9 @@ static void PrintVersion() #endif int main (int argc, char **argv) -//============================== { static struct option long_options[] = { - /* These options set a flag. */ -// {"verbose", no_argument, &verbose_flag, 1}, -// {"brief", no_argument, &verbose_flag, 0}, - - /* These options don't set a flag. - We distinguish them by their indices. */ {"help", no_argument, 0, 'h'}, {"stdin", no_argument, 0, 0x100}, {"compile-debug", optional_argument, 0, 0x101}, diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index fcaadf62..47b4bbfc 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -436,7 +436,7 @@ static void ReadPhondataManifest() } static const char *KeyToMnem(keywtab_t *ktab, int type, int value) -{//=============================================================== +{ while(ktab->mnem != NULL) { if(ktab->data == value) @@ -450,7 +450,7 @@ static const char *KeyToMnem(keywtab_t *ktab, int type, int value) } static void DecompilePhoneme(FILE *f_out, PHONEME_TAB *ph, int compile_phoneme) -{//============================================================================ +{ USHORT *pc; int instn; int instn_category; @@ -753,7 +753,7 @@ char item_string[N_ITEM_STRING]; static int ref_sorter(char **a, char **b) -{//====================================== +{ int ix; REF_HASH_TAB *p1 = (REF_HASH_TAB *)(*a); @@ -768,12 +768,12 @@ static int ref_sorter(char **a, char **b) return ix; return(p1->ph_mnemonic - p2->ph_mnemonic); -} /* end of ref_sorter */ +} static void CompileReport(void) -{//============================ +{ int ix; int hash; int n; @@ -862,7 +862,7 @@ static void CompileReport(void) free(list); list = NULL; fclose(f_report); -} // end of CompileReport +} #ifdef PLATFORM_WINDOWS @@ -886,7 +886,7 @@ int strcasecmp(const char *s1, const char *s2) static int ph_sorter(char **a, char **b) -{//====================================== +{ int ix; int t1, t2; char mnem1[6]; @@ -905,12 +905,12 @@ static int ph_sorter(char **a, char **b) strcpy(mnem1,WordToString(p1->mnemonic)); return(strcasecmp(mnem1,WordToString(p2->mnemonic))); -} /* end of ph_sorter */ +} static void PrintPhonemesUsed(FILE *f, const char *dsource, const char *dictname) -{//============================================================================== +{ int ix; PHONEME_TAB *ph; PHONEME_TAB *ph_tab[N_PHONEME_TAB]; @@ -978,12 +978,12 @@ static void PrintPhonemesUsed(FILE *f, const char *dsource, const char *dictname } } fputc('\n',f); -} // end of PrintPhonemesUsed +} static void error(const char *format, const char *string) -{//====================================================== +{ if(string==NULL) string = ""; fprintf(f_errors,"%4d: ",linenum-1); @@ -993,12 +993,12 @@ static void error(const char *format, const char *string) } static void Error(const char *string) -{//================================== +{ error("%s",string); } static FILE *fopen_log(FILE *f_log, const char *fname,const char *access) -{//===================================================================== +{ // performs fopen, but produces error message to f_log if it fails FILE *f; @@ -1012,7 +1012,7 @@ static FILE *fopen_log(FILE *f_log, const char *fname,const char *access) static unsigned int StringToWord(const char *string) -{//================================================= +{ // Pack 4 characters into a word int ix; unsigned char c; @@ -1070,7 +1070,7 @@ static MNEM_TAB reserved_phonemes[] = { static void ReservePhCodes() -{//========================= +{ // Reserve phoneme codes which have fixed numbers so that they can be // referred to from the program code. unsigned int word; @@ -1086,11 +1086,11 @@ static void ReservePhCodes() n_phcodes = p->value+1; p++; } -} // end of ReservePhCodes +} static int LookupPhoneme(const char *string, int control) -{//====================================================== +{ // control = 0 explicit declaration // control = 1 declare phoneme if not found // control = 2 start looking after control & stress phonemes @@ -1143,12 +1143,12 @@ static int LookupPhoneme(const char *string, int control) phoneme_tab2[use].type = phINVALID; phoneme_tab2[use].program = linenum; // for error report if the phoneme remains undeclared return(use); -} // end of Compile::LookupPhoneme +} static unsigned int get_char() -{//=========================== +{ unsigned int c; c = fgetc(f_in); if(c == '\n') @@ -1157,7 +1157,7 @@ static unsigned int get_char() } static void unget_char(unsigned int c) -{//=================================== +{ ungetc(c,f_in); if(c == '\n') linenum--; @@ -1165,16 +1165,16 @@ static void unget_char(unsigned int c) int CheckNextChar() -{//================ +{ int c; while(((c = get_char()) == ' ') || (c == '\t')); unget_char(c); return(c); -} // end of CheckNextChar +} static int NextItem(int type) -{//========================== +{ int acc; unsigned char c=0; unsigned char c2; @@ -1300,12 +1300,12 @@ static int NextItem(int type) return(LookupPhoneme(item_string,2)); } return(-1); -} // end of NextItem +} static int NextItemMax(int max) -{//============================== +{ // Get a number, but restrict value to max int value; char msg[80]; @@ -1323,7 +1323,7 @@ static int NextItemMax(int max) static int NextItemBrackets(int type, int control) -{//=============================================== +{ // Expect a parameter inside parantheses // control: bit 0 0= need ( // bit 1 1= allow comma @@ -1352,16 +1352,16 @@ static int NextItemBrackets(int type, int control) static void UngetItem() -{//==================== +{ fseek(f_in,f_in_displ,SEEK_SET); linenum = f_in_linenum; -} // end of UngetItem +} static int Range(int value, int divide, int min, int max) -{//====================================================== +{ if(value < 0) value -= divide/2; else @@ -1377,7 +1377,7 @@ static int Range(int value, int divide, int min, int max) int CompileVowelTransition(int which) -{//================================== +{ // Compile a vowel transition int key; int len=0; @@ -1488,12 +1488,12 @@ int CompileVowelTransition(int which) prog_out += 4; return(0); -} // end of VowelTransition +} int LoadSpect(const char *path, int control) -{//========================================= +{ SpectSeq *spectseq; int peak; int displ; @@ -1692,12 +1692,12 @@ int LoadSpect(const char *path, int control) SpectSeqDestroy(spectseq); return(displ); -} // end of LoadSpect +} static int LoadWavefile(FILE *f, const char *fname) -{//================================================ +{ int displ; unsigned char c1; unsigned char c3; @@ -1863,12 +1863,12 @@ static int LoadWavefile(FILE *f, const char *fname) remove(fname_temp); } return(displ | 0x800000); // set bit 23 to indicate a wave file rather than a spectrum -} // end of LoadWavefile +} static int LoadEnvelope(FILE *f, const char *fname) -{//================================================ +{ int displ; char buf[128]; @@ -1889,13 +1889,12 @@ static int LoadEnvelope(FILE *f, const char *fname) } return(displ); -} // end of LoadEnvelope +} -static int Hash8(const char *string) -//================================== /* Generate a hash code from the specified string */ +static int Hash8(const char *string) { int c; int chars=0; @@ -1910,12 +1909,12 @@ static int Hash8(const char *string) } return((hash+chars) & 0xff); -} // end of Hash8 +} static int LoadEnvelope2(FILE *f, const char *fname) -{//=================================================== +{ int ix, ix2; int n; int x, y; @@ -1985,7 +1984,7 @@ static int LoadEnvelope2(FILE *f, const char *fname) } static int LoadDataFile(const char *path, int control) -{//=================================================== +{ // load spectrum sequence or sample data from a file. // return index into spect or sample data area. bit 23=1 if a sample @@ -2084,11 +2083,11 @@ static int LoadDataFile(const char *path, int control) } return(addr); -} // end of LoadDataFile +} static int CompileToneSpec(void) -{//============================= +{ int pitch1=0; int pitch2=0; int pitch_env = 0; @@ -2132,12 +2131,12 @@ static int CompileToneSpec(void) } return(0); -} // end of CompileToneSpec +} int CompileSound(int keyword, int isvowel) -{//======================================= +{ int addr; int value = 0; char path[N_ITEM_STRING]; @@ -2177,7 +2176,7 @@ int CompileSound(int keyword, int isvowel) *prog_out++ = sound_instns[keyword-kFMT] + ((value & 0xff) << 4) + ((addr >> 16) & 0xf); *prog_out++ = addr & 0xffff; return(0); -} // end of CompileSound +} @@ -2194,7 +2193,7 @@ bit 8-11 */ int CompileIf(int elif) -{//==================== +{ int key; int finish = 0; int word = 0; @@ -2322,11 +2321,11 @@ int CompileIf(int elif) *prog_out++ = i_JUMP_FALSE; return(0); -} // end of CompileIf +} void FillThen(int add) -{//=================== +{ USHORT *p; int offset; @@ -2358,11 +2357,11 @@ void FillThen(int add) } then_count = 0; -} // end of FillThen +} int CompileElse(void) -{//================== +{ USHORT *ref; USHORT *p; @@ -2394,11 +2393,11 @@ int CompileElse(void) } return(0); -} // end of CompileElse +} int CompileElif(void) -{//=================== +{ if(if_level < 1) { error("ELIF not expected",NULL); @@ -2412,7 +2411,7 @@ int CompileElif(void) int CompileEndif(void) -{//=================== +{ USHORT *p; int chain; int offset; @@ -2444,11 +2443,11 @@ int CompileEndif(void) if_level--; return(0); -} // end of CompileEndif +} static int CompileSwitch(int type) -{//=============================== +{ // Type 0: EndSwitch // 1: SwitchPrevVowelType // 2: SwitchNextVowelType @@ -2464,12 +2463,12 @@ static int CompileSwitch(int type) if(type == 2) *prog_out++ = i_SWITCH_NEXTVOWEL+6; return(0); -} // end of CompileSwitch +} static PHONEME_TAB_LIST *FindPhonemeTable(const char *string) -{//========================================================== +{ int ix; for(ix=0; ixend_type = 0; // voicingswitch, this must be set later to refer to a local phoneme } -} // end of ImportPhoneme +} static void CallPhoneme(void) -{//========================== +{ PHONEME_TAB *ph; int ix; int addr = 0; @@ -2589,17 +2588,17 @@ static void CallPhoneme(void) *prog_out++ = i_CALLPH + (addr >> 16); *prog_out++ = addr; -} // end of CallPhoneme +} static void DecThenCount() -{//======================= +{ if(then_count >0) then_count--; } static void InstnPlusPhoneme(int instn) -{//==================================== +{ int phcode; phcode = NextItemBrackets(tPHONEMEMNEM,0); @@ -2608,7 +2607,7 @@ static void InstnPlusPhoneme(int instn) int CompilePhoneme(int compile_phoneme) -{//==================================== +{ int endphoneme = 0; int keyword; int value; @@ -3024,14 +3023,14 @@ int CompilePhoneme(int compile_phoneme) } return(0); -} // end of CompilePhoneme +} static void WritePhonemeTables() -{//============================= +{ int ix; int j; int n; @@ -3084,11 +3083,11 @@ static void WritePhonemeTables() fwrite(&p[n],sizeof(PHONEME_TAB),1,f_phtab); // include the extra list-terminator phoneme entry free(p); } -} // end of WritePhonemeTables +} static void EndPhonemeTable() -{//========================== +{ int ix; int *pw; int length; @@ -3128,7 +3127,7 @@ static void EndPhonemeTable() static void StartPhonemeTable(const char *name) -{//============================================ +{ int ix; int j; PHONEME_TAB *p; @@ -3185,11 +3184,11 @@ static void StartPhonemeTable(const char *name) } n_phoneme_tabs++; -} // end of StartPhonemeTable +} static void CompileEquivalents() -{//============================= +{ // a list of phonemes in another language and the equivalent phoneme strings in this language int ix; @@ -3290,12 +3289,12 @@ static void CompileEquivalents() n_bytes = n_bytes / 4; p_start[2] = n_bytes >> 8; // index of next table p_start[3] = n_bytes; -} // end of CompileEquivalents +} static void CompilePhonemeFiles() -{//============================== +{ int item; FILE *f; char buf[sizeof(path_home)+120]; @@ -3381,12 +3380,12 @@ static void CompilePhonemeFiles() } } phoneme_tab2[n_phcodes+1].mnemonic = 0; // terminator -} // end of CompilePhonemeFiles +} static espeak_ng_STATUS CompilePhonemeData2(const char *source, FILE *log) -{//================================================ +{ char fname[sizeof(path_home)+40]; sprintf(fname,"%s/../phsource",path_home); @@ -3515,7 +3514,7 @@ fprintf(f_errors,"\nRefs %d, Reused %d\n",count_references,duplicate_references ReadPhondataManifest(); return ENS_OK; -} // end of CompilePhonemeData +} static const char *preset_tune_names[] = { @@ -3550,15 +3549,8 @@ MNEM_TAB envelope_names[] = { {"rise-fall-rise", 18}, {NULL, -1} }; - -// env_fallrise3, env_fallrise3, -// env_fallrise4, env_fallrise4, -// env_fall2, env_fall2, -// env_rise2, env_rise2, -// env_risefallrise, env_risefallrise - int LookupEnvelopeName(const char *name) -{//================================= +{ return(LookupMnem(envelope_names, name)); } @@ -3566,7 +3558,7 @@ int LookupEnvelopeName(const char *name) #pragma GCC visibility push(default) espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log) -{//===================== +{ int ix; char *p; char c; @@ -3861,7 +3853,7 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log) LoadPhData(NULL); return error_count > 0 ? ENE_COMPILE_ERRORS : ENS_OK; -} // end of CompileIntonation +} diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index 37d0e350..c563f748 100644 --- a/src/libespeak-ng/compiledict.c +++ b/src/libespeak-ng/compiledict.c @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2014 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * * * 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 * @@ -158,7 +158,7 @@ typedef struct { int isspace2(unsigned int c) -{//========================= +{ // can't use isspace() because on Windows, isspace(0xe1) gives TRUE ! int c2; @@ -170,7 +170,7 @@ int isspace2(unsigned int c) static FILE *fopen_log(const char *fname,const char *access) -{//================================================== +{ // performs fopen, but produces error message to f_log if it fails FILE *f; @@ -183,9 +183,8 @@ static FILE *fopen_log(const char *fname,const char *access) } -const char *LookupMnemName(MNEM_TAB *table, const int value) -//========================================================== /* Lookup a mnemonic string in a table, return its name */ +const char *LookupMnemName(MNEM_TAB *table, const int value) { while(table->mnem != NULL) { @@ -194,11 +193,11 @@ const char *LookupMnemName(MNEM_TAB *table, const int value) table++; } return(""); /* not found */ -} /* end of LookupMnemValue */ +} void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len) -{//======================================================================== +{ int stress; int ix; const char *name; @@ -232,7 +231,7 @@ void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len) char *DecodeRule(const char *group_chars, int group_length, char *rule, int control) -{//================================================================================= +{ /* Convert compiled match template to ascii */ unsigned char rb; @@ -402,13 +401,13 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont output[ix++]=' '; output[ix]=0; return(output); -} /* end of DecodeRule */ +} static int compile_line(char *linebuf, char *dict_line, int *hash) -{//=============================================================== +{ // Compile a line in the language_list file unsigned char c; char *p; @@ -759,12 +758,12 @@ static int compile_line(char *linebuf, char *dict_line, int *hash) return(length); -} /* end of compile_line */ +} static void compile_dictlist_start(void) -{//===================================== +{ // initialise dictionary list int ix; char *p; @@ -786,7 +785,7 @@ static void compile_dictlist_start(void) static void compile_dictlist_end(FILE *f_out) -{//========================================== +{ // Write out the compiled dictionary list int hash; int length; @@ -823,7 +822,7 @@ static void compile_dictlist_end(FILE *f_out) static int compile_dictlist_file(const char *path, const char* filename) -{//===================================================================== +{ int length; int hash; char *p; @@ -879,7 +878,7 @@ static int compile_dictlist_file(const char *path, const char* filename) fprintf(f_log,"\t%d entries\n",count); fclose(f_in); return(0); -} /* end of compile_dictlist_file */ +} @@ -908,7 +907,7 @@ int isHexDigit(int c) static void copy_rule_string(char *string, int *state_out) -{//======================================================= +{ // state 0: conditional, 1=pre, 2=match, 3=post, 4=phonemes static char *outbuf[5] = {rule_cond, rule_pre, rule_match, rule_post, rule_phonemes}; static int next_state[5] = {2,2,4,4,4}; @@ -1174,12 +1173,12 @@ static void copy_rule_string(char *string, int *state_out) } *state_out = next_state[state]; -} // end of copy_rule_string +} static char *compile_rule(char *input) -{//=================================== +{ int ix; unsigned char c; int wc; @@ -1360,11 +1359,11 @@ static char *compile_rule(char *input) prule = (char *)malloc(len); memcpy(prule,output,len); return(prule); -} // end of compile_rule +} int __cdecl string_sorter(char **a, char **b) -{//=========================================== +{ char *pa, *pb; int ix; @@ -1373,11 +1372,11 @@ int __cdecl string_sorter(char **a, char **b) pa += (strlen(pa)+1); pb += (strlen(pb)+1); return(strcmp(pa,pb)); -} /* end of string_sorter */ +} static int __cdecl rgroup_sorter(RGROUP *a, RGROUP *b) -{//=================================================== +{ // Sort long names before short names int ix; ix = strlen(b->name) - strlen(a->name); @@ -1390,7 +1389,7 @@ static int __cdecl rgroup_sorter(RGROUP *a, RGROUP *b) #ifdef OUTPUT_FORMAT static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name) -{//============================================================================= +{ int rule; int ix; unsigned char c; @@ -1495,9 +1494,8 @@ static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name) #endif -//#define LIST_GROUP_INFO static void output_rule_group(FILE *f_out, int n_rules, char **rules, char *name) -{//============================================================================== +{ int ix; int len1; int len2; @@ -1558,12 +1556,12 @@ static void output_rule_group(FILE *f_out, int n_rules, char **rules, char *name printf("Group %s %c %d\n",name,ix,nextchar_count[ix]); } #endif -} // end of output_rule_group +} static int compile_lettergroup(char *input, FILE *f_out) -{//===================================================== +{ char *p; char *p_start; int group; @@ -1644,7 +1642,7 @@ static int compile_lettergroup(char *input, FILE *f_out) static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp) -{//==================================================================== +{ char *prule; unsigned char *p; int ix; @@ -1888,12 +1886,12 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp) fprintf(f_log,"\t%d rules, %d groups (%d)\n\n",count,n_rgroups,n_groups3); return(0); -} // end of compile_dictrules +} int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, char *fname_err, int flags) -{//===================================================================================================== +{ // fname: space to write the filename in case of error // flags: bit 0: include source line number information, for debug purposes. @@ -1979,5 +1977,4 @@ int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, cha LoadDictionary(translator, dict_name, 0); return(error_count); -} // end of compile_dictionary - +} diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 6b5fa344..db8f6d0a 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -81,7 +81,7 @@ static unsigned char remove_accent[N_REMOVE_ACCENT] = { void strncpy0(char *to,const char *from, int size) -{//=================================================== +{ // strcpy with limit, ensures a zero terminator strncpy(to,from,size); to[size-1] = 0; @@ -89,7 +89,7 @@ void strncpy0(char *to,const char *from, int size) int Reverse4Bytes(int word) -{//========================== +{ // reverse the order of bytes from little-endian to big-endian #ifdef ARCH_BIG int ix; @@ -108,7 +108,7 @@ int Reverse4Bytes(int word) int LookupMnem(MNEM_TAB *table, const char *string) -{//================================================== +{ while(table->mnem != NULL) { if(strcmp(string,table->mnem)==0) @@ -119,14 +119,8 @@ int LookupMnem(MNEM_TAB *table, const char *string) } -//============================================================================================= -// Read pronunciation rules and pronunciation lookup dictionary -// -//============================================================================================= - - static void InitGroups(Translator *tr) -{//=================================== +{ // Called after dictionary 1 is loaded, to set up table of entry points for translation rule chains // for single-letters and two-letter combinations @@ -230,12 +224,12 @@ static void InitGroups(Translator *tr) p++; } -} // end of InitGroups +} int LoadDictionary(Translator *tr, const char *name, int no_error) -{//=============================================================== +{ int hash; char *p; int *pw; @@ -315,14 +309,13 @@ int LoadDictionary(Translator *tr, const char *name, int no_error) } return(0); -} // end of LoadDictionary +} -int HashDictionary(const char *string) -//==================================== /* Generate a hash code from the specified string This is used to access the dictionary_2 word-lookup dictionary */ +int HashDictionary(const char *string) { int c; int chars=0; @@ -336,25 +329,17 @@ int HashDictionary(const char *string) } return((hash+chars) & 0x3ff); // a 10 bit hash code -} // end of HashDictionary +} -//============================================================================================= -// Translate between internal representation of phonemes and a mnemonic form for display -// -//============================================================================================= - - - -const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme) -/******************************************************************/ /* Translate a phoneme string from ascii mnemonics to internal phoneme numbers, from 'p' up to next blank . Returns advanced 'p' outptr contains encoded phonemes, unrecognized phoneme stops the encoding bad_phoneme must point to char array of length 2 of more */ +const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme) { int ix; unsigned char c; @@ -467,12 +452,12 @@ const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme) /* terminate the encoded string */ *outptr = 0; return(p); -} // end of EncodePhonemes +} void DecodePhonemes(const char *inptr, char *outptr) -{//================================================== +{ // Translate from internal phoneme codes into phoneme mnemonics unsigned char phcode; unsigned char c; @@ -512,7 +497,7 @@ void DecodePhonemes(const char *inptr, char *outptr) } } *outptr = 0; /* string terminator */ -} // end of DecodePhonemes +} // using Kirschenbaum to IPA translation, ascii 0x20 to 0x7f @@ -531,7 +516,7 @@ static unsigned int phon_out_size = 0; char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int use_ipa, int *flags) -{//=================================================================================================== +{ int c; int mnem; int len; @@ -628,12 +613,12 @@ char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int phon_out = &phon_out[ix]; *phon_out = 0; return(phon_out); -} // end of WritePhMnemonic +} const char *GetTranslatedPhonemeString(int phoneme_mode) -{//======================================================= +{ /* Called after a clause has been translated into phonemes, in order to display the clause in phoneme mnemonic form. @@ -789,19 +774,12 @@ const char *GetTranslatedPhonemeString(int phoneme_mode) phon_out_buf[phon_out_ix] = 0; return(phon_out_buf); -} // end of GetTranslatedPhonemeString - - - -//============================================================================================= -// Is a word Unpronouncable - and so should be spoken as individual letters -// -//============================================================================================= +} static int IsLetterGroup(Translator *tr, char *word, int group, int pre) -{//===================================================================== +{ // match the word against a list of utf-8 strings char *p; char *w; @@ -841,7 +819,7 @@ static int IsLetterGroup(Translator *tr, char *word, int group, int pre) static int IsLetter(Translator *tr, int letter, int group) -{//======================================================= +{ int letter2; if(tr->letter_groups[group] != NULL) @@ -875,7 +853,7 @@ static int IsLetter(Translator *tr, int letter, int group) int IsVowel(Translator *tr, int letter) -{//==================================== +{ return(IsLetter(tr, letter, LETTERGP_VOWEL2)); } @@ -883,7 +861,7 @@ int IsVowel(Translator *tr, int letter) static int Unpronouncable2(Translator *tr, char *word) -{//=================================================== +{ int c; int end_flags; char ph_buf[N_WORD_PHONEMES]; @@ -900,7 +878,7 @@ static int Unpronouncable2(Translator *tr, char *word) int Unpronouncable(Translator *tr, char *word, int posn) -{//===================================================== +{ /* Determines whether a word in 'unpronouncable', i.e. whether it should be spoken as individual letters. @@ -978,19 +956,12 @@ int Unpronouncable(Translator *tr, char *word, int posn) return(0); -} /* end of Unpronounceable */ - - - -//============================================================================================= -// Determine the stress pattern of a word -// -//============================================================================================= +} static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char *vowel_stress, int *vowel_count, int *stressed_syllable, int control) -{//================================================================================================================================================= +{ // control = 1, set stress to 1 for forced unstressed vowels unsigned char phcode; PHONEME_TAB *ph; @@ -1117,7 +1088,7 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char * *stressed_syllable = primary_posn; *vowel_count = count; return(max_stress); -} // end of GetVowelStress +} @@ -1127,7 +1098,7 @@ static char stress_phonemes[] = {phonSTRESS_D, phonSTRESS_U, phonSTRESS_2, phonS void ChangeWordStress(Translator *tr, char *word, int new_stress) -{//============================================================== +{ int ix; unsigned char *p; int max_stress; @@ -1176,12 +1147,12 @@ void ChangeWordStress(Translator *tr, char *word, int new_stress) *word++ = *p++; } *word = 0; -} // end of ChangeWordStress +} void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int control) -{//===================================================================================================== +{ /* Guess stress pattern of word. This is language specific 'output' is used for input and output @@ -1822,21 +1793,12 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, *output++ = 0; return; -} /* end of SetWordStress */ - - - - -//============================================================================================= -// Look up a word in the pronunciation rules -// -//============================================================================================= - +} void AppendPhonemes(Translator *tr, char *string, int size, const char *ph) -{//======================================================================== +{ /* Add new phoneme string "ph" to "string" Keeps count of the number of vowel phonemes in the word, and whether these can be stressed syllables. These values can be used in translation rules @@ -1881,12 +1843,12 @@ void AppendPhonemes(Translator *tr, char *string, int size, const char *ph) if(string != NULL) strcat(string,ph); -} /* end of AppendPhonemes */ +} static void MatchRule(Translator *tr, char *word[], char *word_start, int group_length, char *rule, MatchRecord *match_out, int word_flags, int dict_flags) -{//======================================================================================================================================================== +{ /* Checks a specified word against dictionary rules. Returns with phoneme code string, or NULL if no match found. @@ -2579,13 +2541,13 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_ if(best.points == 0) best.phonemes = ""; memcpy(match_out,&best,sizeof(MatchRecord)); -} /* end of MatchRule */ +} int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, char *end_phonemes, int word_flags, unsigned int *dict_flags) -{//===================================================================================================================================== +{ /* Translate a word bounded by space characters Append the result to 'phonemes' and any standard prefix/suffix in 'end_phonemes' */ @@ -2885,11 +2847,11 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c memcpy(p_start,word_copy,strlen(word_copy)); return(0); -} /* end of TranslateRules */ +} void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags) -{//======================================================================== +{ // apply after the translation is complete int ix; int len; @@ -2922,20 +2884,12 @@ void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags) } } } -} // end of ApplySpecialAttribute2 +} - -//============================================================================================= -// Look up a word in the pronunciation dictionary list -// - exceptions which override the usual pronunciation rules, or which give a word -// special properties, such as pronounce as unstressed -//============================================================================================= - - int TransposeAlphabet(Translator *tr, char *text) -{//============================================== +{ // transpose cyrillic alphabet (for example) into ascii (single byte) character codes // return: number of bytes, bit 6: 1=used compression int c; @@ -3043,14 +2997,11 @@ int TransposeAlphabet(Translator *tr, char *text) { return(strlen(text)); } -} // end of TransposeAlphabet +} -static const char *LookupDict2(Translator *tr, const char *word, const char *word2, - char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab) -//===================================================================================== /* Find an entry in the word_dict file for a specified word. Returns NULL if no match, else returns 'word_end' @@ -3061,6 +3012,8 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor end_flags: indicates whether this is a retranslation after removing a suffix */ +static const char *LookupDict2(Translator *tr, const char *word, const char *word2, + char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab) { char *p; char *next; @@ -3402,17 +3355,16 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor } return(0); -} // end of LookupDict2 +} -int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *flags, int end_flags, WORD_TAB *wtab) -//================================================================================================================== /* Lookup a specified word in the word dictionary. Returns phonetic data in 'phonetic' and bits in 'flags' end_flags: indicates if a suffix has been removed */ +int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *flags, int end_flags, WORD_TAB *wtab) { int length; const char *found; @@ -3561,13 +3513,13 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f ph_out[0] = 0; return(0); -} // end of LookupDictList +} extern char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes int Lookup(Translator *tr, const char *word, char *ph_out) -{//========================================================= +{ // Look up in *_list, returns dictionary flags[0] and phonemes int flags0; @@ -3598,7 +3550,7 @@ int Lookup(Translator *tr, const char *word, char *ph_out) int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out) -{//=========================================================================== +{ char buf[100]; static unsigned int flags[2]; char *word1 = (char *)word; @@ -3612,7 +3564,7 @@ int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out) int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy) -{//======================================================================== +{ /* Removes a standard suffix from a word, once it has been indicated by the dictionary rules. end_type: bits 0-6 number of letters bits 8-14 suffix flags @@ -3755,7 +3707,4 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy) end_flags &= ~FLAG_SUFX; // don't consider 's as an added suffix return(end_flags); -} /* end of RemoveEnding */ - - - +} diff --git a/src/libespeak-ng/espeak_command.c b/src/libespeak-ng/espeak_command.c index 6864ed15..d91c6a5e 100644 --- a/src/libespeak-ng/espeak_command.c +++ b/src/libespeak-ng/espeak_command.c @@ -1,6 +1,6 @@ /*************************************************************************** * Copyright (C) 2007, Gilles Casse * - * 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 * * it under the terms of the GNU General Public License as published by * @@ -18,8 +18,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -// This source file is only used for asynchronious modes - #include "speech.h" #include "espeak_command.h" #include diff --git a/src/libespeak-ng/intonation.c b/src/libespeak-ng/intonation.c index a0830739..2f95016a 100644 --- a/src/libespeak-ng/intonation.c +++ b/src/libespeak-ng/intonation.c @@ -325,7 +325,6 @@ static int no_tonic; static void count_pitch_vowels(int start, int end, int clause_end) -/****************************************************************/ { int ix; int stress; @@ -389,14 +388,13 @@ static void count_pitch_vowels(int start, int end, int clause_end) // no primary stress. Use the highest stress syllable_tab[tone_posn].stress = PRIMARY_LAST; } -} /* end of count_pitch_vowels */ +} -static int count_increments(int ix, int end_ix, int min_stress) -/*************************************************************/ /* Count number of primary stresses up to tonic syllable or body_reset */ +static int count_increments(int ix, int end_ix, int min_stress) { int count = 0; int stress; @@ -411,14 +409,13 @@ static int count_increments(int ix, int end_ix, int min_stress) count++; } return(count); -} /* end of count_increments */ +} -static void set_pitch(SYLLABLE *syl, int base, int drop) -/******************************************************/ // Set the pitch of a vowel in syllable_tab +static void set_pitch(SYLLABLE *syl, int base, int drop) { int pitch1, pitch2; int flags = 0; @@ -443,11 +440,11 @@ static void set_pitch(SYLLABLE *syl, int base, int drop) syl->pitch1 = pitch1; syl->pitch2 = pitch2; syl->flags |= flags; -} /* end of set_pitch */ +} static int CountUnstressed(int start, int end, int limit) -{//====================================================== +{ int ix; for(ix=start; ix <= end; ix++) @@ -459,7 +456,7 @@ static int CountUnstressed(int start, int end, int limit) } static int SetHeadIntonation(TUNE *tune, int syl_ix, int end_ix, int control) -{//========================================================================== +{ int stress; SYLLABLE *syl; int ix; @@ -601,15 +598,14 @@ int secondary=2; // 2 } return(syl_ix); -} // end of SetBodyIntonation +} -static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *tn, int min_stress, int continuing) -/**********************************************************************************************/ /* Calculate pitches until next RESET or tonic syllable, or end. Increment pitch if stress is >= min_stress. Used for tonic segment */ +static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *tn, int min_stress, int continuing) { int stress; int pitch=0; @@ -719,12 +715,12 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t ix++; } return(ix); -} /* end of calc_pitch_segment */ +} static void SetPitchGradient(int start_ix, int end_ix, int start_pitch, int end_pitch) -{//==================================================================================== +{ // Set a linear pitch change over a number of syllables. // Used for pre-head, unstressed syllables in the body, and the tail @@ -772,13 +768,12 @@ static void SetPitchGradient(int start_ix, int end_ix, int start_pitch, int end_ set_pitch(syl, (pitch >> 8), drop); } } -} // end of SetPitchGradient +} -static int calc_pitches2(int start, int end, int tune_number) -//============================================================ // Calculate pitch values for the vowels in this tone group +static int calc_pitches2(int start, int end, int tune_number) { int ix; TUNE *tune; @@ -831,13 +826,12 @@ static int calc_pitches2(int start, int end, int tune_number) SetPitchGradient(ix, end, tune->tail_start, tune->tail_end); return(tone_pitch_env); -} /* end of calc_pitches2 */ +} -static int calc_pitches(int control, int start, int end, int tune_number) -//======================================================================== // Calculate pitch values for the vowels in this tone group +static int calc_pitches(int control, int start, int end, int tune_number) { int ix; TONE_HEAD *th; @@ -906,7 +900,7 @@ static int calc_pitches(int control, int start, int end, int tune_number) SetPitchGradient(ix, end, tn->tail_start, tn->tail_end); return(tone_pitch_env); -} /* end of calc_pitches */ +} @@ -914,7 +908,7 @@ static int calc_pitches(int control, int start, int end, int tune_number) static void CalcPitches_Tone(Translator *tr, int clause_tone) -{//========================================================== +{ // clause_tone: 0=. 1=, 2=?, 3=! 4=none PHONEME_LIST *p; int ix; @@ -1088,12 +1082,12 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone) } -} // end of Translator::CalcPitches_Tone +} void CalcPitches(Translator *tr, int clause_type) -{//============================================== +{ // clause_type: 0=. 1=, 2=?, 3=! 4=none PHONEME_LIST *p; SYLLABLE *syl; @@ -1313,6 +1307,4 @@ if(p->tone_ph) } } -} // end of CalcPitches - - +} diff --git a/src/libespeak-ng/klatt.c b/src/libespeak-ng/klatt.c index 965db639..7f08405a 100644 --- a/src/libespeak-ng/klatt.c +++ b/src/libespeak-ng/klatt.c @@ -494,7 +494,7 @@ if(option_log_frames) } } return(0); -} // end of parwave +} @@ -998,7 +998,7 @@ static double klattp_inc[N_KLATTP]; int Wavegen_Klatt(int resume) -{//========================== +{ int pk; int x; int ix; @@ -1106,7 +1106,7 @@ int Wavegen_Klatt(int resume) void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v, int control) -{//=========================================================================================== +{ int ix; DOUBLEX next; int qix; @@ -1263,11 +1263,11 @@ if(option_log_frames) peaks[ix].ap_inc = ((next - peaks[ix].ap1) * STEPSIZE) / length; } } -} // end of SetSynth_Klatt +} int Wavegen_Klatt2(int length, int modulation, int resume, frame_t *fr1, frame_t *fr2) -{//=================================================================================== +{ if(resume==0) SetSynth_Klatt(length, modulation, fr1, fr2, wvoice, 1); @@ -1323,4 +1323,4 @@ void KlattInit() kt_frame.AB = 0; kt_frame.AVpdb = 0; kt_frame.Gain0 = 62; // 60 -} // end of KlattInit +} diff --git a/src/libespeak-ng/numbers.c b/src/libespeak-ng/numbers.c index 591f132c..196f4b39 100644 --- a/src/libespeak-ng/numbers.c +++ b/src/libespeak-ng/numbers.c @@ -393,7 +393,7 @@ static const unsigned short letter_accents_250[] = { }; static int LookupLetter2(Translator *tr, unsigned int letter, char *ph_buf) -{ //======================================================================== +{ int len; char single_letter[10]; @@ -416,7 +416,7 @@ static int LookupLetter2(Translator *tr, unsigned int letter, char *ph_buf) void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf) -{//========================================================================= +{ // lookup the character in the accents table int accent_data = 0; int accent1 = 0; @@ -498,12 +498,12 @@ void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf) } } } -} // end of LookupAccentedLetter +} void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf1, int control) -{//============================================================================================== +{ // control, bit 0: not the first letter of a word int len; @@ -580,7 +580,7 @@ void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_b dict_flags[1] = 0; SetWordStress(tr, ph_buf1, dict_flags, -1, control & 1); -} // end of LookupLetter +} // unicode ranges for non-ascii digits 0-9 @@ -592,7 +592,7 @@ static const int number_ranges[] = { int NonAsciiNumber(int letter) -{//============================ +{ // Change non-ascii digit into ascii digit '0' to '9', (or -1 if not) const int *p; int base; @@ -683,7 +683,7 @@ static const char *hex_letters[] = {"'e:j","b'i:","s'i:","d'i:","'i:","'ef"}; / int IsSuperscript(int letter) -{//=========================== +{ // is this a subscript or superscript letter ? int ix; int c; @@ -701,7 +701,7 @@ int IsSuperscript(int letter) int TranslateLetter(Translator *tr, char *word, char *phonemes, int control) -{//========================================================================= +{ // get pronunciation for an isolated letter // return number of bytes used by the letter // control bit 0: a non-initial letter in a word @@ -990,12 +990,12 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control) strcpy(&phonemes[len],ph_buf2); } return(n_bytes); -} // end of TranslateLetter +} void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars) -{//============================================================================= +{ // Individual letter names, reduce the stress of some. int ix; unsigned int c; @@ -1054,7 +1054,7 @@ void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars) if(control >= 2) *phonemes++ = phonPAUSE_NOLINK; *phonemes = 0; -} // end of SetSpellingStress +} @@ -1065,7 +1065,7 @@ static char ph_ordinal2x[12]; static int CheckDotOrdinal(Translator *tr, char *word, char *word_end, WORD_TAB *wtab, int roman) -{//============================================================================================== +{ int ordinal = 0; int c2; @@ -1117,11 +1117,11 @@ static int CheckDotOrdinal(Translator *tr, char *word, char *word_end, WORD_TAB } } return(ordinal); -} // end of CheckDotOrdinal +} static int hu_number_e(const char *word, int thousandplex, int value) -{//================================================================== +{ // lang-hu: variant form of numbers when followed by hyphen and a suffix starting with 'a' or 'e' (but not a, e, az, ez, azt, ezt, att. ett if((word[0] == 'a') || (word[0] == 'e')) @@ -1135,12 +1135,12 @@ static int hu_number_e(const char *word, int thousandplex, int value) return(1); } return(0); -} // end of hu_numnber_e +} int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab) -{//========================================================================= +{ int c; char *p; const char *p2; @@ -1275,11 +1275,11 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab) strcat(ph_out,ph_roman); return(1); -} // end of TranslateRoman +} static const char *M_Variant(int value) -{//==================================== +{ // returns M, or perhaps MA or MB for some cases int teens = 0; @@ -1326,7 +1326,7 @@ static const char *M_Variant(int value) static int LookupThousands(Translator *tr, int value, int thousandplex, int thousands_exact, char *ph_out) -{//======================================================================================================= +{ // thousands_exact: bit 0 no hundreds,tens,or units, bit 1 ordinal numberr int found; int found_value=0; @@ -1430,11 +1430,11 @@ static int LookupThousands(Translator *tr, int value, int thousandplex, int thou return(1); return(found_value); -} // end f LookupThousands +} static int LookupNum2(Translator *tr, int value, int thousandplex, const int control, char *ph_out) -{//============================================================================= +{ // Lookup a 2 digit number // control bit 0: ordinal number // control bit 1: final tens and units (not number of thousands) (use special form of '1', LANG=de "eins") @@ -1739,11 +1739,11 @@ static int LookupNum2(Translator *tr, int value, int thousandplex, const int con } } return(used_and); -} // end of LookupNum2 +} static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null, int thousandplex, int control) -{//============================================================================================================= +{ // Translate a 3 digit number // control bit 0, previous thousands // bit 1, ordinal number @@ -1996,11 +1996,11 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null sprintf(ph_out,"%s%s%c%s",buf1,ph_hundred_and,phonEND_WORD,buf2); return(0); -} // end of LookupNum3 +} bool CheckThousandsGroup(char *word, int group_len) -{//================================================ +{ // Is this a group of 3 digits which looks like a thousands group? int ix; @@ -2017,7 +2017,7 @@ bool CheckThousandsGroup(char *word, int group_len) static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control) -{//===================================================================================================================== +{ // Number translation with various options // the "word" may be up to 4 digits // "words" of 3 digits may be preceded by another number "word" for thousands or millions @@ -2328,8 +2328,6 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned while(IsDigit09(word[n_digits+decimal_count])) decimal_count++; -// if(decimal_count > 1) - { max_decimal_count = 2; switch(decimal_mode = (tr->langopts.numbers & 0xe000)) { @@ -2393,7 +2391,6 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned strcat(ph_out, buf1); } } - } while(IsDigit09(c = word[n_digits]) && (strlen(ph_out) < (N_WORD_PHONEMES - 10))) { @@ -2438,12 +2435,12 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned if(skipwords) dictionary_skipwords = skipwords; return(1); -} // end of TranslateNumber_1 +} int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control) -{//============================================================================================================= +{ if((option_sayas == SAYAS_DIGITS1) || (wtab[0].flags & FLAG_INDIVIDUAL_DIGITS)) return(0); // speak digits individually @@ -2452,5 +2449,4 @@ int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *fla return(TranslateNumber_1(tr, word1, ph_out, flags, wtab, control)); } return(0); -} // end of TranslateNumber - +} diff --git a/src/libespeak-ng/phoneme.h b/src/libespeak-ng/phoneme.h index cd65ca9f..faf37afe 100644 --- a/src/libespeak-ng/phoneme.h +++ b/src/libespeak-ng/phoneme.h @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2010 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * * * 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 * diff --git a/src/libespeak-ng/phonemelist.c b/src/libespeak-ng/phonemelist.c index 69252067..b30c6cb0 100644 --- a/src/libespeak-ng/phonemelist.c +++ b/src/libespeak-ng/phonemelist.c @@ -38,7 +38,7 @@ extern PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out) -{//=================================================================== +{ // Copy the phonemes list and perform any substitutions that are required for the // current voice int ix; @@ -100,12 +100,12 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out) n_plist_out++; } return(n_plist_out); -} // end of SubstitutePhonemes +} void MakePhonemeList(Translator *tr, int post_pause, int start_sentence) -{//===================================================================== +{ int ix=0; int j; @@ -656,6 +656,4 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence) phlist[ix++].ph = phoneme_tab[phonPAUSE_SHORT]; n_phoneme_list = ix; -} // end of MakePhonemeList - - +} diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 22aed18c..b6570a6e 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2015 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * * * 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 * @@ -513,7 +513,7 @@ int towupper2(unsigned int c) } static int IsRomanU(unsigned int c) -{//================================ +{ if((c=='I') || (c=='V') || (c=='X') || (c=='L')) return(1); return(0); @@ -521,7 +521,7 @@ static int IsRomanU(unsigned int c) static void GetC_unget(int c) -{//========================== +{ // This is only called with UTF8 input, not wchar input if(f_input != NULL) ungetc(c,f_input); @@ -534,7 +534,7 @@ static void GetC_unget(int c) } int Eof(void) -{//========== +{ if(ungot_char != 0) return(0); @@ -546,7 +546,7 @@ int Eof(void) static int GetC_get(void) -{//====================== +{ unsigned int c; unsigned int c2; @@ -599,7 +599,7 @@ static int GetC_get(void) static int GetC(void) -{//================== +{ // Returns a unicode wide character // Performs UTF8 checking and conversion @@ -688,17 +688,17 @@ static int GetC(void) if(c1 >= 0xa0) return(translator->charset_a0[c1-0xa0]); return(c1); -} // end of GetC +} static void UngetC(int c) -{//====================== +{ ungot_char = c; } const char *WordToString2(unsigned int word) -{//============================================ +{ // Convert a language mnemonic word into a string int ix; static char buf[5]; @@ -716,7 +716,7 @@ const char *WordToString2(unsigned int word) static const char *LookupSpecial(Translator *tr, const char *string, char* text_out) -{//================================================================================= +{ unsigned int flags[2]; char phonemes[55]; char phonemes2[55]; @@ -735,7 +735,7 @@ static const char *LookupSpecial(Translator *tr, const char *string, char* text_ static const char *LookupCharName(Translator *tr, int c, int only) -{//=============================================================== +{ // Find the phoneme string (in ascii) to speak the name of character c // Used for punctuation characters and symbols @@ -824,7 +824,7 @@ static const char *LookupCharName(Translator *tr, int c, int only) } int Read4Bytes(FILE *f) -{//==================== +{ // Read 4 bytes (least significant first) into a word int ix; unsigned char c; @@ -840,7 +840,7 @@ int Read4Bytes(FILE *f) static int LoadSoundFile(const char *fname, int index) -{//=================================================== +{ FILE *f; char *p; int *ip; @@ -922,11 +922,11 @@ static int LoadSoundFile(const char *fname, int index) soundicon_tab[index].length = (*ip) / 2; // length in samples soundicon_tab[index].data = p; return(0); -} // end of LoadSoundFile +} static int LookupSoundicon(int c) -{//============================== +{ // Find the sound icon number for a punctuation chatacter int ix; @@ -947,7 +947,7 @@ static int LookupSoundicon(int c) static int LoadSoundFile2(const char *fname) -{//========================================= +{ // Load a sound file into one of the reserved slots in the sound icon table // (if it'snot already loaded) @@ -976,7 +976,7 @@ static int LoadSoundFile2(const char *fname) static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output, int *bufix, int end_clause) -{//============================================================================================================= +{ // announce punctuation names // c1: the punctuation character // c2: the following character @@ -1105,7 +1105,7 @@ static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output return(attributes); return(short_pause); -} // end of AnnouncePunctuation +} #define SSML_SPEAK 1 #define SSML_VOICE 2 @@ -1169,7 +1169,7 @@ static MNEM_TAB ssmltags[] = { static const char *VoiceFromStack() -{//================================ +{ // Use the voice properties from the SSML stack to choose a voice, and switch // to that voice if it's not the current voice int ix; @@ -1249,12 +1249,12 @@ static const char *VoiceFromStack() return(voice_name); } return(v_id); -} // end of VoiceFromStack +} static void ProcessParamStack(char *outbuf, int *outix) -{//==================================================== +{ // Set the speech parameters from the parameter stack int param; int ix; @@ -1306,11 +1306,11 @@ static void ProcessParamStack(char *outbuf, int *outix) *outix += strlen(buf); } } -} // end of ProcessParamStack +} static PARAM_STACK *PushParamStack(int tag_type) -{//============================================= +{ int ix; PARAM_STACK *sp; @@ -1324,11 +1324,11 @@ static PARAM_STACK *PushParamStack(int tag_type) sp->parameter[ix] = -1; } return(sp); -} // end of PushParamStack +} static void PopParamStack(int tag_type, char *outbuf, int *outix) -{//============================================================== +{ // unwind the stack up to and including the previous tag of this type int ix; int top = 0; @@ -1348,12 +1348,12 @@ static void PopParamStack(int tag_type, char *outbuf, int *outix) n_param_stack = top; } ProcessParamStack(outbuf, outix); -} // end of PopParamStack +} static wchar_t *GetSsmlAttribute(wchar_t *pw, const char *name) -{//============================================================ +{ // Gets the value string for an attribute. // Returns NULL if the attribute is not present int ix; @@ -1384,11 +1384,11 @@ static wchar_t *GetSsmlAttribute(wchar_t *pw, const char *name) pw++; } return(NULL); -} // end of GetSsmlAttribute +} static int attrcmp(const wchar_t *string1, const char *string2) -{//============================================================ +{ int ix; if(string1 == NULL) @@ -1404,7 +1404,7 @@ static int attrcmp(const wchar_t *string1, const char *string2) static int attrlookup(const wchar_t *string1, const MNEM_TAB *mtab) -{//================================================================ +{ int ix; for(ix=0; mtab[ix].mnem != NULL; ix++) @@ -1417,7 +1417,7 @@ static int attrlookup(const wchar_t *string1, const MNEM_TAB *mtab) static int attrnumber(const wchar_t *pw, int default_value, int type) -{//================================================================== +{ int value = 0; if((pw == NULL) || !IsDigit09(*pw)) @@ -1433,12 +1433,12 @@ static int attrnumber(const wchar_t *pw, int default_value, int type) value *= 1000; } return(value); -} // end of attrnumber +} static int attrcopy_utf8(char *buf, const wchar_t *pw, int len) -{//============================================================ +{ // Convert attribute string into utf8, write to buf, and return its utf8 length unsigned int c; int ix = 0; @@ -1458,12 +1458,12 @@ static int attrcopy_utf8(char *buf, const wchar_t *pw, int len) } buf[ix] = 0; return(ix); -} // end of attrcopy_utf8 +} static int attr_prosody_value(int param_type, const wchar_t *pw, int *value_out) -{//============================================================================= +{ int sign = 0; wchar_t *tail; double value; @@ -1519,11 +1519,11 @@ static int attr_prosody_value(int param_type, const wchar_t *pw, int *value_out) *value_out = (int)value; return(sign); // -1, 0, or 1 -} // end of attr_prosody_value +} int AddNameData(const char *name, int wide) -{//======================================== +{ // Add the name to the namedata and return its position // (Used by the Windows SAPI wrapper) int ix; @@ -1553,11 +1553,11 @@ int AddNameData(const char *name, int wide) memcpy(&namedata[ix = namedata_ix],name,len); namedata_ix += len; return(ix); -} // end of AddNameData +} void SetVoiceStack(espeak_VOICE *v, const char *variant_name) -{//========================================================== +{ SSML_STACK *sp; sp = &ssml_stack[0]; @@ -1582,7 +1582,7 @@ void SetVoiceStack(espeak_VOICE *v, const char *variant_name) static int GetVoiceAttributes(wchar_t *pw, int tag_type) -{//===================================================== +{ // Determines whether voice attribute are specified in this tag, and if so, whether this means // a voice change. // If it's a closing tag, delete the top frame of the stack and determine whether this implies @@ -1657,11 +1657,11 @@ static int GetVoiceAttributes(wchar_t *pw, int tag_type) } return(0); -} // end of GetVoiceAttributes +} static void SetProsodyParameter(int param_type, wchar_t *attr1, PARAM_STACK *sp) -{//============================================================================= +{ int value; int sign; @@ -1729,11 +1729,11 @@ static void SetProsodyParameter(int param_type, wchar_t *attr1, PARAM_STACK *sp) sp->parameter[param_type] = speech_parameters[param_type] + (value*sign); } } -} // end of SetProsodyParemeter +} static int ReplaceKeyName(char *outbuf, int index, int *outix) -{//=========================================================== +{ // Replace some key-names by single characters, so they can be pronounced in different languages static MNEM_TAB keynames[] = { {"space ",0xe020}, @@ -1759,7 +1759,7 @@ static int ReplaceKeyName(char *outbuf, int index, int *outix) static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outbuf, int self_closing) -{//================================================================================================== +{ // xml_buf is the tag and attributes with a zero terminator in place of the original '>' // returns a clause terminator value. @@ -2213,16 +2213,16 @@ terminator=0; // ?? Sentence intonation, but no pause ?? return(CLAUSE_PARAGRAPH); } return(0); -} // end of ProcessSsmlTag +} static void RemoveChar(char *p) -{//======================= +{ // Replace a UTF-8 character by spaces int c; memset(p, ' ', utf8_in(&c, p)); -} // end of RemoveChar +} static MNEM_TAB xml_char_mnemonics[] = { @@ -2236,7 +2236,7 @@ static MNEM_TAB xml_char_mnemonics[] = { int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change) -{//================================================================================================================================= +{ /* Find the end of the current clause. Write the clause into buf @@ -2936,11 +2936,11 @@ if(option_ssml) parag=1; buf[ix] = ' '; buf[ix+1] = 0; return(CLAUSE_EOF); // end of file -} // end of ReadClause +} void InitNamedata(void) -{//==================== +{ namedata_ix = 0; if(namedata != NULL) { @@ -2952,7 +2952,7 @@ void InitNamedata(void) void InitText2(void) -{//================= +{ int param; ungot_char = 0; @@ -2978,4 +2978,3 @@ void InitText2(void) xmlbase = NULL; } - diff --git a/src/libespeak-ng/setlengths.c b/src/libespeak-ng/setlengths.c index 4429ea74..c33bc9f7 100644 --- a/src/libespeak-ng/setlengths.c +++ b/src/libespeak-ng/setlengths.c @@ -133,12 +133,10 @@ static int speed3 = 118; -//#define TEST_SPEED - #ifdef INCLUDE_SONIC void SetSpeed(int control) -{//======================= +{ int x; int s1; int wpm; @@ -297,12 +295,12 @@ speed.min_sample_len = (speed.min_sample_len * samplerate_native) / 22050; speed.clause_pause_factor = 16; } } -} // end of SetSpeed +} #else // not using sonic speed-up void SetSpeed(int control) -{//======================= +{ // This is the earlier version of SetSpeed() before sonic speed-up was added int x; int s1; @@ -420,13 +418,13 @@ void SetSpeed(int control) speed.clause_pause_factor = 16; } } -} // end of SetSpeed +} #endif // of INCLUDE_SONIC void SetParameter(int parameter, int value, int relative) -{//====================================================== +{ // parameter: reset-all, amp, pitch, speed, linelength, expression, capitals, number grouping // relative 0=absolute 1=relative @@ -485,12 +483,12 @@ void SetParameter(int parameter, int value, int relative) default: break; } -} // end of SetParameter +} static void DoEmbedded2(int *embix) -{//================================ +{ // There were embedded commands in the text at this point unsigned int word; @@ -509,7 +507,7 @@ static void DoEmbedded2(int *embix) void CalcLengths(Translator *tr) -{//============================== +{ int ix; int ix2; PHONEME_LIST *prev; @@ -971,5 +969,4 @@ if(p->type != phVOWEL) break; } } -} // end of CalcLengths - +} diff --git a/src/libespeak-ng/speak_lib.c b/src/libespeak-ng/speak_lib.c index d7b8ca99..a2f3e957 100644 --- a/src/libespeak-ng/speak_lib.c +++ b/src/libespeak-ng/speak_lib.c @@ -80,7 +80,7 @@ extern int saved_parameters[N_SPEECH_PARAM]; //Parameters saved on synthesis sta void WVoiceChanged(voice_t *wvoice) -{//================================= +{ // Voice change in wavegen voice_samplerate = wvoice->samplerate; } @@ -89,7 +89,7 @@ void WVoiceChanged(voice_t *wvoice) #ifdef USE_ASYNC static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event) -{//====================================================================== +{ ENTER("dispatch_audio"); int a_wave_can_be_played = fifo_is_command_enabled(); @@ -187,7 +187,7 @@ static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event) static int create_events(short* outbuf, int length, espeak_EVENT* event, uint32_t the_write_pos) -{//===================================================================== +{ int finished; int i=0; @@ -224,7 +224,7 @@ static int create_events(short* outbuf, int length, espeak_EVENT* event, uint32_ int sync_espeak_terminated_msg( uint32_t unique_identifier, void* user_data) -{//===================================================================== +{ ENTER("sync_espeak_terminated_msg"); int finished=0; @@ -265,7 +265,7 @@ int sync_espeak_terminated_msg( uint32_t unique_identifier, void* user_data) static void select_output(espeak_AUDIO_OUTPUT output_type) -{//======================================================= +{ my_mode = output_type; my_audio = NULL; synchronous_mode = 1; @@ -291,13 +291,13 @@ static void select_output(espeak_AUDIO_OUTPUT output_type) WavegenInitSound(); break; } -} // end of select_output +} int GetFileLength(const char *filename) -{//==================================== +{ struct stat statbuf; if(stat(filename,&statbuf) != 0) @@ -307,11 +307,11 @@ int GetFileLength(const char *filename) return(-2); // a directory return(statbuf.st_size); -} // end of GetFileLength +} char *Alloc(int size) -{//================== +{ char *p; if((p = (char *)malloc(size)) == NULL) fprintf(stderr,"Can't allocate memory\n"); // I was told that size+1 fixes a crash on 64-bit systems @@ -319,7 +319,7 @@ char *Alloc(int size) } void Free(void *ptr) -{//================= +{ if(ptr != NULL) free(ptr); } @@ -327,7 +327,7 @@ void Free(void *ptr) static void init_path(const char *path) -{//==================================== +{ #ifdef PLATFORM_WINDOWS HKEY RegKey; unsigned long size; @@ -382,7 +382,7 @@ static void init_path(const char *path) } static int initialise(int control) -{//=============================== +{ int param; int result; int srate = 22050; // default sample rate 22050 Hz @@ -418,7 +418,7 @@ static int initialise(int control) static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text, int flags) -{//======================================================================================== +{ // Fill the buffer with output sound int length; int finished = 0; @@ -550,7 +550,7 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text, } } return(EE_OK); -} // end of Synthesize +} #ifdef DEBUG_ENABLED static const char* label[] = { @@ -568,7 +568,7 @@ static const char* label[] = { void MarkerEvent(int type, unsigned int char_position, int value, int value2, unsigned char *out_ptr) -{//================================================================================================== +{ // type: 1=word, 2=sentence, 3=named mark, 4=play audio, 5=end, 7=phoneme ENTER("MarkerEvent"); espeak_EVENT *ep; @@ -609,7 +609,7 @@ void MarkerEvent(int type, unsigned int char_position, int value, int value2, un { ep->id.number = value; } -} // end of MarkerEvent +} @@ -617,7 +617,7 @@ void MarkerEvent(int type, unsigned int char_position, int value, int value2, un espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, size_t size, unsigned int position, espeak_POSITION_TYPE position_type, unsigned int end_position, unsigned int flags, void* user_data) -{//=========================================================================== +{ #ifdef DEBUG_ENABLED ENTER("sync_espeak_Synth"); @@ -660,7 +660,7 @@ espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, SHOW_TIME("LEAVE sync_espeak_Synth"); return aStatus; -} // end of sync_espeak_Synth +} @@ -668,7 +668,7 @@ espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size, const char *index_mark, unsigned int end_position, unsigned int flags, void* user_data) -{//========================================================================= +{ espeak_ERROR aStatus; InitText(flags); @@ -689,12 +689,12 @@ espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void * SHOW_TIME("LEAVE sync_espeak_Synth_Mark"); return (aStatus); -} // end of sync_espeak_Synth_Mark +} void sync_espeak_Key(const char *key) -{//================================== +{ // symbolic name, symbolicname_character - is there a system resource of symbolic names per language? int letter; int ix; @@ -714,7 +714,7 @@ void sync_espeak_Key(const char *key) void sync_espeak_Char(wchar_t character) -{//===================================== +{ // is there a system resource of character names per language? char buf[80]; my_unique_identifier = 0; @@ -727,7 +727,7 @@ void sync_espeak_Char(wchar_t character) void sync_espeak_SetPunctuationList(const wchar_t *punctlist) -{//========================================================== +{ // Set the list of punctuation which are spoken for "some". my_unique_identifier = 0; my_user_data = NULL; @@ -738,7 +738,7 @@ void sync_espeak_SetPunctuationList(const wchar_t *punctlist) wcsncpy(option_punctlist, punctlist, N_PUNCTLIST); option_punctlist[N_PUNCTLIST-1] = 0; } -} // end of sync_espeak_SetPunctuationList +} @@ -747,7 +747,7 @@ void sync_espeak_SetPunctuationList(const wchar_t *punctlist) ESPEAK_API void espeak_SetSynthCallback(t_espeak_callback* SynthCallback) -{//====================================================================== +{ ENTER("espeak_SetSynthCallback"); synth_callback = SynthCallback; #ifdef USE_ASYNC @@ -756,19 +756,19 @@ ESPEAK_API void espeak_SetSynthCallback(t_espeak_callback* SynthCallback) } ESPEAK_API void espeak_SetUriCallback(int (* UriCallback)(int, const char*, const char *)) -{//======================================================================================= +{ ENTER("espeak_SetUriCallback"); uri_callback = UriCallback; } ESPEAK_API void espeak_SetPhonemeCallback(int (* PhonemeCallback)(const char*)) -{//=========================================================================== +{ phoneme_callback = PhonemeCallback; } ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path, int options) -{//============================================================================================================= +{ ENTER("espeak_Initialize"); int param; @@ -841,7 +841,7 @@ ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size, espeak_POSITION_TYPE position_type, unsigned int end_position, unsigned int flags, unsigned int* unique_identifier, void* user_data) -{//===================================================================================== +{ #ifdef DEBUG_ENABLED ENTER("espeak_Synth"); SHOW("espeak_Synth > position=%d, position_type=%d, end_position=%d, flags=%d, user_data=0x%x, text=%s\n", position, position_type, end_position, flags, user_data, text); @@ -896,7 +896,7 @@ ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size, #endif return a_error; -} // end of espeak_Synth +} @@ -906,7 +906,7 @@ ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size, unsigned int flags, unsigned int* unique_identifier, void* user_data) -{//========================================================================= +{ #ifdef DEBUG_ENABLED ENTER("espeak_Synth_Mark"); SHOW("espeak_Synth_Mark > index_mark=%s, end_position=%d, flags=%d, text=%s\n", index_mark, end_position, flags, text); @@ -962,12 +962,12 @@ ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size, #endif return a_error; -} // end of espeak_Synth_Mark +} ESPEAK_API espeak_ERROR espeak_Key(const char *key) -{//================================================ +{ ENTER("espeak_Key"); // symbolic name, symbolicname_character - is there a system resource of symbolicnames per language @@ -998,7 +998,7 @@ ESPEAK_API espeak_ERROR espeak_Key(const char *key) ESPEAK_API espeak_ERROR espeak_Char(wchar_t character) -{//=========================================== +{ ENTER("espeak_Char"); // is there a system resource of character names per language? @@ -1031,24 +1031,24 @@ ESPEAK_API espeak_ERROR espeak_Char(wchar_t character) ESPEAK_API espeak_ERROR espeak_SetVoiceByName(const char *name) -{//============================================================ +{ ENTER("espeak_SetVoiceByName"); return(SetVoiceByName(name)); -} // end of espeak_SetVoiceByName +} ESPEAK_API espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_selector) -{//============================================================================== +{ ENTER("espeak_SetVoiceByProperties"); return(SetVoiceByProperties(voice_selector)); -} // end of espeak_SetVoiceByProperties +} ESPEAK_API int espeak_GetParameter(espeak_PARAMETER parameter, int current) -{//======================================================================== +{ ENTER("espeak_GetParameter"); // current: 0=default value, 1=current value if(current) @@ -1059,11 +1059,11 @@ ESPEAK_API int espeak_GetParameter(espeak_PARAMETER parameter, int current) { return(param_defaults[parameter]); } -} // end of espeak_GetParameter +} ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int relative) -{//============================================================================================= +{ ENTER("espeak_SetParameter"); if(f_logespeak) @@ -1095,7 +1095,7 @@ ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int valu ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist) -{//================================================================ +{ ENTER("espeak_SetPunctuationList"); // Set the list of punctuation which are spoken for "some". @@ -1119,11 +1119,11 @@ ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist) sync_espeak_SetPunctuationList(punctlist); return(EE_OK); #endif -} // end of espeak_SetPunctuationList +} ESPEAK_API void espeak_SetPhonemeTrace(int phonememode, FILE *stream) -{//=================================================================== +{ ENTER("espeak_SetPhonemes"); /* phonememode: Controls the output of phoneme symbols for the text bits 0-2: @@ -1142,11 +1142,11 @@ ESPEAK_API void espeak_SetPhonemeTrace(int phonememode, FILE *stream) if(stream == NULL) f_trans = stderr; -} // end of espeak_SetPhonemes +} ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, int phonememode) -{//================================================================================================= +{ /* phoneme_mode bit 1: 0=eSpeak's ascii phoneme names, 1= International Phonetic Alphabet (as UTF-8 characters). bit 7: use (bits 8-23) as a tie within multi-letter phonemes names @@ -1160,14 +1160,14 @@ ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, ESPEAK_API void espeak_CompileDictionary(const char *path, FILE *log, int flags) -{//============================================================================= +{ ENTER("espeak_CompileDictionary"); CompileDictionary(path, dictionary_name, log, NULL, flags); -} // end of espeak_CompileDirectory +} ESPEAK_API espeak_ERROR espeak_Cancel(void) -{//=============================== +{ #ifdef USE_ASYNC ENTER("espeak_Cancel"); fifo_stop(); @@ -1185,11 +1185,11 @@ ESPEAK_API espeak_ERROR espeak_Cancel(void) SetParameter(i, saved_parameters[i], 0); return EE_OK; -} // end of espeak_Cancel +} ESPEAK_API int espeak_IsPlaying(void) -{//================================== +{ #ifdef USE_ASYNC if((my_mode == AUDIO_OUTPUT_PLAYBACK) && wave_is_busy(my_audio)) return(1); @@ -1198,11 +1198,11 @@ ESPEAK_API int espeak_IsPlaying(void) #else return(0); #endif -} // end of espeak_IsPlaying +} ESPEAK_API espeak_ERROR espeak_Synchronize(void) -{//============================================= +{ espeak_ERROR berr = err; #ifdef USE_ASYNC SHOW_TIME("espeak_Synchronize > ENTER"); @@ -1214,14 +1214,14 @@ ESPEAK_API espeak_ERROR espeak_Synchronize(void) err = EE_OK; SHOW_TIME("espeak_Synchronize > LEAVE"); return berr; -} // end of espeak_Synchronize +} extern void FreePhData(void); extern void FreeVoiceList(void); ESPEAK_API espeak_ERROR espeak_Terminate(void) -{//=========================================== +{ ENTER("espeak_Terminate"); #ifdef USE_ASYNC fifo_stop(); @@ -1250,10 +1250,10 @@ ESPEAK_API espeak_ERROR espeak_Terminate(void) } return EE_OK; -} // end of espeak_Terminate +} ESPEAK_API const char *espeak_Info(const char **ptr) -{//================================================= +{ if(ptr != NULL) { *ptr = path_home; @@ -1262,5 +1262,3 @@ ESPEAK_API const char *espeak_Info(const char **ptr) } #pragma GCC visibility pop - - diff --git a/src/libespeak-ng/spect.c b/src/libespeak-ng/spect.c index 11e0a181..b37ca68b 100644 --- a/src/libespeak-ng/spect.c +++ b/src/libespeak-ng/spect.c @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2007 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2013-2015 by Reece H. Dunn * + * Copyright (C) 2013-2015 Reece H. Dunn * * * * 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 * @@ -58,7 +58,7 @@ static double read_double(FILE *stream) } float polint(float xa[],float ya[],int n,float x) -{//============================================== +{ // General polinomial interpolation routine, xa[1...n] ya[1...n] int i,m,ns=1; float den,dif,dift,ho,hp,w; @@ -92,11 +92,11 @@ float polint(float xa[],float ya[],int n,float x) y += ((2*ns < (n-m) ? c[ns+1] : d[ns--])); } return(y); -} // end of polint +} static void PeaksZero(peak_t *sp, peak_t *zero) -{//===================================== +{ int pk; memcpy(zero,sp,sizeof(peak_t)*N_PEAKS); @@ -104,7 +104,7 @@ static void PeaksZero(peak_t *sp, peak_t *zero) for(pk=0; pkspect = spect_data; return(0); -} // End of SpectFrame::Load +} double GetFrameRms(SpectFrame *frame, int seq_amplitude) -{//========================================= +{ int h; float total=0; int maxh; @@ -271,7 +271,7 @@ SpectSeq *SpectSeqCreate() } void SpectSeqDestroy(SpectSeq *spect) -{//================== +{ int ix; if(spect->frames != NULL) { @@ -288,7 +288,7 @@ void SpectSeqDestroy(SpectSeq *spect) static float GetFrameLength(SpectSeq *spect, int frame) -{//=============================================================== +{ int ix; float adjust=0; @@ -305,7 +305,7 @@ static float GetFrameLength(SpectSeq *spect, int frame) int LoadSpectSeq(SpectSeq *spect, const char *filename) -{//======================================= +{ short n, temp; int ix; uint32_t id1, id2, name_len; @@ -418,4 +418,4 @@ else spect->frames[ix]->length_adjust = spect->frames[ix]->length - GetFrameLength(spect,ix); } return(0); -} // end of SpectSeq::Load +} diff --git a/src/libespeak-ng/spect.h b/src/libespeak-ng/spect.h index 171d77f6..dd06f470 100644 --- a/src/libespeak-ng/spect.h +++ b/src/libespeak-ng/spect.h @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2007 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2013-2015 by Reece H. Dunn * + * Copyright (C) 2013-2015 Reece H. Dunn * * * * 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 * diff --git a/src/libespeak-ng/synth_mbrola.c b/src/libespeak-ng/synth_mbrola.c index 98430278..87cc6203 100644 --- a/src/libespeak-ng/synth_mbrola.c +++ b/src/libespeak-ng/synth_mbrola.c @@ -108,7 +108,7 @@ static int mbrola_control = 0; static int mbr_name_prefix = 0; espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int *srate) -{//=================================================================================== +{ // Load a phoneme name translation table from espeak-data/mbrola int size; @@ -194,11 +194,11 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int strcpy(mbrola_name,mbrola_voice); mbrola_delay = 1000; // improve synchronization of events return(EE_OK); -} // end of LoadMbrolaTable +} static int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev, PHONEME_TAB *ph_next, int *name2, int *split, int *control) -{//========================================================================================================================================== +{ // Look up a phoneme in the mbrola phoneme name translation table // It may give none, 1, or 2 mbrola phonemes MBROLA_TAB *pr; @@ -288,7 +288,7 @@ static int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev static char *WritePitch(int env, int pitch1, int pitch2, int split, int final) -{//=========================================================================== +{ // final=1: only give the final pitch value. int x; int ix; @@ -401,11 +401,11 @@ static char *WritePitch(int env, int pitch1, int pitch2, int split, int final) if(final) sprintf(output,"\t100 %d\n",p_end); return(output); -} // end of WritePitch +} int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbrola) -{//================================================================================= +{ // Generate a mbrola pho file unsigned int name; int len; @@ -628,11 +628,11 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr } return 0; -} // end of MbrolaTranslate +} int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume) -{//================================================================== +{ FILE *f_mbrola = NULL; if(*n_ph == 0) @@ -652,7 +652,7 @@ int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume) int MbrolaFill(int length, int resume, int amplitude) -{//================================================== +{ // Read audio data from Mbrola (length is in millisecs) static int n_samples; @@ -690,7 +690,7 @@ int MbrolaFill(int length, int resume, int amplitude) void MbrolaReset(void) -{//=================== +{ // Reset the Mbrola engine and flush the pending audio reset_MBR(); diff --git a/src/libespeak-ng/synthdata.c b/src/libespeak-ng/synthdata.c index eb7fce64..9a3ca3d6 100644 --- a/src/libespeak-ng/synthdata.c +++ b/src/libespeak-ng/synthdata.c @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2014 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * * * 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 * @@ -71,7 +71,7 @@ int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsig static char *ReadPhFile(void *ptr, const char *fname, int *size) -{//============================================================= +{ FILE *f_in; char *p; unsigned int length; @@ -105,11 +105,11 @@ static char *ReadPhFile(void *ptr, const char *fname, int *size) if(size != NULL) *size = length; return(p); -} // end of ReadPhFile +} int LoadPhData(int *srate) -{//======================== +{ int ix; int n_phonemes; int version; @@ -169,11 +169,11 @@ int LoadPhData(int *srate) if(srate != NULL) *srate = rate; return(result); -} // end of LoadPhData +} void FreePhData(void) -{//================== +{ Free(phoneme_tab_data); Free(phoneme_index); Free(phondata_ptr); @@ -186,7 +186,7 @@ void FreePhData(void) int PhonemeCode(unsigned int mnem) -{//=============================== +{ int ix; for(ix=0; ixmnemonic)); } static bool StressCondition(Translator *tr, PHONEME_LIST *plist, int condition, int control) -{//======================================================================================== +{ // condition: // 0 if diminished, 1 if unstressed, 2 if not stressed, 3 if stressed, 4 if max stress @@ -597,11 +597,11 @@ static bool StressCondition(Translator *tr, PHONEME_LIST *plist, int condition, } return(false); -} // end of StressCondition +} static int CountVowelPosition(PHONEME_LIST *plist) -{//=============================================== +{ int count = 0; for(;;) @@ -613,11 +613,11 @@ static int CountVowelPosition(PHONEME_LIST *plist) plist--; } return(count); -} // end of CoundVowelPosition +} static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, USHORT *p_prog, WORD_PH_DATA *worddata) -{//======================================================================================================================== +{ int which; int ix; unsigned int data; @@ -880,11 +880,11 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, } } return(false); -} // end of InterpretCondition +} static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT **p_prog, int instn_type) -{//======================================================================================================== +{ USHORT *prog; int voweltype; signed char x; @@ -909,11 +909,11 @@ static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT } *p_prog += 12; -} // end of SwitchVowelType +} int NumInstnWords(USHORT *prog) -{//============================ +{ int instn; int instn2; int instn_type; @@ -963,12 +963,12 @@ int NumInstnWords(USHORT *prog) } return(2); } -} // end of NumInstnWords +} void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata, WORD_PH_DATA *worddata) -{//=================================================================================================================== +{ // control: //bit 0: PreVoicing //bit 8: change phonemes @@ -1269,11 +1269,11 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_ plist->phontab_addr = phdata->sound_addr[1]; // WAV address plist->sound_param = phdata->sound_param[1]; } -} // end of InterpretPhoneme +} void InterpretPhoneme2(int phcode, PHONEME_DATA *phdata) -{//===================================================== +{ // Examine the program of a single isolated phoneme int ix; PHONEME_LIST plist[4]; @@ -1290,4 +1290,4 @@ void InterpretPhoneme2(int phcode, PHONEME_DATA *phdata) plist[2].sourceix = 1; InterpretPhoneme(NULL, 0, &plist[1], phdata, NULL); -} // end of InterpretPhoneme2 +} diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index ee96586a..9f3749e8 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -76,7 +76,7 @@ static PHONEME_LIST next_pause; const char *WordToString(unsigned int word) -{//======================================== +{ // Convert a phoneme mnemonic word into a string int ix; static char buf[5]; @@ -90,7 +90,7 @@ const char *WordToString(unsigned int word) void SynthesizeInit() -{//================== +{ last_pitch_cmd = 0; last_amp_cmd = 0; last_frame = NULL; @@ -104,7 +104,7 @@ void SynthesizeInit() static void EndAmplitude(void) -{//=========================== +{ if(amp_length > 0) { if(wcmdq[last_amp_cmd][1] == 0) @@ -116,7 +116,7 @@ static void EndAmplitude(void) static void EndPitch(int voice_break) -{//================================== +{ // posssible end of pitch envelope, fill in the length if((pitch_length > 0) && (last_pitch_cmd >= 0)) { @@ -134,12 +134,12 @@ static void EndPitch(int voice_break) syllable_centre = -1; memset(vowel_transition,0,sizeof(vowel_transition)); } -} // end of EndPitch +} static void DoAmplitude(int amp, unsigned char *amp_env) -{//===================================================== +{ long64 *q; last_amp_cmd = wcmdq_tail; @@ -151,12 +151,12 @@ static void DoAmplitude(int amp, unsigned char *amp_env) q[2] = (long64)amp_env; q[3] = amp; WcmdqInc(); -} // end of DoAmplitude +} static void DoPitch(unsigned char *env, int pitch1, int pitch2) -{//============================================================ +{ long64 *q; EndPitch(0); @@ -180,12 +180,12 @@ static void DoPitch(unsigned char *env, int pitch1, int pitch2) q[2] = (long64)env; q[3] = (pitch1 << 16) + pitch2; WcmdqInc(); -} // end of DoPitch +} int PauseLength(int pause, int control) -{//==================================== +{ unsigned int len; if(control == 0) @@ -207,7 +207,7 @@ int PauseLength(int pause, int control) static void DoPause(int length, int control) -{//========================================= +{ // length in nominal mS // control = 1, less shortening at fast speeds unsigned int len; @@ -242,14 +242,14 @@ static void DoPause(int length, int control) wcmdq[wcmdq_tail][1] = fmt_amplitude = 0; WcmdqInc(); } -} // end of DoPause +} extern int seq_len_adjust; // temporary fix to advance the start point for playing the wav sample static int DoSample2(int index, int which, int std_length, int control, int length_mod, int amp) -{//============================================================================================= +{ int length; int wav_length; int wav_scale; @@ -390,12 +390,12 @@ static int DoSample2(int index, int which, int std_length, int control, int leng } return(length); -} // end of DoSample2 +} int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp) -{//========================================================= +{ int amp2; int len; EndPitch(1); @@ -425,13 +425,13 @@ int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp) } last_frame = NULL; return(len); -} // end of DoSample3 +} static frame_t *AllocFrame() -{//========================= +{ // Allocate a temporary spectrum frame for the wavegen queue. Use a pool which is big // enough to use a round-robin without checks. // Only needed for modifying spectra for blending to consonants @@ -448,7 +448,7 @@ static frame_t *AllocFrame() static void set_frame_rms(frame_t *fr, int new_rms) -{//================================================= +{ // Each frame includes its RMS amplitude value, so to set a new // RMS just adjust the formant amplitudes by the appropriate ratio @@ -491,12 +491,12 @@ static void set_frame_rms(frame_t *fr, int new_rms) h = fr->fheight[ix] * x; fr->fheight[ix] = h/0x200; } -} /* end of set_frame_rms */ +} static void formants_reduce_hf(frame_t *fr, int level) -{//==================================================== +{ // change height of peaks 2 to 8, percentage int ix; int x; @@ -513,7 +513,7 @@ static void formants_reduce_hf(frame_t *fr, int level) static frame_t *CopyFrame(frame_t *frame1, int copy) -{//================================================= +{ // create a copy of the specified frame in temporary buffer frame_t *frame2; @@ -535,7 +535,7 @@ static frame_t *CopyFrame(frame_t *frame1, int copy) static frame_t *DuplicateLastFrame(frameref_t *seq, int n_frames, int length) -{//========================================================================== +{ frame_t *fr; seq[n_frames-1].length = length; @@ -547,7 +547,7 @@ static frame_t *DuplicateLastFrame(frameref_t *seq, int n_frames, int length) static void AdjustFormants(frame_t *fr, int target, int min, int max, int f1_adj, int f3_adj, int hf_reduce, int flags) -{//==================================================================================================================== +{ int x; target = (target * voice->formant_factor)/256; @@ -593,7 +593,7 @@ static void AdjustFormants(frame_t *fr, int target, int min, int max, int f1_adj static int VowelCloseness(frame_t *fr) -{//=================================== +{ // return a value 0-3 depending on the vowel's f1 int f1; @@ -608,7 +608,7 @@ static int VowelCloseness(frame_t *fr) int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsigned int data2, PHONEME_TAB *other_ph, int which) -{//============================================================================================================================== +{ int ix; int formant; int next_rms; @@ -756,12 +756,12 @@ if(voice->klattv[0]) if(flags & 16) return(len); return(0); -} // end of FormantTransition2 +} static void SmoothSpect(void) -{//========================== +{ // Limit the rate of frequence change of formants, to reduce chirping long64 *q; @@ -961,11 +961,11 @@ static void SmoothSpect(void) } syllable_start = syllable_end; -} // end of SmoothSpect +} static void StartSyllable(void) -{//============================ +{ // start of syllable, if not already started if(syllable_end == syllable_start) syllable_end = wcmdq_tail; @@ -974,7 +974,7 @@ static void StartSyllable(void) int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_LIST *plist, int modulation) -{//======================================================================================================== +{ // which: 0 not a vowel, 1 start of vowel, 2 body and end of vowel // length_mod: 256 = 100% // modulation: -1 = don't write to wcmdq @@ -1189,13 +1189,13 @@ if(which==1) return(total_len); -} // end of DoSpect +} void DoMarker(int type, int char_posn, int length, int value) -{//========================================================== +{ // This could be used to return an index to the word currently being spoken // Type 1=word, 2=sentence, 3=named marker, 4=play audio, 5=end if(WcmdqFree() > 5) @@ -1205,11 +1205,11 @@ void DoMarker(int type, int char_posn, int length, int value) wcmdq[wcmdq_tail][2] = value; WcmdqInc(); } -} // end of DoMarker +} void DoPhonemeMarker(int type, int char_posn, int length, char *name) -{//================================================================== +{ // This could be used to return an index to the word currently being spoken // Type 7=phoneme int *p; @@ -1223,22 +1223,22 @@ void DoPhonemeMarker(int type, int char_posn, int length, char *name) wcmdq[wcmdq_tail][3] = p[1]; WcmdqInc(); } -} // end of DoMarker +} #ifdef INCLUDE_SONIC void DoSonicSpeed(int value) -{//========================= +{ // value, multiplier * 1024 wcmdq[wcmdq_tail][0] = WCMD_SONIC_SPEED; wcmdq[wcmdq_tail][1] = value; WcmdqInc(); -} // end of DoSonicSpeed +} #endif void DoVoiceChange(voice_t *v) -{//=========================== +{ // allocate memory for a copy of the voice data, and free it in wavegenfill() voice_t *v2; @@ -1251,7 +1251,7 @@ void DoVoiceChange(voice_t *v) void DoEmbedded(int *embix, int sourceix) -{//====================================== +{ // There were embedded commands in the text at this point unsigned int word; // bit 7=last command for this word, bits 5,6 sign, bits 0-4 command unsigned int value; @@ -1311,7 +1311,7 @@ void DoEmbedded(int *embix, int sourceix) int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume) -{//============================================================ +{ static int ix; static int embedded_ix; static int word_count; @@ -1816,7 +1816,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume) } return(0); // finished the phoneme list -} // end of Generate +} @@ -1825,7 +1825,7 @@ static int timer_on = 0; static int paused = 0; int SynthOnTimer() -{//=============== +{ if(!timer_on) { return(WavegenCloseSound()); @@ -1846,14 +1846,14 @@ int SynthOnTimer() int SynthStatus() -{//============== +{ return(timer_on | paused); } int SpeakNextClause(FILE *f_in, const void *text_in, int control) -{//============================================================== +{ // Speak text from file (f_in) or memory (text_in) // control 0: start // either f_in or text_in is set, the other must be NULL @@ -1994,5 +1994,4 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control) } return(1); -} // end of SpeakNextClause - +} diff --git a/src/libespeak-ng/synthesize.h b/src/libespeak-ng/synthesize.h index 461f5398..6f63e774 100644 --- a/src/libespeak-ng/synthesize.h +++ b/src/libespeak-ng/synthesize.h @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2014 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * * * 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 * diff --git a/src/libespeak-ng/tr_languages.c b/src/libespeak-ng/tr_languages.c index 978cefd6..82c6749d 100644 --- a/src/libespeak-ng/tr_languages.c +++ b/src/libespeak-ng/tr_languages.c @@ -106,7 +106,7 @@ ALPHABET alphabets [] = { ALPHABET *AlphabetFromName(const char *name) -{//========================================== +{ ALPHABET *alphabet; for(alphabet=alphabets; alphabet->name != NULL; alphabet++) @@ -119,7 +119,7 @@ ALPHABET *AlphabetFromName(const char *name) ALPHABET *AlphabetFromChar(int c) -{//=============================== +{ // Find the alphabet from a character. ALPHABET *alphabet = alphabets; @@ -144,12 +144,12 @@ static void Translator_Russian(Translator *tr); static void SetLetterVowel(Translator *tr, int c) -{//============================================== +{ tr->letter_bits[c] = (tr->letter_bits[c] & 0x40) | 0x81; // keep value for group 6 (front vowels e,i,y) } static void ResetLetterBits(Translator *tr, int groups) -{//==================================================== +{ // Clear all the specified groups unsigned int ix; unsigned int mask; @@ -163,7 +163,7 @@ static void ResetLetterBits(Translator *tr, int groups) } static void SetLetterBits(Translator *tr, int group, const char *string) -{//===================================================================== +{ int bits; unsigned char c; @@ -173,7 +173,7 @@ static void SetLetterBits(Translator *tr, int group, const char *string) } static void SetLetterBitsRange(Translator *tr, int group, int first, int last) -{//=========================================================================== +{ int bits; int ix; @@ -203,7 +203,7 @@ const char string_ordinal[] = {0xc2,0xba,0}; // masculine ordinal character, UT static Translator* NewTranslator(void) -{//=================================== +{ Translator *tr; int ix; static const unsigned char stress_amps2[] = {18,18, 20,20, 20,22, 22,20 }; @@ -394,7 +394,7 @@ static const unsigned char ru_vowels[] = {0x10,0x15,0x31,0x18,0x1e,0x23,0x2b,0x2 static const unsigned char ru_consonants[] = {0x11,0x12,0x13,0x14,0x16,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2c, 0x73,0x7b,0x83,0x9b,0}; static void SetCyrillicLetters(Translator *tr) -{//=========================================== +{ // character codes offset by 0x420 static const char ru_soft[] = {0x2c,0x19,0x27,0x29,0}; // letter group B [k ts; s;] static const char ru_hard[] = {0x2a,0x16,0x26,0x28,0}; // letter group H [S Z ts] @@ -417,11 +417,11 @@ static void SetCyrillicLetters(Translator *tr) SetLetterBits(tr,LETTERGP_G,ru_voiced); SetLetterBits(tr,LETTERGP_Y,ru_ivowels); SetLetterBits(tr,LETTERGP_VOWEL2,(char *)ru_vowels); -} // end of SetCyrillicLetters +} void SetIndicLetters(Translator *tr) -{//================================= +{ // Set letter types for Indic scripts, Devanagari, Tamill, etc static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,0x7b,0x7c,0x7e,0x7f,0}; static const char dev_vowels2[] = {0x60,0x61, 0x55,0x56,0x57,0x62,0x63,0}; // non-consecutive vowels and vowel-signs @@ -447,7 +447,7 @@ void SetIndicLetters(Translator *tr) void SetupTranslator(Translator *tr, const short *lengths, const unsigned char *amps) -{//================================================================================== +{ if(lengths != NULL) memcpy(tr->stress_lengths,lengths,sizeof(tr->stress_lengths)); if(amps != NULL) @@ -456,7 +456,7 @@ void SetupTranslator(Translator *tr, const short *lengths, const unsigned char * Translator *SelectTranslator(const char *name) -{//=========================================== +{ int name2 = 0; Translator *tr; @@ -1668,11 +1668,11 @@ SetLengthMods(tr,3); // all equal ProcessLanguageOptions(&tr->langopts); return(tr); -} // end of SelectTranslator +} void ProcessLanguageOptions(LANGUAGE_OPTIONS *langopts) -{//===================================================== +{ if(langopts->numbers & NUM_DECIMAL_COMMA) { // use . and ; for thousands and decimal separators @@ -1685,13 +1685,9 @@ void ProcessLanguageOptions(LANGUAGE_OPTIONS *langopts) } } -//********************************************************************************************************** - - - static void Translator_Russian(Translator *tr) -{//=========================================== +{ static const unsigned char stress_amps_ru[] = {16,16, 18,18, 20,24, 24,22 }; static const short stress_lengths_ru[8] = {150,140, 220,220, 0,0, 260,280}; static const char ru_ivowels2[] = {0x2c,0x15,0x18,0x2e,0x2f,0}; // add more vowels to letter group Y (iotated vowels & soft-sign) @@ -1711,4 +1707,4 @@ static void Translator_Russian(Translator *tr) tr->langopts.phoneme_change = 1; tr->langopts.testing = 2; -} // end of Translator_Russian +} diff --git a/src/libespeak-ng/translate.c b/src/libespeak-ng/translate.c index a0b80626..e6f15730 100644 --- a/src/libespeak-ng/translate.c +++ b/src/libespeak-ng/translate.c @@ -313,7 +313,7 @@ static unsigned char length_mods_en[100] = { 105,120,100,105,105,122,125,110,105, 100, /* r */ 105,120, 95,105,100,115,120,110,100, 100, /* N */ 100,120,100,100,100,100,100,100,100, 100 -}; // SPARE +}; // as above, but for the last syllable in a word static unsigned char length_mods_en0[100] = { @@ -328,7 +328,7 @@ static unsigned char length_mods_en0[100] = { 105,150,100,105,105,122,135,120,105, 100, /* r */ 105,150,100,105,105,115,135,110,105, 100, /* N */ 100,100,100,100,100,100,100,100,100, 100 -}; // SPARE +}; static unsigned char length_mods_equal[100] = { @@ -343,7 +343,7 @@ static unsigned char length_mods_equal[100] = { 110,120,100,110,110,110,110,110,110, 110, /* r */ 110,120,100,110,110,110,110,110,110, 110, /* N */ 110,120,100,110,110,110,110,110,110, 110 -}; // SPARE +}; static unsigned char *length_mod_tabs[6] = { @@ -357,7 +357,7 @@ static unsigned char *length_mod_tabs[6] = { void SetLengthMods(Translator *tr, int value) -{//========================================== +{ int value2; tr->langopts.length_mods0 = tr->langopts.length_mods = length_mod_tabs[value % 100]; @@ -370,7 +370,7 @@ void SetLengthMods(Translator *tr, int value) int IsAlpha(unsigned int c) -{//======================== +{ // Replacement for iswalph() which also checks for some in-word symbols static const unsigned short extra_indic_alphas[] = { @@ -428,14 +428,14 @@ int IsAlpha(unsigned int c) } int IsDigit09(unsigned int c) -{//============================ +{ if((c >= '0') && (c <= '9')) return(1); return(0); } int IsDigit(unsigned int c) -{//======================== +{ if(iswdigit(c)) return(1); @@ -446,21 +446,19 @@ int IsDigit(unsigned int c) } int IsSpace(unsigned int c) -{//======================== +{ if(c == 0) return(0); if((c >= 0x2500) && (c < 0x25a0)) return(1); // box drawing characters if((c >= 0xfff9) && (c <= 0xffff)) return(1); // unicode specials -// if(wcschr(chars_space,c)) -// return(1); return(iswspace(c)); } void DeleteTranslator(Translator *tr) -{//================================== +{ if(tr->data_dictlist != NULL) Free(tr->data_dictlist); Free(tr); @@ -468,7 +466,7 @@ void DeleteTranslator(Translator *tr) int lookupwchar(const unsigned short *list,int c) -{//============================================== +{ // Is the character c in the list ? int ix; @@ -482,7 +480,7 @@ int lookupwchar(const unsigned short *list,int c) int lookupwchar2(const unsigned short *list,int c) -{//============================================== +{ // Replace character c by another character. // Returns 0 = not found, 1 = delete character int ix; @@ -497,7 +495,7 @@ int lookupwchar2(const unsigned short *list,int c) int IsBracket(int c) -{//================= +{ if((c >= 0x2014) && (c <= 0x201f)) return(1); return(lookupwchar(brackets,c)); @@ -505,7 +503,7 @@ int IsBracket(int c) int utf8_out(unsigned int c, char *buf) -{//==================================== +{ // write a unicode character into a buffer as utf8 // returns the number of bytes written int n_bytes; @@ -538,11 +536,11 @@ int utf8_out(unsigned int c, char *buf) buf[j+1] = 0x80 + ((c >> shift) & 0x3f); } return(n_bytes+1); -} // end of utf8_out +} int utf8_nbytes(const char *buf) -{//============================= +{ // Returns the number of bytes for the first UTF-8 character in buf unsigned char c = (unsigned char)buf[0]; if(c < 0x80) @@ -556,7 +554,7 @@ int utf8_nbytes(const char *buf) int utf8_in2(int *c, const char *buf, int backwards) -{//================================================= +{ // Read a unicode characater from a UTF8 string // Returns the number of UTF8 bytes used. // backwards: set if we are moving backwards through the UTF8 string @@ -598,7 +596,7 @@ int utf8_in2(int *c, const char *buf, int backwards) int utf8_in(int *c, const char *buf) -{//================================= +{ // Read a unicode characater from a UTF8 string // Returns the number of UTF8 bytes used. return(utf8_in2(c,buf,0)); @@ -606,7 +604,7 @@ int utf8_in(int *c, const char *buf) char *strchr_w(const char *s, int c) -{//================================= +{ // return NULL for any non-ascii character if(c >= 0x80) return(NULL); @@ -615,7 +613,7 @@ char *strchr_w(const char *s, int c) int IsAllUpper(const char *word) -{//============================= +{ int c; while((*word != 0) && !isspace2(*word)) { @@ -628,7 +626,7 @@ int IsAllUpper(const char *word) static char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word) -{//============================================================================================ +{ int posn = 0; int capitals = 0; int non_initial = 0; @@ -652,12 +650,12 @@ static char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, } SetSpellingStress(tr,phonemes,spell_word,posn); return(word); -} // end of SpeakIndividualLetters +} static int CheckDottedAbbrev(char *word1, WORD_TAB *wtab) -{//===================================================== +{ int wc; int count = 0; int nbytes; @@ -717,13 +715,13 @@ static int CheckDottedAbbrev(char *word1, WORD_TAB *wtab) dictionary_skipwords = (count - 1)*2; } return(count); -} // end of CheckDottedAbbrev +} extern char *phondata_ptr; int ChangeEquivalentPhonemes(Translator *tr, int lang2, char *phonemes) -{//==================================================================== +{ // tr: the original language // lang2: phoneme table number for the temporary language // phonemes: the phonemes to be replaced @@ -808,13 +806,13 @@ int ChangeEquivalentPhonemes(Translator *tr, int lang2, char *phonemes) fprintf(f_trans,"%s\n\n", phonbuf); } return(1); -} // end of ChangeEquivalentPhonemes +} int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wtab, char *word_out) -{//================================================================================================== +{ // word1 is terminated by space (0x20) character char *word1; @@ -1611,12 +1609,12 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt dictionary_flags[0] |= was_unpronouncable; memcpy(word_start, word_copy2, word_copy_length); return(dictionary_flags[0]); -} // end of TranslateWord +} static void SetPlist2(PHONEME_LIST2 *p, unsigned char phcode) -{//========================================================== +{ p->phcode = phcode; p->stresslevel = 0; p->tone_ph = 0; @@ -1626,7 +1624,7 @@ static void SetPlist2(PHONEME_LIST2 *p, unsigned char phcode) } static int CountSyllables(unsigned char *phonemes) -{//=============================================== +{ int count = 0; int phon; while((phon = *phonemes++) != 0) @@ -1639,7 +1637,7 @@ static int CountSyllables(unsigned char *phonemes) void Word_EmbeddedCmd() -{//==================== +{ // Process embedded commands for emphasis, sayas, and break int embedded_cmd; int value; @@ -1668,11 +1666,11 @@ void Word_EmbeddedCmd() break; } } while(((embedded_cmd & 0x80) == 0) && (embedded_read < embedded_ix)); -} // end of Word_EmbeddedCmd +} int SetTranslator2(const char *new_language) -{//========================================= +{ // Set translator2 to a second language int new_phoneme_tab; const char *new_phtab_name; @@ -1733,12 +1731,12 @@ int SetTranslator2(const char *new_language) if(translator2 != NULL) translator2->phonemes_repeat[0] = 0; return(new_phoneme_tab); -} // end of SetTranslator2 +} static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pause, int next_pause) -{//================================================================================================= +{ int flags=0; int stress; int next_stress; @@ -2283,12 +2281,12 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa tr->prev_dict_flags[0] = flags; return(flags); -} // end of TranslateWord2 +} static int EmbeddedCommand(unsigned int *source_index_out) -{//======================================================= +{ // An embedded command to change the pitch, volume, etc. // returns number of commands added to embedded_list @@ -2349,12 +2347,12 @@ static int EmbeddedCommand(unsigned int *source_index_out) embedded_list[embedded_ix++] = cmd + sign + (value << 8); *source_index_out = source_index; return(1); -} // end of EmbeddedCommand +} static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, int *insert, int *wordflags) -{//========================================================================================= +{ int ix; unsigned int word; unsigned int new_c, c2, c_lower; @@ -2423,7 +2421,7 @@ static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert, int *wordflags) -{//================================================================================================================ +{ // To allow language specific examination and replacement of characters int code; @@ -2506,7 +2504,7 @@ static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c, static const char *UCase_ga[] = {"bp","bhf","dt","gc","hA","mb","nd","ng","ts","tA","nA",NULL}; int UpperCaseInWord(Translator *tr, char *word, int c) -{//===================================================== +{ int ix; int len; const char *p; @@ -2532,7 +2530,7 @@ int UpperCaseInWord(Translator *tr, char *word, int c) void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *tone_out, char **voice_change) -{//========================================================================================================== +{ int ix; int c; int cc; @@ -3496,14 +3494,14 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t return((void *)p_wchar_input); else return((void *)p_textinput); -} // end of TranslateClause +} void InitText(int control) -{//======================= +{ count_sentences = 0; count_words = 0; end_character_position = 0; @@ -3529,4 +3527,3 @@ void InitText(int control) InitNamedata(); } } - diff --git a/src/libespeak-ng/translate.h b/src/libespeak-ng/translate.h index 675eb03e..72fc8cd5 100644 --- a/src/libespeak-ng/translate.h +++ b/src/libespeak-ng/translate.h @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2014 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * * * 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 * @@ -603,7 +603,7 @@ typedef struct { typedef struct -{//=========== +{ LANGUAGE_OPTIONS langopts; int translator_name; diff --git a/src/libespeak-ng/voice.h b/src/libespeak-ng/voice.h index 5af10c4a..12c6b7f0 100644 --- a/src/libespeak-ng/voice.h +++ b/src/libespeak-ng/voice.h @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2007 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * * * 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 * diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index cf22b61c..b830861c 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2005 to 2015 by Jonathan Duddington * * email: jonsd@users.sourceforge.net * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * * * 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 * @@ -190,7 +190,7 @@ voice_t *voice = &voicedata; static char *fgets_strip(char *buf, int size, FILE *f_in) -{//====================================================== +{ // strip trailing spaces, and truncate lines at // comment int len; char *p; @@ -216,7 +216,7 @@ static char *fgets_strip(char *buf, int size, FILE *f_in) static int LookupTune(const char *name) -{//==================================== +{ int ix; for(ix=0; ixvariant = 0; voice_data->xx1 = n_variants; return(voice_data); -} // end of ReadVoiceFile +} void VoiceReset(int tone_only) -{//=========================== +{ // Set voice to the default values int pk; @@ -464,11 +464,11 @@ void VoiceReset(int tone_only) option_quiet = 0; LoadMbrolaTable(NULL,NULL,0); } -} // end of VoiceReset +} static void VoiceFormant(char *p) -{//============================== +{ // Set parameters for a formant int ix; int formant; @@ -498,7 +498,7 @@ static void VoiceFormant(char *p) static void PhonemeReplacement(int type, char *p) -{//============================================== +{ int n; int phon; int flags = 0; @@ -516,12 +516,12 @@ static void PhonemeReplacement(int type, char *p) replace_phonemes[n_replace_phonemes].old_ph = phon; replace_phonemes[n_replace_phonemes].new_ph = LookupPhonemeString(phon_string2); replace_phonemes[n_replace_phonemes++].type = flags; -} // end of PhonemeReplacement +} static int Read8Numbers(char *data_in,int *data) -{//============================================= +{ // Read 8 integer numbers memset(data, 0, 8+sizeof(int)); return(sscanf(data_in,"%d %d %d %d %d %d %d %d", @@ -530,7 +530,7 @@ static int Read8Numbers(char *data_in,int *data) static unsigned int StringToWord2(const char *string) -{//====================================================== +{ // Convert a language name string to a word such as L('e','n') int ix; int c; @@ -545,7 +545,7 @@ static unsigned int StringToWord2(const char *string) voice_t *LoadVoice(const char *vname, int control) -{//=============================================== +{ // control, bit 0 1= no_default // bit 1 1 = change tone only, not language // bit 2 1 = don't report error on LoadDictionary @@ -1129,11 +1129,11 @@ voice_t *LoadVoice(const char *vname, int control) } return(voice); -} // end of LoadVoice +} static char *ExtractVoiceVariantName(char *vname, int variant_num, int add_dir) -{//=========================================================================== +{ // Remove any voice variant suffix (name or number) from a voice name // Returns the voice variant name @@ -1174,12 +1174,12 @@ static char *ExtractVoiceVariantName(char *vname, int variant_num, int add_dir) } return(variant_name); -} // end of ExtractVoiceVariantName +} 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" @@ -1203,7 +1203,7 @@ voice_t *LoadVoiceVariant(const char *vname, int variant_num) static int __cdecl VoiceNameSorter(const void *p1, const void *p2) -{//======================================================= +{ int ix; espeak_VOICE *v1 = *(espeak_VOICE **)p1; espeak_VOICE *v2 = *(espeak_VOICE **)p2; @@ -1218,7 +1218,7 @@ static int __cdecl VoiceNameSorter(const void *p1, const void *p2) static int __cdecl VoiceScoreSorter(const void *p1, const void *p2) -{//======================================================== +{ int ix; espeak_VOICE *v1 = *(espeak_VOICE **)p1; espeak_VOICE *v2 = *(espeak_VOICE **)p2; @@ -1230,7 +1230,7 @@ static int __cdecl VoiceScoreSorter(const void *p1, const void *p2) static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int spec_n_parts, int spec_lang_len, espeak_VOICE *voice) -{//========================================================================================================================= +{ int ix; const char *p; int c1, c2; @@ -1369,11 +1369,11 @@ static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int s if(score < 1) score = 1; return(score); -} // end of ScoreVoice +} static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int control) -{//====================================================================================== +{ // control: bit0=1 include mbrola voices int ix; int score; @@ -1439,13 +1439,13 @@ static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int qsort(voices,nv,sizeof(espeak_VOICE *),(int (__cdecl *)(const void *,const void *))VoiceScoreSorter); return(nv); -} // end of SetVoiceScores +} espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name2) -{//====================================================================== +{ int ix; int match_fname = -1; int match_fname2 = -1; @@ -1505,13 +1505,13 @@ espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name2) return(NULL); return(voices[match_name]); -} // end of SelectVoiceByName +} char const *SelectVoice(espeak_VOICE *voice_select, int *found) -{//============================================================ +{ // Returns a path within espeak-voices, with a possible +variant suffix // variant is an output-only parameter int nv; // number of candidates @@ -1655,12 +1655,12 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found) } return(vp->identifier); -} // end of SelectVoice +} static void GetVoices(const char *path) -{//==================================== +{ FILE *f_voice; espeak_VOICE *voice_data; int ftype; @@ -1802,12 +1802,12 @@ static void GetVoices(const char *path) closedir(dir); #endif #endif -} // end of GetVoices +} espeak_ERROR SetVoiceByName(const char *name) -{//========================================= +{ espeak_VOICE *v; int ix; espeak_VOICE voice_selector; @@ -1862,12 +1862,12 @@ espeak_ERROR SetVoiceByName(const char *name) } } return(EE_INTERNAL_ERROR); // voice name not found -} // end of SetVoiceByName +} espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector) -{//============================================================ +{ const char *voice_id; int voice_found; @@ -1881,11 +1881,11 @@ espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector) SetVoiceStack(voice_selector, ""); return(EE_OK); -} // end of SetVoiceByProperties +} void FreeVoiceList() -{//================= +{ int ix; for(ix=0; ix * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * based on AudioIO.cc (Audacity-1.2.4b) and wavegen.cpp * * * * This program is free software; you can redistribute it and/or modify * @@ -414,7 +414,7 @@ static int pa_callback(void *inputBuffer, void *outputBuffer, #endif return(aResult); -} // end of WaveCallBack +} void wave_flush(void* theHandler) diff --git a/src/libespeak-ng/wave_pulse.c b/src/libespeak-ng/wave_pulse.c index f3272512..675adc1f 100644 --- a/src/libespeak-ng/wave_pulse.c +++ b/src/libespeak-ng/wave_pulse.c @@ -1,6 +1,6 @@ /*************************************************************************** * Copyright (C) 2007, Gilles Casse * - * Copyright (C) 2015 by Reece H. Dunn * + * Copyright (C) 2015 Reece H. Dunn * * eSpeak driver for PulseAudio * * based on the XMMS PulseAudio Plugin * * * diff --git a/src/libespeak-ng/wavegen.c b/src/libespeak-ng/wavegen.c index 2f73e5ed..e50f415d 100644 --- a/src/libespeak-ng/wavegen.c +++ b/src/libespeak-ng/wavegen.c @@ -264,7 +264,7 @@ unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1] = { #ifdef LOG_FRAMES static void LogMarker(int type, int value, int value2) -{//=================================================== +{ char buf[20]; int *p; @@ -294,7 +294,7 @@ static void LogMarker(int type, int value, int value2) #endif void WcmdqStop() -{//============= +{ wcmdq_head = 0; wcmdq_tail = 0; @@ -315,7 +315,7 @@ void WcmdqStop() int WcmdqFree() -{//============ +{ int i; i = wcmdq_head - wcmdq_tail; if(i <= 0) i += N_WCMDQ; @@ -323,19 +323,19 @@ int WcmdqFree() } int WcmdqUsed() -{//============ +{ return(N_WCMDQ - WcmdqFree()); } void WcmdqInc() -{//============ +{ wcmdq_tail++; if(wcmdq_tail >= N_WCMDQ) wcmdq_tail=0; } static void WcmdqIncHead() -{//======================= +{ wcmdq_head++; if(wcmdq_head >= N_WCMDQ) wcmdq_head=0; } @@ -531,7 +531,7 @@ static int WaveCallback(const void *inputBuffer, void *outputBuffer, return(result); #endif -} // end of WaveCallBack +} #if USE_PORTAUDIO == 19 @@ -578,7 +578,7 @@ static PaError Pa_OpenDefaultStream2( PaStream** stream, int WavegenOpenSound() -{//=================== +{ PaError err, err2; PaError active; @@ -643,7 +643,7 @@ int WavegenOpenSound() int WavegenCloseSound() -{//==================== +{ PaError active; // check whether speaking has finished, and close the stream @@ -673,7 +673,7 @@ int WavegenCloseSound() int WavegenInitSound() -{//=================== +{ PaError err; if(option_quiet) @@ -691,22 +691,22 @@ int WavegenInitSound() } #else int WavegenOpenSound() -{//=================== +{ return(0); } int WavegenCloseSound() -{//==================== +{ return(0); } int WavegenInitSound() -{//=================== +{ return(0); } #endif void WavegenInit(int rate, int wavemult_fact) -{//========================================== +{ int ix; double x; @@ -757,11 +757,11 @@ void WavegenInit(int rate, int wavemult_fact) remove("log-espeakedit"); remove("log-klatt"); #endif -} // end of WavegenInit +} int GetAmplitude(void) -{//=================== +{ int amp; // normal, none, reduced, moderate, strong @@ -774,7 +774,7 @@ int GetAmplitude(void) static void WavegenSetEcho(void) -{//============================= +{ int delay; int amp; @@ -812,12 +812,12 @@ static void WavegenSetEcho(void) // compensate (partially) for increase in amplitude due to echo general_amplitude = GetAmplitude(); general_amplitude = ((general_amplitude * (500-amp))/500); -} // end of WavegenSetEcho +} int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control) -{//============================================================================ +{ // Calculate the amplitude of each harmonics from the formants // Only for formants 0 to 5 @@ -942,12 +942,12 @@ int h2; } return(hmax); // highest harmonic number -} // end of PeaksToHarmspect +} static void AdvanceParameters() -{//============================ +{ // Called every 64 samples to increment the formant freq, height, and widths int x; @@ -1014,12 +1014,12 @@ static void AdvanceParameters() harm_sqrt[ix] += harm_sqrt_inc[ix]; } #endif -} // end of AdvanceParameters +} #ifndef PLATFORM_RISCOS static double resonator(RESONATOR *r, double input) -{//================================================ +{ double x; x = r->a * input + r->b * r->x1 + r->c * r->x2; @@ -1032,7 +1032,7 @@ static double resonator(RESONATOR *r, double input) static void setresonator(RESONATOR *rp, int freq, int bwidth, int init) -{//==================================================================== +{ // freq Frequency of resonator in Hz // bwidth Bandwidth of resonator in Hz // init Initialize internal data @@ -1055,12 +1055,12 @@ static void setresonator(RESONATOR *rp, int freq, int bwidth, int init) rp->b = x * cos(arg) * 2.0; rp->a = 1.0 - rp->b - rp->c; -} // end if setresonator +} #endif void InitBreath(void) -{//================== +{ #ifndef PLATFORM_RISCOS int ix; @@ -1072,12 +1072,12 @@ void InitBreath(void) setresonator(&rbreath[ix],2000,200,1); } #endif -} // end of InitBreath +} static void SetBreath() -{//==================== +{ #ifndef PLATFORM_RISCOS int pk; @@ -1094,11 +1094,11 @@ static void SetBreath() } } #endif -} // end of SetBreath +} static int ApplyBreath(void) -{//========================= +{ int value = 0; #ifndef PLATFORM_RISCOS int noise; @@ -1123,7 +1123,7 @@ static int ApplyBreath(void) int Wavegen() -{//========== +{ unsigned short waveph; unsigned short theta; int total; @@ -1389,11 +1389,11 @@ int Wavegen() return(1); } return(0); -} // end of Wavegen +} static int PlaySilence(int length, int resume) -{//=========================================== +{ static int n_samples; int value=0; @@ -1425,12 +1425,12 @@ static int PlaySilence(int length, int resume) return(1); } return(0); -} // end of PlaySilence +} static int PlayWave(int length, int resume, unsigned char *data, int scale, int amp) -{//================================================================================= +{ static int n_samples; static int ix=0; int value; @@ -1490,7 +1490,7 @@ static int PlayWave(int length, int resume, unsigned char *data, int scale, int static int SetWithRange0(int value, int max) -{//========================================= +{ if(value < 0) return(0); if(value > max) @@ -1500,7 +1500,7 @@ static int SetWithRange0(int value, int max) static void SetPitchFormants() -{//=========================== +{ int ix; int factor = 256; int pitch_value; @@ -1527,7 +1527,7 @@ static void SetPitchFormants() void SetEmbedded(int control, int value) -{//===================================== +{ // there was an embedded command in the text at this point int sign=0; int command; @@ -1572,7 +1572,7 @@ void SetEmbedded(int control, int value) void WavegenSetVoice(voice_t *v) -{//============================= +{ static voice_t v2; memcpy(&v2,v,sizeof(v2)); @@ -1596,7 +1596,7 @@ void WavegenSetVoice(voice_t *v) static void SetAmplitude(int length, unsigned char *amp_env, int value) -{//==================================================================== +{ amp_ix = 0; if(length==0) amp_inc = 0; @@ -1611,7 +1611,7 @@ static void SetAmplitude(int length, unsigned char *amp_env, int value) void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pitch_range) -{//====================================================================================== +{ int x; int base; int range; @@ -1642,7 +1642,7 @@ void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pit void SetPitch(int length, unsigned char *env, int pitch1, int pitch2) -{//================================================================== +{ // length in samples #ifdef LOG_FRAMES @@ -1672,14 +1672,14 @@ if(option_log_frames) flutter_amp = wvoice->flutter; -} // end of SetPitch +} void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v) -{//======================================================================== +{ int ix; DOUBLEX next; int length2; @@ -1787,11 +1787,11 @@ if(option_log_frames) } } } -} // end of SetSynth +} static int Wavegen2(int length, int modulation, int resume, frame_t *fr1, frame_t *fr2) -{//==================================================================================== +{ if(resume==0) SetSynth(length, modulation, fr1, fr2, wvoice); @@ -1799,7 +1799,7 @@ static int Wavegen2(int length, int modulation, int resume, frame_t *fr1, frame_ } void Write4Bytes(FILE *f, int value) -{//================================= +{ // Write 4 bytes to a file, least significant first int ix; @@ -1813,7 +1813,7 @@ void Write4Bytes(FILE *f, int value) int WavegenFill2(int fill_zeros) -{//============================ +{ // Pick up next wavegen commands from the queue // return: 0 output buffer has been filled // return: 1 input command queue is now empty @@ -1962,13 +1962,13 @@ int WavegenFill2(int fill_zeros) } return(0); -} // end of WavegenFill2 +} #ifdef INCLUDE_SONIC /* Speed up the audio samples with libsonic. */ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text) -{//============================================================================== +{ if(length_in >0) { if(sonicSpeedupStream == NULL) @@ -1991,13 +1991,13 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text sonicFlushStream(sonicSpeedupStream); } return sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out); -} // end of SpeedUp +} #endif /* Call WavegenFill2, and then speed up the output samples. */ int WavegenFill(int fill_zeros) -{//============================ +{ int finished; unsigned char *p_start; @@ -2021,5 +2021,5 @@ int WavegenFill(int fill_zeros) } #endif return finished; -} // end of WavegenFill +} diff --git a/src/speak-ng.c b/src/speak-ng.c index 7d219c1b..18e31a6a 100644 --- a/src/speak-ng.c +++ b/src/speak-ng.c @@ -130,7 +130,7 @@ USHORT voice_pcnt[N_PEAKS+1][3]; void DisplayVoices(FILE *f_out, char *language) -{//============================================ +{ int ix; const char *p; int len; @@ -198,11 +198,10 @@ void DisplayVoices(FILE *f_out, char *language) } fputc('\n',f_out); } -} // end of DisplayVoices +} static int OpenWaveFile(const char *path, int rate) -//================================================= { // Set the length of 0x7ffff000 for --stdout // This will be changed to the correct length for -w (write to file) @@ -240,13 +239,12 @@ static int OpenWaveFile(const char *path, int rate) return(0); } return(1); -} // end of OpenWaveFile +} static void CloseWaveFile() -//========================= { unsigned int pos; @@ -266,13 +264,13 @@ static void CloseWaveFile() fclose(f_wave); f_wave = NULL; -} // end of CloseWaveFile +} static int WavegenFile(void) -{//========================= +{ int finished; unsigned char wav_outbuf[1024]; char fname[210]; @@ -308,12 +306,12 @@ static int WavegenFile(void) fwrite(wav_outbuf, 1, out_ptr - wav_outbuf, f_wave); } return(finished); -} // end of WavegenFile +} static void init_path(char *argv0, char *path_specified) -{//===================================================== +{ if(path_specified) { @@ -375,7 +373,7 @@ static void init_path(char *argv0, char *path_specified) static int initialise(void) -{//======================== +{ int param; int result; int srate = 22050; // default sample rate @@ -434,16 +432,9 @@ static int initialise(void) #endif int main (int argc, char **argv) -//============================== { static struct option long_options[] = { - /* These options set a flag. */ -// {"verbose", no_argument, &verbose_flag, 1}, -// {"brief", no_argument, &verbose_flag, 0}, - - /* These options don't set a flag. - We distinguish them by their indices. */ {"help", no_argument, 0, 'h'}, {"stdin", no_argument, 0, 0x100}, {"compile-debug", optional_argument, 0, 0x101},