mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-30 14:22:29 +00:00
Merge branch 'master' into android
Conflicts: README.md
This commit is contained in:
+10
-1
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* Copyright (C) 2013 by 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 *
|
||||
@@ -124,6 +125,7 @@ static keywtab_t k_properties[] = {
|
||||
{"isVFricative", 0, phVFRICATIVE},
|
||||
|
||||
{"isPalatal", 0, i_isPalatal},
|
||||
{"isLong", 0, i_isLong},
|
||||
{"isRhotic", 0, i_isRhotic},
|
||||
{"isSibilant", 0, i_isSibilant},
|
||||
{"isFlag1", 0, i_isFlag1},
|
||||
@@ -990,6 +992,10 @@ static wxString CompileAllDictionaries()
|
||||
|
||||
sprintf(fname_log,"%s%s",path_dsource,"dict_log");
|
||||
log = fopen(fname_log,"w");
|
||||
if(log != 0)
|
||||
{
|
||||
fprintf(log, "%s", utf8_bom);
|
||||
}
|
||||
sprintf(fname_log,"%s%s",path_dsource,"dict_phonemes");
|
||||
f_phused = fopen(fname_log,"w");
|
||||
|
||||
@@ -2407,6 +2413,9 @@ int CompileIf(int elif)
|
||||
else
|
||||
{
|
||||
error("Unexpected keyword '%s'",item_string);
|
||||
|
||||
if((strcmp(item_string, "phoneme") == 0) || (strcmp(item_string, "endphoneme") == 0))
|
||||
return(-1);
|
||||
}
|
||||
|
||||
// output the word
|
||||
|
||||
+24
-14
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -51,6 +51,7 @@ static char letterGroupsDefined[N_LETTER_GROUPS];
|
||||
|
||||
MNEM_TAB mnem_rules[] = {
|
||||
{"unpr", 0x01},
|
||||
{"noprefix", 0x02}, // rule fails if a prefix has been removed
|
||||
|
||||
{"w_alt1", 0x11},
|
||||
{"w_alt2", 0x12},
|
||||
@@ -235,6 +236,7 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
|
||||
unsigned char rb;
|
||||
unsigned char c;
|
||||
char *p;
|
||||
char *p_end;
|
||||
int ix;
|
||||
int match_type;
|
||||
int finished=0;
|
||||
@@ -245,10 +247,10 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
|
||||
int condition_num=0;
|
||||
int at_start = 0;
|
||||
const char *name;
|
||||
char buf[60];
|
||||
char buf_pre[60];
|
||||
char buf[200];
|
||||
char buf_pre[200];
|
||||
char suffix[20];
|
||||
static char output[60];
|
||||
static char output[80];
|
||||
|
||||
static char symbols[] =
|
||||
{' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
|
||||
@@ -367,6 +369,8 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
|
||||
*p = 0;
|
||||
|
||||
p = output;
|
||||
p_end = p + sizeof(output) - 1;
|
||||
|
||||
if(linenum > 0)
|
||||
{
|
||||
sprintf(p,"%5d:\t",linenum);
|
||||
@@ -381,12 +385,14 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
|
||||
{
|
||||
if(at_start)
|
||||
*p++ = '_';
|
||||
while(--ix >= 0)
|
||||
while((--ix >= 0) && (p < p_end-3))
|
||||
*p++ = buf_pre[ix];
|
||||
*p++ = ')';
|
||||
*p++ = ' ';
|
||||
}
|
||||
*p = 0;
|
||||
|
||||
buf[p_end - p] = 0; // prevent overflow in output[]
|
||||
strcat(p,buf);
|
||||
ix = strlen(output);
|
||||
while(ix < 8)
|
||||
@@ -425,7 +431,8 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
char *mnemptr;
|
||||
unsigned char flag_codes[100];
|
||||
char encoded_ph[200];
|
||||
unsigned char bad_phoneme[4];
|
||||
char bad_phoneme_str[4];
|
||||
int bad_phoneme;
|
||||
static char nullstring[] = {0};
|
||||
|
||||
text_not_phonemes = 0;
|
||||
@@ -660,17 +667,18 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
}
|
||||
else
|
||||
{
|
||||
EncodePhonemes(phonetic,encoded_ph,bad_phoneme);
|
||||
EncodePhonemes(phonetic,encoded_ph,&bad_phoneme);
|
||||
if(strchr(encoded_ph,phonSWITCH) != 0)
|
||||
{
|
||||
flag_codes[n_flag_codes++] = BITNUM_FLAG_ONLY_S; // don't match on suffixes (except 's') when switching languages
|
||||
}
|
||||
|
||||
// check for errors in the phonemes codes
|
||||
if(bad_phoneme[0] != 0)
|
||||
if(bad_phoneme != 0)
|
||||
{
|
||||
// unrecognised phoneme, report error
|
||||
fprintf(f_log,"%5d: Bad phoneme [%c] (0x%x) in: %s %s\n",linenum,bad_phoneme[0],bad_phoneme[0],word,phonetic);
|
||||
bad_phoneme_str[utf8_out(bad_phoneme, bad_phoneme_str)] = 0;
|
||||
fprintf(f_log,"%5d: Bad phoneme [%s] (U+%x) in: %s %s\n",linenum,bad_phoneme_str,bad_phoneme,word,phonetic);
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
@@ -1194,7 +1202,8 @@ static char *compile_rule(char *input)
|
||||
int finish=0;
|
||||
char buf[80];
|
||||
char output[150];
|
||||
unsigned char bad_phoneme[4];
|
||||
int bad_phoneme;
|
||||
char bad_phoneme_str[4];
|
||||
|
||||
buf[0]=0;
|
||||
rule_cond[0]=0;
|
||||
@@ -1272,10 +1281,11 @@ static char *compile_rule(char *input)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
EncodePhonemes(rule_phonemes,buf,bad_phoneme);
|
||||
if(bad_phoneme[0] != 0)
|
||||
EncodePhonemes(rule_phonemes,buf,&bad_phoneme);
|
||||
if(bad_phoneme != 0)
|
||||
{
|
||||
fprintf(f_log,"%5d: Bad phoneme [%c] in %s\n",linenum,bad_phoneme[0],input);
|
||||
bad_phoneme_str[utf8_out(bad_phoneme, bad_phoneme_str)] = 0;
|
||||
fprintf(f_log,"%5d: Bad phoneme [%s] (U+%x) in: %s\n",linenum,bad_phoneme_str,bad_phoneme,input);
|
||||
error_count++;
|
||||
}
|
||||
strcpy(output,buf);
|
||||
@@ -1923,7 +1933,7 @@ int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, cha
|
||||
if((f_out = fopen_log(fname_out,"wb+")) == NULL)
|
||||
{
|
||||
if(fname_err)
|
||||
strcpy(fname_err,fname_in);
|
||||
strcpy(fname_err,fname_out);
|
||||
return(-1);
|
||||
}
|
||||
sprintf(fname_temp,"%s%ctemp",path_home,PATHSEP);
|
||||
|
||||
+44
-18
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* Copyright (C) 2013 Reece H. Dunn *
|
||||
* *
|
||||
@@ -352,8 +352,8 @@ int HashDictionary(const char *string)
|
||||
|
||||
|
||||
|
||||
const char *EncodePhonemes(const char *p, char *outptr, unsigned char *bad_phoneme)
|
||||
/***************************************************************************/
|
||||
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'
|
||||
@@ -370,7 +370,7 @@ const char *EncodePhonemes(const char *p, char *outptr, unsigned char *bad_phone
|
||||
unsigned int mnemonic_word;
|
||||
|
||||
if(bad_phoneme != NULL)
|
||||
bad_phoneme[0] = 0;
|
||||
*bad_phoneme = 0;
|
||||
|
||||
// skip initial blanks
|
||||
while(isspace(*p))
|
||||
@@ -432,8 +432,7 @@ const char *EncodePhonemes(const char *p, char *outptr, unsigned char *bad_phone
|
||||
// not recognised, report and ignore
|
||||
if(bad_phoneme != NULL)
|
||||
{
|
||||
bad_phoneme[0] = *p;
|
||||
bad_phoneme[1] = 0;
|
||||
utf8_in(bad_phoneme, p);
|
||||
}
|
||||
*outptr++ = 0;
|
||||
return(p+1);
|
||||
@@ -523,7 +522,7 @@ void DecodePhonemes(const char *inptr, char *outptr)
|
||||
|
||||
// using Kirschenbaum to IPA translation, ascii 0x20 to 0x7f
|
||||
unsigned short ipa1[96] = {
|
||||
0x20,0x21,0x22,0x2b0,0x24,0x25,0x0e6,0x2c8,0x28,0x27e,0x2a,0x2b,0x2cc,0x2d,0x2e,0x2f,
|
||||
0x20,0x21,0x22,0x2b0,0x24,0x25,0x0e6,0x2c8,0x28,0x29,0x27e,0x2b,0x2cc,0x2d,0x2e,0x2f,
|
||||
0x252,0x31,0x32,0x25c,0x34,0x35,0x36,0x37,0x275,0x39,0x2d0,0x2b2,0x3c,0x3d,0x3e,0x294,
|
||||
0x259,0x251,0x3b2,0xe7,0xf0,0x25b,0x46,0x262,0x127,0x26a,0x25f,0x4b,0x26b,0x271,0x14b,0x254,
|
||||
0x3a6,0x263,0x280,0x283,0x3b8,0x28a,0x28c,0x153,0x3c7,0xf8,0x292,0x32a,0x5c,0x5d,0x5e,0x5f,
|
||||
@@ -532,7 +531,7 @@ unsigned short ipa1[96] = {
|
||||
};
|
||||
|
||||
#define N_PHON_OUT 500 // realloc increment
|
||||
static char *phon_out_buf = NULL;
|
||||
static char *phon_out_buf = NULL; // passes the result of GetTranslatedPhonemeString()
|
||||
static int phon_out_size = 0;
|
||||
|
||||
|
||||
@@ -669,6 +668,16 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
|
||||
use_ipa = phoneme_mode & 0x10;
|
||||
use_tie = phoneme_mode & 0x0f;
|
||||
|
||||
if(phon_out_buf == NULL)
|
||||
{
|
||||
phon_out_size = N_PHON_OUT;
|
||||
if((phon_out_buf = (char *)realloc(phon_out_buf, phon_out_size)) == NULL)
|
||||
{
|
||||
phon_out_size = 0;
|
||||
return("");
|
||||
}
|
||||
}
|
||||
|
||||
if(use_tie >= 3)
|
||||
{
|
||||
// separate individual phonemes with underscores
|
||||
@@ -676,6 +685,7 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
|
||||
use_tie = 0;
|
||||
}
|
||||
|
||||
|
||||
for(ix=1; ix<(n_phoneme_list-2); ix++)
|
||||
{
|
||||
buf = phon_buf;
|
||||
@@ -904,6 +914,7 @@ int Unpronouncable(Translator *tr, char *word, int posn)
|
||||
int vowel_posn=9;
|
||||
int index;
|
||||
int count;
|
||||
ALPHABET *alphabet;
|
||||
|
||||
utf8_in(&c,word);
|
||||
if((tr->letter_bits_offset > 0) && (c < 0x241))
|
||||
@@ -912,6 +923,12 @@ int Unpronouncable(Translator *tr, char *word, int posn)
|
||||
return(0); // so we can re-translate the word as English
|
||||
}
|
||||
|
||||
if(((alphabet = AlphabetFromChar(c)) != NULL) && (alphabet->offset != tr->letter_bits_offset))
|
||||
{
|
||||
// Character is not in our alphabet
|
||||
return(0);
|
||||
}
|
||||
|
||||
if(tr->langopts.param[LOPT_UNPRONOUNCABLE] == 1)
|
||||
return(0);
|
||||
|
||||
@@ -2157,6 +2174,13 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
{
|
||||
match.end_type = SUFX_UNPRON; // $unpron
|
||||
}
|
||||
else if(command == 0x02) // $noprefix
|
||||
{
|
||||
if(word_flags & FLAG_PREFIX_REMOVED)
|
||||
failed = 1; // a prefix has been removed
|
||||
else
|
||||
add_points = 1;
|
||||
}
|
||||
else if((command & 0xf0) == 0x10)
|
||||
{
|
||||
// $w_alt
|
||||
@@ -2921,9 +2945,10 @@ int TransposeAlphabet(Translator *tr, char *text)
|
||||
int acc;
|
||||
int pairs_start;
|
||||
const short *pairs_list;
|
||||
char buf[N_WORD_BYTES];
|
||||
int bufix;
|
||||
char buf[N_WORD_BYTES+1];
|
||||
|
||||
|
||||
p2 = buf;
|
||||
offset = tr->transpose_min - 1;
|
||||
min = tr->transpose_min;
|
||||
max = tr->transpose_max;
|
||||
@@ -2931,6 +2956,7 @@ int TransposeAlphabet(Translator *tr, char *text)
|
||||
|
||||
pairs_start = max - min + 2;
|
||||
|
||||
bufix = 0;
|
||||
do {
|
||||
p += utf8_in(&c,p);
|
||||
if(c != 0)
|
||||
@@ -2939,30 +2965,30 @@ int TransposeAlphabet(Translator *tr, char *text)
|
||||
{
|
||||
if(map == NULL)
|
||||
{
|
||||
*p2++ = c - offset;
|
||||
buf[bufix++] = c - offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the code from the transpose map
|
||||
if(map[c - min] > 0)
|
||||
{
|
||||
*p2++ = map[c - min];
|
||||
buf[bufix++] = map[c - min];
|
||||
}
|
||||
else
|
||||
{
|
||||
p2 += utf8_out(c,p2);
|
||||
all_alpha=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p2 += utf8_out(c,p2);
|
||||
all_alpha=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (c != 0);
|
||||
*p2 = 0;
|
||||
} while ((c != 0) && (bufix < N_WORD_BYTES));
|
||||
buf[bufix] = 0;
|
||||
|
||||
if(all_alpha)
|
||||
{
|
||||
@@ -3594,7 +3620,7 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
int end_flags;
|
||||
const char *p;
|
||||
int len;
|
||||
static char ending[12];
|
||||
char ending[50];
|
||||
|
||||
// these lists are language specific, but are only relevent if the 'e' suffix flag is used
|
||||
static const char *add_e_exceptions[] = {
|
||||
@@ -3632,7 +3658,7 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
}
|
||||
|
||||
// remove bytes from the end of the word and replace them by spaces
|
||||
for(i=0; i<len_ending; i++)
|
||||
for(i=0; (i<len_ending) && (i < sizeof(ending)-1); i++)
|
||||
{
|
||||
ending[i] = word_end[i];
|
||||
word_end[i] = ' ';
|
||||
|
||||
+26
-10
@@ -43,8 +43,6 @@
|
||||
#include "translate.h"
|
||||
#include "prosodydisplay.h"
|
||||
|
||||
|
||||
|
||||
static const char *about_string2 = "espeakedit: %s\nAuthor: Jonathan Duddington (c) 2009\n\n"
|
||||
"Licensed under GNU General Public License version 3\n"
|
||||
"http://espeak.sourceforge.net/";
|
||||
@@ -93,10 +91,6 @@ int frame_x, frame_y, frame_w, frame_h;
|
||||
|
||||
int adding_page = 0; // fix for wxWidgets (2,8,7) bug, adding first page to a wxNotebook gives emptystring for GetPageTex() in Notebook_Page_Changed event.
|
||||
|
||||
wxFont FONT_SMALL(8,wxSWISS,wxNORMAL,wxNORMAL);
|
||||
wxFont FONT_MEDIUM(9,wxSWISS,wxNORMAL,wxNORMAL);
|
||||
wxFont FONT_NORMAL(10,wxSWISS,wxNORMAL,wxNORMAL);
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
wxString AppName = _T("espeakedit");
|
||||
@@ -123,8 +117,8 @@ bool MyApp::OnInit(void)
|
||||
{//=====================
|
||||
|
||||
int j;
|
||||
wxChar *p;
|
||||
char param[80];
|
||||
const wxChar *p;
|
||||
char param[120];
|
||||
|
||||
|
||||
if(argc > 1)
|
||||
@@ -186,20 +180,22 @@ if(argc > 1)
|
||||
SetTopWindow(myframe);
|
||||
wxInitAllImageHandlers();
|
||||
// wxImage::AddHandler(wxPNGHandler);
|
||||
wxLogStatus(_T("Using espeak_data at: ")+wxString(path_home, wxConvLocal));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_CHAR(MyFrame::OnKey)
|
||||
EVT_MENU(MENU_ABOUT, MyFrame::OnAbout)
|
||||
EVT_MENU(MENU_DOCS, MyFrame::OnAbout)
|
||||
EVT_MENU(MENU_DOCS, MyFrame::OnAbout)
|
||||
EVT_MENU(MENU_SPECTRUM, MyFrame::OnNewWindow)
|
||||
EVT_MENU(MENU_SPECTRUM2, MyFrame::OnNewWindow)
|
||||
EVT_MENU(MENU_PROSODY, MyFrame::OnProsody)
|
||||
EVT_MENU(MENU_OPT_SPEED, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_OPT_PUNCT, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_OPT_SPELL, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_OPT_SPELL2, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_OPT_SPELL2, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_PATH_DATA, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_PATH0, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_PATH1, MyFrame::OnOptions)
|
||||
EVT_MENU(MENU_PATH2, MyFrame::OnOptions)
|
||||
@@ -393,6 +389,7 @@ void MyFrame::PageCmd(wxCommandEvent& event)
|
||||
break;
|
||||
case SPECTSEQ_SAVEAS:
|
||||
currentcanvas->Save();
|
||||
screenpages->SetPageText(screenpages->GetSelection(), currentcanvas->spectseq->name+_T(" ²"));
|
||||
break;
|
||||
case SPECTSEQ_SAVESELECT:
|
||||
currentcanvas->Save(_T(""), 1);
|
||||
@@ -637,6 +634,20 @@ void OnOptions2(int event_id)
|
||||
notebook->SetSelection(1);
|
||||
break;
|
||||
|
||||
case MENU_PATH_DATA:
|
||||
string = wxDirSelector(_T("espeak_data directory"), wxEmptyString);
|
||||
if(!string.IsEmpty())
|
||||
{
|
||||
if(!wxDirExists(string+_T("/voices")))
|
||||
{
|
||||
wxLogError(_T("No 'voices' directory in ") + string);
|
||||
break;
|
||||
}
|
||||
path_espeakdata = string;
|
||||
wxLogMessage(_T("Quit and restart espeakedit to use the new espeak_data location"));
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_PATH0:
|
||||
string = wxFileSelector(_T("Master phonemes file"),wxFileName(path_phfile).GetPath(),
|
||||
_T("phonemes"),_T(""),_T("*"),wxOPEN);
|
||||
@@ -726,6 +737,7 @@ void MyFrame::OnTools(wxCommandEvent& event)
|
||||
int debug_flag=0;
|
||||
char fname_log[sizeof(path_dsource)+12];
|
||||
char err_fname[sizeof(path_home)+15];
|
||||
static const char utf8_bom[] = {0xef,0xbb,0xbf,0};
|
||||
|
||||
switch(event.GetId())
|
||||
{
|
||||
@@ -776,6 +788,10 @@ void MyFrame::OnTools(wxCommandEvent& event)
|
||||
case MENU_COMPILE_DICT:
|
||||
sprintf(fname_log,"%s%s",path_dsource,"dict_log");
|
||||
log = fopen(fname_log,"w");
|
||||
if(log != NULL)
|
||||
{
|
||||
fprintf(log, "%s", utf8_bom);
|
||||
}
|
||||
|
||||
LoadDictionary(translator, translator->dictionary_name, 0);
|
||||
if((err = CompileDictionary(path_dsource,translator->dictionary_name,log,err_fname,debug_flag)) < 0)
|
||||
|
||||
+18
-11
@@ -22,7 +22,9 @@
|
||||
|
||||
|
||||
//<includes
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@@ -47,6 +49,7 @@ static sem_t my_sem_stop_is_required;
|
||||
static sem_t my_sem_stop_is_acknowledged;
|
||||
// my_thread: polls the audio duration and compares it to the duration of the first event.
|
||||
static pthread_t my_thread;
|
||||
static bool thread_inited;
|
||||
|
||||
static t_espeak_callback* my_callback = NULL;
|
||||
static int my_event_is_running=0;
|
||||
@@ -94,16 +97,16 @@ void event_init(void)
|
||||
assert(-1 != sem_init(&my_sem_stop_is_acknowledged, 0, 0));
|
||||
|
||||
pthread_attr_t a_attrib;
|
||||
if (pthread_attr_init (& a_attrib)
|
||||
|| pthread_attr_setdetachstate(&a_attrib, PTHREAD_CREATE_JOINABLE)
|
||||
|| pthread_create( &my_thread,
|
||||
& a_attrib,
|
||||
polling_thread,
|
||||
(void*)NULL))
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (pthread_attr_init (&a_attrib) == 0
|
||||
&& pthread_attr_setdetachstate(&a_attrib, PTHREAD_CREATE_JOINABLE) == 0)
|
||||
{
|
||||
thread_inited = (0 == pthread_create(&my_thread,
|
||||
&a_attrib,
|
||||
polling_thread,
|
||||
(void*)NULL));
|
||||
}
|
||||
assert(thread_inited);
|
||||
pthread_attr_destroy(&a_attrib);
|
||||
}
|
||||
//>
|
||||
@@ -126,7 +129,10 @@ ENTER("event_display");
|
||||
"MARK",
|
||||
"PLAY",
|
||||
"END",
|
||||
"MSG_TERMINATED"
|
||||
"MSG_TERMINATED",
|
||||
"PHONEME",
|
||||
"SAMPLERATE",
|
||||
"??"
|
||||
};
|
||||
|
||||
SHOW("event_display > event=0x%x\n",event);
|
||||
@@ -711,7 +717,7 @@ void event_terminate()
|
||||
{
|
||||
ENTER("event_terminate");
|
||||
|
||||
if (my_thread)
|
||||
if (thread_inited)
|
||||
{
|
||||
pthread_cancel(my_thread);
|
||||
pthread_join(my_thread,NULL);
|
||||
@@ -720,6 +726,7 @@ ENTER("event_terminate");
|
||||
sem_destroy(&my_sem_stop_is_required);
|
||||
sem_destroy(&my_sem_stop_is_acknowledged);
|
||||
init(); // purge event
|
||||
thread_inited = 0;
|
||||
}
|
||||
}
|
||||
//>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 to 2011 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* Copyright (C) 2013 by 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 *
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
|
||||
//<includes
|
||||
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
+9
-6
@@ -110,13 +110,9 @@ extern TranslDlg *transldlg;
|
||||
extern wchar_t ipa1[256];
|
||||
|
||||
|
||||
|
||||
extern wxFont FONT_SMALL;
|
||||
extern wxFont FONT_MEDIUM;
|
||||
extern wxFont FONT_NORMAL;
|
||||
|
||||
enum {
|
||||
MENU_QUIT = 1,
|
||||
MENU_OPEN,
|
||||
MENU_SPECTRUM,
|
||||
MENU_SPECTRUM2,
|
||||
MENU_CLOSE_ALL,
|
||||
@@ -129,6 +125,7 @@ enum {
|
||||
MENU_OPT_SPELL,
|
||||
MENU_OPT_SPELL2,
|
||||
MENU_PATHS,
|
||||
MENU_PATH_DATA,
|
||||
MENU_PATH0,
|
||||
MENU_PATH1,
|
||||
MENU_PATH2,
|
||||
@@ -183,5 +180,11 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
|
||||
// wxWidgets 3 name changes
|
||||
#if wxCHECK_VERSION(3, 0, 0)
|
||||
#define wxOPEN wxFD_OPEN
|
||||
#define wxSAVE wxFD_SAVE
|
||||
#define WXK_PRIOR WXK_PAGEUP
|
||||
#define WXK_NEXT WXK_PAGEDOWN
|
||||
#endif
|
||||
|
||||
|
||||
+52
-29
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -680,6 +680,25 @@ static unsigned short derived_letters[] = {
|
||||
|
||||
static const char *hex_letters[] = {"'e:j","b'i:","s'i:","d'i:","'i:","'ef"}; // names, using phonemes available to all languages
|
||||
|
||||
|
||||
int IsSuperscript(int letter)
|
||||
{//===========================
|
||||
// is this a subscript or superscript letter ?
|
||||
int ix;
|
||||
int c;
|
||||
|
||||
for(ix=0; (c = derived_letters[ix]) != 0; ix+=2)
|
||||
{
|
||||
if(c > letter)
|
||||
break;
|
||||
if(c == letter)
|
||||
return(derived_letters[ix+1]);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
{//=========================================================================
|
||||
// get pronunciation for an isolated letter
|
||||
@@ -736,30 +755,25 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
if(ph_buf[0] == 0)
|
||||
{
|
||||
// is this a subscript or superscript letter ?
|
||||
for(ix=0; (c = derived_letters[ix]) != 0; ix+=2)
|
||||
if((c = IsSuperscript(letter)) != 0)
|
||||
{
|
||||
if(c > letter)
|
||||
break;
|
||||
if(c == letter)
|
||||
letter = c & 0x3fff;
|
||||
if((control & 4 ) && ((modifier = modifiers[c >> 14]) != NULL))
|
||||
{
|
||||
c = derived_letters[ix+1];
|
||||
letter = c & 0x3fff;
|
||||
if((modifier = modifiers[c >> 14]) != NULL)
|
||||
// don't say "superscript" during normal text reading
|
||||
Lookup(tr, modifier, capital);
|
||||
if(capital[0] == 0)
|
||||
{
|
||||
Lookup(tr, modifier, capital);
|
||||
if(capital[0] == 0)
|
||||
capital[2] = SetTranslator2("en"); // overwrites previous contents of translator2
|
||||
Lookup(translator2, modifier, &capital[3]);
|
||||
if(capital[3] != 0)
|
||||
{
|
||||
capital[2] = SetTranslator2("en"); // overwrites previous contents of translator2
|
||||
Lookup(translator2, modifier, &capital[3]);
|
||||
if(capital[3] != 0)
|
||||
{
|
||||
capital[0] = phonPAUSE;
|
||||
capital[1] = phonSWITCH;
|
||||
len = strlen(&capital[3]);
|
||||
capital[len+3] = phonSWITCH;
|
||||
capital[len+4] = phontab_1;
|
||||
capital[len+5] = 0;
|
||||
}
|
||||
capital[0] = phonPAUSE;
|
||||
capital[1] = phonSWITCH;
|
||||
len = strlen(&capital[3]);
|
||||
capital[len+3] = phonSWITCH;
|
||||
capital[len+4] = phontab_1;
|
||||
capital[len+5] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1157,6 +1171,9 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
if(((tr->langopts.numbers & NUM_ROMAN_CAPITALS) && !(wtab[0].flags & FLAG_ALL_UPPER)) || IsDigit09(word[-2]))
|
||||
return(0); // not '2xx'
|
||||
|
||||
if(word[1] == ' ')
|
||||
return(0); // only one letter, don't speak as a Roman Number
|
||||
|
||||
word_start = word;
|
||||
while((c = *word++) != ' ')
|
||||
{
|
||||
@@ -1213,7 +1230,7 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
p = &ph_out[strlen(ph_roman)];
|
||||
}
|
||||
|
||||
sprintf(number_chars," %d ",acc);
|
||||
sprintf(number_chars," %d %s ",acc, tr->langopts.roman_suffix);
|
||||
|
||||
if(word[0] == '.')
|
||||
{
|
||||
@@ -1411,7 +1428,7 @@ static int LookupThousands(Translator *tr, int value, int thousandplex, int thou
|
||||
} // end f LookupThousands
|
||||
|
||||
|
||||
static int LookupNum2(Translator *tr, int value, const int control, char *ph_out)
|
||||
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
|
||||
@@ -1510,7 +1527,10 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out
|
||||
else
|
||||
{
|
||||
// followed by hundreds or thousands etc
|
||||
sprintf(string,"_%da",value);
|
||||
if((tr->langopts.numbers2 & NUM2_ORDINAL_AND_THOUSANDS) && (thousandplex <= 1))
|
||||
sprintf(string, "_%do", value); // LANG=TA
|
||||
else
|
||||
sprintf(string, "_%da", value);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
|
||||
@@ -1616,7 +1636,10 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out
|
||||
else if(((control & 2) == 0) || ((tr->langopts.numbers & NUM_SWAP_TENS) != 0))
|
||||
{
|
||||
// followed by hundreds or thousands (or tens)
|
||||
sprintf(string,"_%da",units);
|
||||
if((tr->langopts.numbers2 & NUM2_ORDINAL_AND_THOUSANDS) && (thousandplex <= 1))
|
||||
sprintf(string, "_%do", units); // LANG=TA, only for 100s, 1000s
|
||||
else
|
||||
sprintf(string, "_%da", units);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
}
|
||||
@@ -1790,7 +1813,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
x = 8; // use variant (feminine) for before thousands and millions
|
||||
if(tr->translator_name == L('m','l'))
|
||||
x = 0x208;
|
||||
LookupNum2(tr, hundreds/10, x, ph_digits);
|
||||
LookupNum2(tr, hundreds/10, thousandplex, x, ph_digits);
|
||||
}
|
||||
|
||||
if(tr->langopts.numbers2 & 0x200)
|
||||
@@ -1873,7 +1896,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
|
||||
if(say_one_hundred != 0)
|
||||
{
|
||||
LookupNum2(tr, hundreds, 0, ph_digits);
|
||||
LookupNum2(tr, hundreds, thousandplex, 0, ph_digits);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1932,7 +1955,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
x |= 0x208; // use #f form for both tens and units
|
||||
}
|
||||
|
||||
if(LookupNum2(tr, tensunits, x | (control & 0x100), buf2) != 0)
|
||||
if(LookupNum2(tr, tensunits, thousandplex, x | (control & 0x100), buf2) != 0)
|
||||
{
|
||||
if(tr->langopts.numbers & NUM_SINGLE_AND)
|
||||
ph_hundred_and[0] = 0; // don't put 'and' after 'hundred' if there's 'and' between tens and units
|
||||
@@ -2360,7 +2383,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
{
|
||||
// speak any remaining decimal fraction digits individually
|
||||
value = word[n_digits++] - '0';
|
||||
LookupNum2(tr, value, 2, buf1);
|
||||
LookupNum2(tr, value, 0, 2, buf1);
|
||||
len = strlen(ph_out);
|
||||
sprintf(&ph_out[len],"%c%s", phonEND_WORD, buf1);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ extern int GetNumeric(wxTextCtrl *t);
|
||||
extern void SetNumeric(wxTextCtrl *t, int value);
|
||||
extern int samplerate;
|
||||
|
||||
wxString path_espeakdata;
|
||||
wxString path_spectload;
|
||||
wxString path_spectload2;
|
||||
wxString path_pitches;
|
||||
@@ -178,6 +179,12 @@ void ConfigInit(bool use_defaults)
|
||||
}
|
||||
else
|
||||
{
|
||||
pConfig->Read(_T("/espeakdata"),&path_espeakdata,wxEmptyString);
|
||||
if(path_espeakdata != wxEmptyString)
|
||||
{
|
||||
strcpy(path_home, path_espeakdata.mb_str(wxConvLocal));
|
||||
}
|
||||
|
||||
pConfig->Read(_T("/spectload"),&path_spectload,basedir+_T("/phsource"));
|
||||
pConfig->Read(_T("/spectload2"),&path_spectload2,basedir+_T("/phsource"));
|
||||
pConfig->Read(_T("/pitchpath"),&path_pitches,basedir+_T("/pitch"));
|
||||
@@ -210,6 +217,7 @@ void ConfigSave(int exit)
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
// pConfig->Write(_T("/samplerate"),samplerate);
|
||||
#endif
|
||||
pConfig->Write(_T("/espeakdata"),path_espeakdata);
|
||||
pConfig->Write(_T("/spectload"),path_spectload);
|
||||
pConfig->Write(_T("/spectload2"),path_spectload2);
|
||||
pConfig->Write(_T("/pitchpath"),path_pitches);
|
||||
|
||||
+3
-2
@@ -32,6 +32,7 @@ extern void ConfigInit(bool use_defaults);
|
||||
extern void ConfigSave(int end);
|
||||
extern void ConfigSetPaths();
|
||||
|
||||
extern wxString path_espeakdata;
|
||||
extern wxString path_spectload;
|
||||
extern wxString path_spectload2;
|
||||
extern wxString path_pitches;
|
||||
@@ -51,13 +52,13 @@ extern void OnOptions2(int event_id);
|
||||
|
||||
// not currently used
|
||||
class Options : public wxDialog {
|
||||
public:
|
||||
public:
|
||||
Options(wxWindow *parent);
|
||||
~Options();
|
||||
|
||||
private:
|
||||
void OnCommand(wxCommandEvent& event);
|
||||
|
||||
|
||||
wxButton *m_save;
|
||||
wxButton *m_close;
|
||||
wxStaticText *m_lab[10];
|
||||
|
||||
+4
-4
@@ -49,7 +49,7 @@
|
||||
#define phSINGLE_INSTN 0x1000 // this phoneme has a single instruction program, with an implicit Return
|
||||
#define phBRKAFTER 0x4000 // [*] add a post-pause
|
||||
|
||||
#define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
|
||||
#define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
|
||||
#define phLONG 0x200000
|
||||
#define phLENGTHENSTOP 0x400000 // make the pre-pause slightly longer
|
||||
#define phRHOTIC 0x800000 // bit 23
|
||||
@@ -113,7 +113,7 @@ typedef struct {
|
||||
unsigned char end_type;
|
||||
unsigned char std_length; // for vowels, in mS/2; for phSTRESS phonemes, this is the stress/tone type
|
||||
unsigned char length_mod; // a length_mod group number, used to access length_mod_tab
|
||||
|
||||
|
||||
} PHONEME_TAB;
|
||||
|
||||
|
||||
@@ -155,13 +155,13 @@ typedef struct {
|
||||
|
||||
|
||||
|
||||
#define PH(c1,c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name
|
||||
#define PH(c1,c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name
|
||||
#define PH3(c1,c2,c3) (c3<<16)+(c2<<8)+c1
|
||||
#define PhonemeCode2(c1,c2) PhonemeCode((c2<<8)+c1)
|
||||
int LookupPhonemeString(const char *string);
|
||||
int PhonemeCode(unsigned int mnem);
|
||||
|
||||
const char *EncodePhonemes(const char *p, char *outptr, unsigned char *bad_phoneme);
|
||||
const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme);
|
||||
void DecodePhonemes(const char *inptr, char *outptr);
|
||||
|
||||
extern const char *WordToString(unsigned int word);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
|
||||
+10
-10
@@ -2529,6 +2529,16 @@ f_input = f_in; // for GetC etc
|
||||
|
||||
linelength++;
|
||||
|
||||
if((j = lookupwchar2(tr->chars_ignore,c1)) != 0)
|
||||
{
|
||||
if(j == 1)
|
||||
{
|
||||
// ignore this character (eg. zero-width-non-joiner U+200C)
|
||||
continue;
|
||||
}
|
||||
c1 = j; // replace the character
|
||||
}
|
||||
|
||||
if(iswalnum(c1))
|
||||
any_alnum = 1;
|
||||
else
|
||||
@@ -2541,16 +2551,6 @@ f_input = f_in; // for GetC etc
|
||||
c2 = ' ';
|
||||
}
|
||||
|
||||
if((j = lookupwchar2(tr->chars_ignore,c1)) != 0)
|
||||
{
|
||||
if(j == 1)
|
||||
{
|
||||
// ignore this character (eg. zero-width-non-joiner U+200C)
|
||||
continue;
|
||||
}
|
||||
c1 = j; // replace the character
|
||||
}
|
||||
|
||||
if(c1 == 0xf0b)
|
||||
c1 = ' '; // Tibet inter-syllabic mark, ?? replace by space ??
|
||||
|
||||
|
||||
+19
-5
@@ -32,7 +32,12 @@
|
||||
#include "speech.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#include <winreg.h>
|
||||
#else /* PLATFORM_POSIX */
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@@ -552,7 +557,11 @@ static const char* label[] = {
|
||||
"SENTENCE",
|
||||
"MARK",
|
||||
"PLAY",
|
||||
"END"};
|
||||
"END",
|
||||
"MSG_TERMINATED",
|
||||
"PHONEME",
|
||||
"SAMPLERATE",
|
||||
"??" };
|
||||
#endif
|
||||
|
||||
|
||||
@@ -724,8 +733,12 @@ void sync_espeak_SetPunctuationList(const wchar_t *punctlist)
|
||||
my_unique_identifier = 0;
|
||||
my_user_data = NULL;
|
||||
|
||||
wcsncpy(option_punctlist, punctlist ? punctlist : L"", N_PUNCTLIST);
|
||||
option_punctlist[N_PUNCTLIST-1] = 0;
|
||||
option_punctlist[0] = 0;
|
||||
if(punctlist != NULL)
|
||||
{
|
||||
wcsncpy(option_punctlist, punctlist, N_PUNCTLIST);
|
||||
option_punctlist[N_PUNCTLIST-1] = 0;
|
||||
}
|
||||
} // end of sync_espeak_SetPunctuationList
|
||||
|
||||
|
||||
@@ -784,8 +797,9 @@ ENTER("espeak_Initialize");
|
||||
}
|
||||
|
||||
// buflength is in mS, allocate 2 bytes per sample
|
||||
if(buf_length == 0)
|
||||
if((buf_length == 0) || (output_type == AUDIO_OUTPUT_PLAYBACK) || (output_type == AUDIO_OUTPUT_SYNCH_PLAYBACK))
|
||||
buf_length = 200;
|
||||
|
||||
outbuf_size = (buf_length * samplerate)/500;
|
||||
outbuf = (unsigned char*)realloc(outbuf,outbuf_size);
|
||||
if((out_start = outbuf) == NULL)
|
||||
|
||||
@@ -187,6 +187,8 @@ ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, cons
|
||||
output: the audio data can either be played by eSpeak or passed back by the SynthCallback function.
|
||||
|
||||
buflength: The length in mS of sound buffers passed to the SynthCallback function.
|
||||
Value=0 gives a default of 200mS.
|
||||
This paramater is only used for AUDIO_OUTPUT_RETRIEVAL and AUDIO_OUTPUT_SYNCHRONOUS modes.
|
||||
|
||||
path: The directory which contains the espeak-data directory, or NULL for the default location.
|
||||
|
||||
|
||||
+10
-6
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* Copyright (C) 2013 by 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 *
|
||||
@@ -50,7 +51,7 @@ wxBrush BRUSH_MARKER[N_MARKERS] = {
|
||||
wxBrush(wxColour(200,0,255),wxSOLID),
|
||||
wxBrush(wxColour(200,0,255),wxSOLID),
|
||||
wxBrush(wxColour(255,0,200),wxSOLID) };
|
||||
|
||||
|
||||
#define DRAWPEAKWIDTH 2000
|
||||
#define PEAKSHAPEW 256
|
||||
|
||||
@@ -86,7 +87,7 @@ float SpectTilt(int value, int freq)
|
||||
}
|
||||
else
|
||||
{
|
||||
return(sqrt(y));
|
||||
return(sqrt(y));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +97,9 @@ SpectFrame::SpectFrame(SpectFrame *copy)
|
||||
|
||||
int ix;
|
||||
|
||||
FONT_SMALL = wxFont(8, wxSWISS, wxNORMAL, wxNORMAL); // wxWidgets 3, Font creation needs a GTK+ Window
|
||||
FONT_MEDIUM = wxFont(9, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
|
||||
selected = 0;
|
||||
keyframe = 0;
|
||||
spect = NULL;
|
||||
@@ -210,7 +214,7 @@ int SpectFrame::ImportSPC2(wxInputStream& stream, float &time_acc)
|
||||
|
||||
stream.Read(&cy,44);
|
||||
size = SPC2_size_cycle(&cy);
|
||||
|
||||
|
||||
p = (CYCLE *)malloc(size);
|
||||
if(p == NULL)
|
||||
{
|
||||
@@ -218,14 +222,14 @@ int SpectFrame::ImportSPC2(wxInputStream& stream, float &time_acc)
|
||||
}
|
||||
stream.SeekI(-44,wxFromCurrent);
|
||||
stream.Read(p,size);
|
||||
|
||||
|
||||
time = time_acc;
|
||||
len = cy.length / 15625.0;
|
||||
time_acc += len;
|
||||
pitch = float(cy.pitch) / 16.0;
|
||||
nx = cy.n_harm;
|
||||
dx = pitch;
|
||||
|
||||
|
||||
for(ix=0; ix<7; ix++)
|
||||
{
|
||||
peaks[ix].pkfreq = cy.peak_data[ix].freq * peak_factor[ix];
|
||||
@@ -244,7 +248,7 @@ int SpectFrame::ImportSPC2(wxInputStream& stream, float &time_acc)
|
||||
}
|
||||
if(((cy.flags & 0x80)==0) && (peaks[1].pkheight > 0))
|
||||
keyframe = 1;
|
||||
|
||||
|
||||
if(cy.flags & 0x08)
|
||||
markers |= 4;
|
||||
if(cy.flags & 0x10)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* Copyright (C) 2013 by 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 *
|
||||
@@ -171,6 +172,8 @@ public:
|
||||
private:
|
||||
void DrawPeaks(wxDC *dc, int offy, int frame_width, int seq_amplitude, double scalex);
|
||||
|
||||
wxFont FONT_SMALL;
|
||||
wxFont FONT_MEDIUM;
|
||||
};
|
||||
|
||||
class SpectSeq
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* Copyright (C) 2013 by 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 *
|
||||
@@ -522,12 +523,12 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
|
||||
if(event.ShiftDown())
|
||||
{
|
||||
x_inc = pk_inc1[pk_num];
|
||||
y_inc = 0x40;
|
||||
y_inc = 0x20;
|
||||
}
|
||||
else
|
||||
{
|
||||
x_inc = pk_inc2[pk_num];
|
||||
y_inc = 0x100;
|
||||
y_inc = 0x80;
|
||||
}
|
||||
|
||||
switch(key)
|
||||
@@ -995,7 +996,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
|
||||
return;
|
||||
}
|
||||
wxFileName path = wxFileName(filename);
|
||||
leaf = path.GetName();
|
||||
leaf = path.GetName();
|
||||
|
||||
setlocale(LC_NUMERIC,"C"); // read numbers in the form 1.23456
|
||||
spectseq->Load(stream);
|
||||
@@ -1013,7 +1014,9 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
|
||||
SpectDisplay *canvas = new SpectDisplay(screenpages, wxDefaultPosition, wxSize(width, height), spectseq);
|
||||
screenpages->AddPage(canvas, leaf, true);
|
||||
canvas->savepath = filename;
|
||||
currentcanvas = canvas;
|
||||
currentcanvas = canvas;
|
||||
|
||||
notebook->ChangeSelection(0); // select FormatDlg window
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.47.12 23.Sep.13";
|
||||
const int version_phdata = 0x014709;
|
||||
const char *version_string = "1.48.02 02.Feb.14";
|
||||
const int version_phdata = 0x014801;
|
||||
|
||||
int option_device_number = -1;
|
||||
FILE *f_logespeak = NULL;
|
||||
|
||||
@@ -72,6 +72,7 @@ extern int embedded_default[N_EMBEDDED_VALUES];
|
||||
|
||||
|
||||
#define N_PEAKS 9
|
||||
#define N_PEAKS2 9 // plus Notch and Fill (not yet implemented)
|
||||
#define N_MARKERS 8
|
||||
|
||||
#define N_KLATTP 10 // this affects the phoneme data file format
|
||||
@@ -349,6 +350,7 @@ typedef struct {
|
||||
// phflags
|
||||
#define i_isSibilant 0x45 // bit 5 in phflags
|
||||
#define i_isPalatal 0x49 // bit 9 in phflags
|
||||
#define i_isLong 0x55 // bit 21 in phflags
|
||||
#define i_isRhotic 0x57 // bit 23 in phflags
|
||||
#define i_isFlag1 0x5c
|
||||
#define i_isFlag2 0x5d
|
||||
|
||||
+36
-17
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -193,10 +193,13 @@ static const unsigned short chars_ignore_default[] = {
|
||||
// alternatively, ignore characters but allow zero-width-non-joiner (lang-fa)
|
||||
static const unsigned short chars_ignore_zwnj_hyphen[] = {
|
||||
0xad, 1, // soft hyphen
|
||||
0x640, 1, // igniore Arabic Tatweel (lang=FA)
|
||||
0x200c, '-', // zero width non-joiner, replace with hyphen
|
||||
0x200d, 1, // zero width joiner
|
||||
0, 0 };
|
||||
|
||||
const char string_ordinal[] = {0xc2,0xba,0}; // masculine ordinal character, UTF-8
|
||||
|
||||
|
||||
static Translator* NewTranslator(void)
|
||||
{//===================================
|
||||
@@ -293,6 +296,7 @@ static const char transpose_map_latin[] = {
|
||||
tr->langopts.replace_chars = NULL;
|
||||
tr->langopts.ascii_language[0] = 0; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
|
||||
tr->langopts.alt_alphabet_lang = L('e','n');
|
||||
tr->langopts.roman_suffix = "";
|
||||
|
||||
SetLengthMods(tr,201);
|
||||
// tr->langopts.length_mods = length_mods_en;
|
||||
@@ -511,6 +515,8 @@ Translator *SelectTranslator(const char *name)
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
case L('a','r'): // Arabic
|
||||
tr->letter_bits_offset = OFFSET_ARABIC;
|
||||
tr->langopts.numbers = NUM_SWAP_TENS | NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED | NUM_THOUSAND_AND | NUM_OMIT_1_THOUSAND;
|
||||
@@ -752,7 +758,9 @@ Translator *SelectTranslator(const char *name)
|
||||
if(name2 == L('a','n'))
|
||||
{
|
||||
tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2;
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ROMAN | NUM_ROMAN_ORDINAL;
|
||||
tr->langopts.numbers2 = NUM2_ORDINAL_NO_AND;
|
||||
tr->langopts.roman_suffix = string_ordinal;
|
||||
}
|
||||
else
|
||||
if(name2 == L_pap)
|
||||
@@ -845,11 +853,14 @@ Translator *SelectTranslator(const char *name)
|
||||
break;
|
||||
|
||||
case L('g','a'): // irish
|
||||
case L('g','d'): // scots gaelic
|
||||
{
|
||||
tr->langopts.stress_rule = STRESSPOSN_1L;
|
||||
tr->langopts.numbers = 1;
|
||||
tr->langopts.stress_flags = S_NO_AUTO_2; // don't use secondary stress
|
||||
tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND;
|
||||
tr->langopts.accents = 2; // 'capital' after letter name
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 3; // don't count apostrophe
|
||||
tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove [:] phoneme from non-stressed syllables (Lang=gd)
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1042,11 +1053,11 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.unstressed_wd1 = 2;
|
||||
tr->langopts.unstressed_wd2 = 2;
|
||||
tr->langopts.param[LOPT_IT_LENGTHEN] = 2; // remove lengthen indicator from unstressed or non-penultimate syllables
|
||||
tr->langopts.param[LOPT_IT_DOUBLING] = 2; // double the first consonant if the previous word ends in a stressed vowel
|
||||
tr->langopts.param[LOPT_IT_DOUBLING] = 1; // double the first consonant if the previous word ends in a stressed vowel (changed to =1, 23.01.2014 - only use if prev.word has $double)
|
||||
tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
|
||||
tr->langopts.param[LOPT_REDUCE] = 1; // reduce vowels even if phonemes are specified in it_list
|
||||
tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
|
||||
tr->langopts.numbers = NUM_SINGLE_VOWEL | NUM_OMIT_1_HUNDRED |NUM_DECIMAL_COMMA | NUM_ROMAN | NUM_DFRACTION_1;
|
||||
tr->langopts.numbers = NUM_SINGLE_VOWEL | NUM_OMIT_1_HUNDRED |NUM_DECIMAL_COMMA | NUM_ROMAN | NUM_DFRACTION_1 | NUM_ROMAN_CAPITALS | NUM_ROMAN_AFTER;
|
||||
tr->langopts.accents = 2; // Say "Capital" after the letter.
|
||||
SetLetterVowel(tr,'y');
|
||||
}
|
||||
@@ -1260,7 +1271,7 @@ SetLengthMods(tr,3); // all equal
|
||||
}
|
||||
break;
|
||||
|
||||
case L('o','m'):
|
||||
case L('o','m'): // Oromo
|
||||
{
|
||||
static const unsigned char stress_amps_om[] = {18,15, 20,20, 20,22, 22,22 };
|
||||
static const short stress_lengths_om[8] = {200,200, 200,200, 0,0, 200,200};
|
||||
@@ -1268,6 +1279,8 @@ SetLengthMods(tr,3); // all equal
|
||||
SetupTranslator(tr,stress_lengths_om,stress_amps_om);
|
||||
tr->langopts.stress_rule = STRESSPOSN_2R;
|
||||
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | 0x80000;
|
||||
tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_HUNDRED_AND;
|
||||
tr->langopts.numbers2 = 0x200; // say "thousands" before its number
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1300,8 +1313,9 @@ SetLengthMods(tr,3); // all equal
|
||||
|
||||
tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
|
||||
tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_INITIAL_2 | S_PRIORITY_STRESS;
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_DFRACTION_2 | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_ROMAN;
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_DFRACTION_2 | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_ROMAN_CAPITALS;
|
||||
tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_NO_TEEN_ORDINALS | NUM2_ORDINAL_NO_AND;
|
||||
tr->langopts.max_roman = 5000;
|
||||
SetLetterVowel(tr,'y');
|
||||
ResetLetterBits(tr,0x2);
|
||||
SetLetterBits(tr,1,"bcdfgjkmnpqstvxz"); // B hard consonants, excluding h,l,r,w,y
|
||||
@@ -1482,6 +1496,7 @@ SetLengthMods(tr,3); // all equal
|
||||
SetupTranslator(tr,stress_lengths_ta, NULL);
|
||||
tr->letter_bits_offset = OFFSET_TAMIL;
|
||||
tr->langopts.numbers = NUM_OMIT_1_THOUSAND ;
|
||||
tr->langopts.numbers2 = NUM2_ORDINAL_AND_THOUSANDS;
|
||||
tr->langopts.param[LOPT_WORD_MERGE] = 1; // don't break vowels betwen words
|
||||
}
|
||||
else
|
||||
@@ -1578,6 +1593,7 @@ SetLengthMods(tr,3); // all equal
|
||||
break;
|
||||
|
||||
case L('u','r'): // Urdu
|
||||
case L('s','d'): // Sindhi
|
||||
{
|
||||
tr->letter_bits_offset = OFFSET_ARABIC;
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
|
||||
@@ -1655,21 +1671,24 @@ SetLengthMods(tr,3); // all equal
|
||||
|
||||
tr->translator_name = name2;
|
||||
|
||||
if(tr->langopts.numbers & NUM_DECIMAL_COMMA)
|
||||
{
|
||||
// use . and ; for thousands and decimal separators
|
||||
tr->langopts.thousands_sep = '.';
|
||||
tr->langopts.decimal_sep = ',';
|
||||
}
|
||||
if(tr->langopts.numbers & NUM_THOUS_SPACE)
|
||||
{
|
||||
tr->langopts.thousands_sep = 0; // don't allow thousands separator, except space
|
||||
}
|
||||
|
||||
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
|
||||
langopts->thousands_sep = '.';
|
||||
langopts->decimal_sep = ',';
|
||||
}
|
||||
if(langopts->numbers & NUM_THOUS_SPACE)
|
||||
{
|
||||
langopts->thousands_sep = 0; // don't allow thousands separator, except space
|
||||
}
|
||||
}
|
||||
|
||||
//**********************************************************************************************************
|
||||
|
||||
|
||||
+40
-8
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -413,7 +413,7 @@ int IsAlpha(unsigned int c)
|
||||
if(c == 0x0605)
|
||||
return(1);
|
||||
|
||||
if((c >= 0x64b) && (c <= 0x65e))
|
||||
if((c == 0x670) || ((c >= 0x64b) && (c <= 0x65e)))
|
||||
return(1); // arabic vowel marks
|
||||
|
||||
if((c >= 0x300) && (c <= 0x36f))
|
||||
@@ -1184,9 +1184,9 @@ if(end_type & SUFX_UNPRON)
|
||||
{
|
||||
int wc;
|
||||
// characters not recognised, speak them individually
|
||||
|
||||
// ?? should we say super/sub-script numbers and letters here?
|
||||
utf8_in(&wc, wordx);
|
||||
if((word_length == 1) && IsAlpha(wc))
|
||||
if((word_length == 1) && (IsAlpha(wc) || IsSuperscript(wc)))
|
||||
{
|
||||
if((wordx = SpeakIndividualLetters(tr, wordx, phonemes, spell_word)) == NULL)
|
||||
{
|
||||
@@ -1273,6 +1273,7 @@ if(end_type & SUFX_UNPRON)
|
||||
c_temp = wordx[-1];
|
||||
wordx[-1] = ' ';
|
||||
confirm_prefix = 1;
|
||||
wflags |= FLAG_PREFIX_REMOVED;
|
||||
|
||||
if(prefix_type & SUFX_B)
|
||||
{
|
||||
@@ -1314,7 +1315,7 @@ if(end_type & SUFX_UNPRON)
|
||||
prefix_flags = 1;
|
||||
if(found == 0)
|
||||
{
|
||||
end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, 0, dictionary_flags);
|
||||
end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, wflags & (FLAG_HYPHEN_AFTER | FLAG_PREFIX_REMOVED), dictionary_flags);
|
||||
|
||||
if(phonemes[0] == phonSWITCH)
|
||||
{
|
||||
@@ -1718,8 +1719,26 @@ int SetTranslator2(const char *new_language)
|
||||
{//=========================================
|
||||
// Set translator2 to a second language
|
||||
int new_phoneme_tab;
|
||||
const char *new_phtab_name;
|
||||
int bitmap;
|
||||
int dialect = 0;
|
||||
|
||||
if((new_phoneme_tab = SelectPhonemeTableName(new_language)) >= 0)
|
||||
new_phtab_name = new_language;
|
||||
if((bitmap = translator->langopts.dict_dialect) != 0)
|
||||
{
|
||||
if((bitmap & (1 << DICTDIALECT_EN_US)) && (strcmp(new_language, "en") == 0))
|
||||
{
|
||||
new_phtab_name = "en-us";
|
||||
dialect = DICTDIALECT_EN_US;
|
||||
}
|
||||
if((bitmap & (1 << DICTDIALECT_ES_LA)) && (strcmp(new_language, "es") == 0))
|
||||
{
|
||||
new_phtab_name = "es-la";
|
||||
dialect = DICTDIALECT_ES_LA;
|
||||
}
|
||||
}
|
||||
|
||||
if((new_phoneme_tab = SelectPhonemeTableName(new_phtab_name)) >= 0)
|
||||
{
|
||||
if((translator2 != NULL) && (strcmp(new_language,translator2_language) != 0))
|
||||
{
|
||||
@@ -1739,6 +1758,19 @@ int SetTranslator2(const char *new_language)
|
||||
new_phoneme_tab = -1;
|
||||
translator2_language[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dialect == DICTDIALECT_EN_US)
|
||||
{
|
||||
// en-us
|
||||
translator2->dict_condition = 0x48; // bits 3, 6
|
||||
translator2->langopts.param[LOPT_REDUCE_T] = 1;
|
||||
}
|
||||
if(dialect == DICTDIALECT_ES_LA)
|
||||
{
|
||||
translator2->dict_condition = 0x04; // bit 2
|
||||
}
|
||||
}
|
||||
translator2->phoneme_tab_ix = new_phoneme_tab;
|
||||
}
|
||||
}
|
||||
@@ -1772,7 +1804,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
int ix;
|
||||
int sylimit; // max. number of syllables in a word to be combined with a preceding preposition
|
||||
const char *new_language;
|
||||
unsigned char bad_phoneme[4];
|
||||
int bad_phoneme;
|
||||
int word_flags;
|
||||
int word_copy_len;
|
||||
char word_copy[N_WORD_BYTES+1];
|
||||
@@ -1878,7 +1910,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
}
|
||||
else
|
||||
{
|
||||
EncodePhonemes(word,word_phonemes,bad_phoneme);
|
||||
EncodePhonemes(word,word_phonemes,&bad_phoneme);
|
||||
}
|
||||
flags = FLAG_FOUND;
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -117,6 +117,7 @@
|
||||
#define FLAG_DELETE_WORD 0x100000 // don't speak this word, it has been spoken as part of the previous word
|
||||
#define FLAG_CHAR_REPLACED 0x200000 // characters have been replaced by .replace in the *_rules
|
||||
#define FLAG_TRANSLATOR2 0x400000 // retranslating using a different language
|
||||
#define FLAG_PREFIX_REMOVED 0x800000 // a prefix has been removed from this word
|
||||
|
||||
#define FLAG_SUFFIX_VOWEL 0x08000000 // remember an initial vowel from the suffix
|
||||
#define FLAG_NO_TRACE 0x10000000 // passed to TranslateRules() to suppress dictionary lookup printout
|
||||
@@ -511,6 +512,7 @@ typedef struct {
|
||||
#define NUM2_ENGLISH_NUMERALS 0x8000
|
||||
#define NUM2_PERCENT_BEFORE 0x10000
|
||||
#define NUM2_OMIT_1_HUNDRED_ONLY 0x20000
|
||||
#define NUM2_ORDINAL_AND_THOUSANDS 0x40000
|
||||
// bits 1-4 use variant form of numbers before thousands,millions,etc.
|
||||
// bits 6-8 use different forms of thousand, million, etc (M MA MB)
|
||||
// bit9=(LANG=rw) say "thousand" and "million" before its number, not after
|
||||
@@ -521,6 +523,7 @@ typedef struct {
|
||||
// bit15=(LANG=ne) speak (non-replaced) English numerals in English
|
||||
// bit16=(LANG=si) say "%" before the number
|
||||
// bit17=(LANG=ml) omit "one" before hundred only if there are no previous digits
|
||||
// bit18=(LANG=ta) same variant for ordinals and thousands (#o = #a)
|
||||
int numbers2;
|
||||
|
||||
#define BREAK_THOUSANDS 0x49249248
|
||||
@@ -531,6 +534,7 @@ typedef struct {
|
||||
int decimal_sep;
|
||||
int max_digits; // max number of digits which can be spoken as an integer number (rather than individual digits)
|
||||
const char *ordinal_indicator; // UTF-8 string
|
||||
const char *roman_suffix; // add this (ordinal) suffix to Roman numbers (LANG=an)
|
||||
|
||||
// bit 0, accent name before the letter name, bit 1 "capital" after letter name
|
||||
int accents;
|
||||
@@ -556,6 +560,10 @@ typedef struct {
|
||||
int max_lengthmod;
|
||||
int lengthen_tonic; // lengthen the tonic syllable
|
||||
int suffix_add_e; // replace a suffix (which has the SUFX_E flag) with this character
|
||||
|
||||
#define DICTDIALECT_EN_US 1 // bit number
|
||||
#define DICTDIALECT_ES_LA 2
|
||||
int dict_dialect; // bitmap, use a dialect for foreign words
|
||||
} LANGUAGE_OPTIONS;
|
||||
|
||||
|
||||
@@ -716,6 +724,7 @@ int IsDigit(unsigned int c);
|
||||
int IsDigit09(unsigned int c);
|
||||
int IsAlpha(unsigned int c);
|
||||
int IsVowel(Translator *tr, int c);
|
||||
int IsSuperscript(int letter);
|
||||
int iswalpha2(int c);
|
||||
int isspace2(unsigned int c);
|
||||
int iswlower2(int c);
|
||||
@@ -730,6 +739,7 @@ ALPHABET *AlphabetFromName(const char *name);
|
||||
Translator *SelectTranslator(const char *name);
|
||||
int SetTranslator2(const char *name);
|
||||
void DeleteTranslator(Translator *tr);
|
||||
void ProcessLanguageOptions(LANGUAGE_OPTIONS *langopts);
|
||||
int Lookup(Translator *tr, const char *word, char *ph_out);
|
||||
int LookupFlags(Translator *tr, const char *word);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* Copyright (C) 2013 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 *
|
||||
|
||||
@@ -111,6 +111,7 @@ enum {
|
||||
V_SPEED,
|
||||
V_DICTMIN,
|
||||
V_ALPHABET2,
|
||||
V_DICTDIALECT,
|
||||
|
||||
// these need a phoneme table to have been specified
|
||||
V_REPLACE,
|
||||
@@ -163,6 +164,7 @@ static MNEM_TAB keyword_tab[] = {
|
||||
{"speed", V_SPEED},
|
||||
{"dict_min", V_DICTMIN},
|
||||
{"alphabet2", V_ALPHABET2},
|
||||
{"dictdialect", V_DICTDIALECT},
|
||||
|
||||
// these just set a value in langopts.param[]
|
||||
{"l_dieresis", 0x100+LOPT_DIERESES},
|
||||
@@ -176,6 +178,13 @@ static MNEM_TAB keyword_tab[] = {
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static MNEM_TAB dict_dialects[] = {
|
||||
{"en-us", DICTDIALECT_EN_US},
|
||||
{"es-la", DICTDIALECT_ES_LA},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
#define N_VOICE_VARIANTS 12
|
||||
const char variants_either[N_VOICE_VARIANTS] = {1,2,12,3,13,4,14,5,11,0};
|
||||
const char variants_male[N_VOICE_VARIANTS] = {1,2,3,4,5,6,0};
|
||||
@@ -873,6 +882,7 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
}
|
||||
while(isalnum(*p)) p++;
|
||||
}
|
||||
ProcessLanguageOptions(langopts);
|
||||
break;
|
||||
|
||||
case V_REPLACE:
|
||||
@@ -1029,6 +1039,21 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
}
|
||||
break;
|
||||
|
||||
case V_DICTDIALECT:
|
||||
// specify a dialect to use for foreign words, eg, en-us for _^_EN
|
||||
if(sscanf(p, "%s", name1) == 1)
|
||||
{
|
||||
if((ix = LookupMnem(dict_dialects, name1)) > 0)
|
||||
{
|
||||
langopts->dict_dialect |= (1 << ix);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "dictdialect name '%s' not recognized\n", name1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if((key & 0xff00) == 0x100)
|
||||
{
|
||||
@@ -1068,6 +1093,7 @@ voice_t *LoadVoice(const char *vname, int control)
|
||||
if((ix = SelectPhonemeTableName(phonemes_name)) < 0)
|
||||
{
|
||||
fprintf(stderr,"Unknown phoneme table: '%s'\n",phonemes_name);
|
||||
ix = 0;
|
||||
}
|
||||
voice->phoneme_tab_ix = ix;
|
||||
new_translator->phoneme_tab_ix = ix;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* Copyright (C) 2013 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 *
|
||||
|
||||
+75
-63
@@ -31,7 +31,10 @@
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
#include "portaudio.h"
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "wave.h"
|
||||
@@ -39,6 +42,15 @@
|
||||
|
||||
//<Definitions
|
||||
|
||||
#ifdef NEED_STRUCT_TIMESPEC
|
||||
#define HAVE_STRUCT_TIMESPEC 1
|
||||
struct timespec {
|
||||
long tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
#endif /* HAVE_STRUCT_TIMESPEC */
|
||||
|
||||
|
||||
enum {ONE_BILLION=1000000000};
|
||||
|
||||
#ifdef USE_PORTAUDIO
|
||||
@@ -53,8 +65,8 @@ enum {ONE_BILLION=1000000000};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef USE_PULSEAUDIO
|
||||
// create some wrappers for runtime detection
|
||||
|
||||
@@ -203,8 +215,8 @@ static t_wave_callback* my_callback_is_output_enabled=NULL;
|
||||
#define BUFFER_LENGTH (MAX_SAMPLE_RATE*2*sizeof(uint16_t))
|
||||
//#define THRESHOLD (BUFFER_LENGTH/5)
|
||||
static char myBuffer[BUFFER_LENGTH];
|
||||
static char* myRead=NULL;
|
||||
static char* myWrite=NULL;
|
||||
static char* myRead=NULL;
|
||||
static char* myWrite=NULL;
|
||||
static int out_channels=1;
|
||||
static int my_stream_could_start=0;
|
||||
static int wave_samplerate;
|
||||
@@ -223,7 +235,7 @@ static PaError pa_init_err=0;
|
||||
|
||||
// time measurement
|
||||
// The read and write position audio stream in the audio stream are measured in ms.
|
||||
//
|
||||
//
|
||||
// * When the stream is opened, myReadPosition and myWritePosition are cleared.
|
||||
// * myWritePosition is updated in wave_write.
|
||||
// * myReadPosition is updated in pa_callback (+ sample delay).
|
||||
@@ -275,12 +287,12 @@ static void start_stream()
|
||||
PaError err;
|
||||
SHOW_TIME("start_stream");
|
||||
|
||||
my_stream_could_start=0;
|
||||
my_stream_could_start=0;
|
||||
mInCallbackFinishedState = false;
|
||||
|
||||
err = Pa_StartStream(pa_stream);
|
||||
SHOW("start_stream > Pa_StartStream=%d (%s)\n", err, Pa_GetErrorText(err));
|
||||
|
||||
|
||||
#if USE_PORTAUDIO == 19
|
||||
if(err == paStreamIsNotStopped)
|
||||
{
|
||||
@@ -337,7 +349,7 @@ static int pa_callback(void *inputBuffer, void *outputBuffer,
|
||||
memcpy(outputBuffer, myRead, aUsedMem);
|
||||
}
|
||||
char* p = (char*)outputBuffer + aUsedMem;
|
||||
memset(p, 0, n - aUsedMem);
|
||||
memset(p, 0, n - aUsedMem);
|
||||
// myReadPosition += aUsedMem/(out_channels*sizeof(uint16_t));
|
||||
myRead = aWrite;
|
||||
}
|
||||
@@ -367,7 +379,7 @@ static int pa_callback(void *inputBuffer, void *outputBuffer,
|
||||
myRead = myBuffer + aRest;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
SHOW_TIME("pa_callback > underflow");
|
||||
aResult=1; // paComplete;
|
||||
|
||||
@@ -387,7 +399,7 @@ static int pa_callback(void *inputBuffer, void *outputBuffer,
|
||||
|
||||
size_t aUsedMem = aTopMem + aRest;
|
||||
char* p = (char*)outputBuffer + aUsedMem;
|
||||
memset(p, 0, n - aUsedMem);
|
||||
memset(p, 0, n - aUsedMem);
|
||||
// myReadPosition += aUsedMem/(out_channels*sizeof(uint16_t));
|
||||
myRead = aWrite;
|
||||
}
|
||||
@@ -498,8 +510,8 @@ static int wave_open_sound()
|
||||
//paClipOff | paDitherOff,
|
||||
paNoFlag,
|
||||
pa_callback, (void *)userdata);
|
||||
|
||||
SHOW("wave_open_sound > Pa_OpenDefaultStream(1): err=%d (%s)\n",err, Pa_GetErrorText(err));
|
||||
|
||||
SHOW("wave_open_sound > Pa_OpenDefaultStream(1): err=%d (%s)\n",err, Pa_GetErrorText(err));
|
||||
|
||||
if(err == paInvalidChannelCount)
|
||||
{
|
||||
@@ -544,7 +556,7 @@ static int wave_open_sound()
|
||||
// paClipOff | paDitherOff,
|
||||
pa_callback,
|
||||
(void *)userdata);
|
||||
if ((err!=paNoError)
|
||||
if ((err!=paNoError)
|
||||
&& (err!=paInvalidChannelCount)) //err==paUnanticipatedHostError
|
||||
{
|
||||
fprintf(stderr, "wave_open_sound > Pa_OpenStream : err=%d (%s)\n",err,Pa_GetErrorText(err));
|
||||
@@ -600,7 +612,7 @@ static void update_output_parameters(int selectedDevice, const PaDeviceInfo *dev
|
||||
myOutputParameters.channelCount = 1;
|
||||
myOutputParameters.sampleFormat = paInt16;
|
||||
|
||||
// Latency greater than 100ms for avoiding glitches
|
||||
// Latency greater than 100ms for avoiding glitches
|
||||
// (e.g. when moving a window in a graphical desktop)
|
||||
// deviceInfo = Pa_GetDeviceInfo(selectedDevice);
|
||||
if (deviceInfo)
|
||||
@@ -654,15 +666,15 @@ static void select_device(const char* the_api)
|
||||
for( i=0; i<numDevices; i++ )
|
||||
{
|
||||
deviceInfo = Pa_GetDeviceInfo( i );
|
||||
|
||||
|
||||
if (deviceInfo == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
|
||||
|
||||
|
||||
if (hostInfo && hostInfo->type == paALSA)
|
||||
{
|
||||
{
|
||||
// Check (once) the default output device
|
||||
if (defaultAlsaIndex == numDevices)
|
||||
{
|
||||
@@ -671,23 +683,23 @@ static void select_device(const char* the_api)
|
||||
update_output_parameters(defaultAlsaIndex, deviceInfo);
|
||||
if (Pa_IsFormatSupported(NULL, &myOutputParameters, wave_samplerate) == 0)
|
||||
{
|
||||
SHOW( "select_device > ALSA (default), name=%s (#%d)\n", deviceInfo->name, defaultAlsaIndex);
|
||||
SHOW( "select_device > ALSA (default), name=%s (#%d)\n", deviceInfo->name, defaultAlsaIndex);
|
||||
selectedIndex = defaultAlsaIndex;
|
||||
selectedDeviceInfo = deviceInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if the default output device does not match,
|
||||
// look for the device with the highest number of output channels
|
||||
|
||||
// if the default output device does not match,
|
||||
// look for the device with the highest number of output channels
|
||||
SHOW( "select_device > ALSA, i=%d (numDevices=%d)\n", i, numDevices);
|
||||
|
||||
|
||||
update_output_parameters(i, deviceInfo);
|
||||
|
||||
|
||||
if (Pa_IsFormatSupported(NULL, &myOutputParameters, wave_samplerate) == 0)
|
||||
{
|
||||
SHOW( "select_device > ALSA, name=%s (#%d)\n", deviceInfo->name, i);
|
||||
|
||||
|
||||
if (!selectedDeviceInfo
|
||||
|| (selectedDeviceInfo->maxOutputChannels < deviceInfo->maxOutputChannels))
|
||||
{
|
||||
@@ -703,14 +715,14 @@ static void select_device(const char* the_api)
|
||||
{
|
||||
update_output_parameters(selectedIndex, selectedDeviceInfo);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
i = Pa_GetDefaultOutputDevice();
|
||||
deviceInfo = Pa_GetDeviceInfo( i );
|
||||
update_output_parameters(i, deviceInfo);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//>
|
||||
@@ -798,18 +810,18 @@ void* wave_open(const char* the_api)
|
||||
//<copyBuffer
|
||||
|
||||
|
||||
static size_t copyBuffer(char* dest, char* src, const size_t theSizeInBytes)
|
||||
{
|
||||
static size_t copyBuffer(char* dest, char* src, const size_t theSizeInBytes)
|
||||
{
|
||||
size_t bytes_written = 0;
|
||||
unsigned int i = 0;
|
||||
uint16_t* a_dest = NULL;
|
||||
uint16_t* a_src = NULL;
|
||||
|
||||
|
||||
if ((src != NULL) && dest != NULL)
|
||||
{
|
||||
{
|
||||
// copy for one channel (mono)?
|
||||
if(out_channels==1)
|
||||
{
|
||||
{
|
||||
SHOW("copyBuffer > 1 channel > memcpy %x (%d bytes)\n", (int)myWrite, theSizeInBytes);
|
||||
memcpy(dest, src, theSizeInBytes);
|
||||
bytes_written = theSizeInBytes;
|
||||
@@ -820,7 +832,7 @@ static size_t copyBuffer(char* dest, char* src, const size_t theSizeInBytes)
|
||||
i = 0;
|
||||
a_dest = (uint16_t* )dest;
|
||||
a_src = (uint16_t* )src;
|
||||
|
||||
|
||||
for(i=0; i<theSizeInBytes/2; i++)
|
||||
{
|
||||
a_dest[2*i] = a_src[i];
|
||||
@@ -829,8 +841,8 @@ static size_t copyBuffer(char* dest, char* src, const size_t theSizeInBytes)
|
||||
bytes_written = 2*theSizeInBytes;
|
||||
} // end if(out_channels==1)
|
||||
} // end if ((src != NULL) && dest != NULL)
|
||||
|
||||
return bytes_written;
|
||||
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
//>
|
||||
@@ -843,7 +855,7 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
|
||||
// space in ringbuffer for the sample needed: 1x mono channel but 2x for 1 stereo channel
|
||||
size_t bytes_to_write = (out_channels==1) ? theSize : theSize*2;
|
||||
my_stream_could_start = 0;
|
||||
|
||||
|
||||
if(pa_stream == NULL)
|
||||
{
|
||||
SHOW_TIME("wave_write > wave_open_sound\n");
|
||||
@@ -859,16 +871,16 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
|
||||
my_stream_could_start = 1;
|
||||
}
|
||||
assert(BUFFER_LENGTH >= bytes_to_write);
|
||||
|
||||
|
||||
if (myWrite >= myBuffer + BUFFER_LENGTH)
|
||||
{
|
||||
myWrite = myBuffer;
|
||||
} // end if (myWrite >= myBuffer + BUFFER_LENGTH)
|
||||
|
||||
|
||||
size_t aTotalFreeMem=0;
|
||||
char* aRead = myRead;
|
||||
SHOW("wave_write > aRead=%x, myWrite=%x\n", (int)aRead, (int)myWrite);
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (my_callback_is_output_enabled && (0==my_callback_is_output_enabled()))
|
||||
@@ -876,9 +888,9 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
|
||||
SHOW_TIME("wave_write > my_callback_is_output_enabled: no!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
aRead = myRead;
|
||||
|
||||
|
||||
// write pointer is before read pointer?
|
||||
if (myWrite >= aRead)
|
||||
{
|
||||
@@ -888,27 +900,27 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
|
||||
{
|
||||
aTotalFreeMem = aRead - myWrite;
|
||||
} // end if (myWrite >= aRead)
|
||||
|
||||
|
||||
if (aTotalFreeMem>1)
|
||||
{
|
||||
// -1 because myWrite must be different of aRead
|
||||
// otherwise buffer would be considered as empty
|
||||
aTotalFreeMem -= 1;
|
||||
} // end if (aTotalFreeMem>1)
|
||||
|
||||
|
||||
if (aTotalFreeMem >= bytes_to_write)
|
||||
{
|
||||
break;
|
||||
} // end if (aTotalFreeMem >= bytes_to_write)
|
||||
|
||||
|
||||
//SHOW_TIME("wave_write > wait");
|
||||
SHOW("wave_write > wait: aTotalFreeMem=%d\n", aTotalFreeMem);
|
||||
SHOW("wave_write > aRead=%x, myWrite=%x\n", (int)aRead, (int)myWrite);
|
||||
usleep(10000);
|
||||
} // end while (1)
|
||||
|
||||
|
||||
aRead = myRead;
|
||||
|
||||
|
||||
// write pointer is ahead the read pointer?
|
||||
if (myWrite >= aRead)
|
||||
{
|
||||
@@ -945,17 +957,17 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
|
||||
SHOW_TIME("wave_write > myWrite <= aRead");
|
||||
myWrite += copyBuffer(myWrite, theMono16BitsWaveBuffer, theSize);
|
||||
} // end if (myWrite >= aRead)
|
||||
|
||||
|
||||
bytes_written = bytes_to_write;
|
||||
myWritePosition += theSize/sizeof(uint16_t); // add number of samples
|
||||
|
||||
|
||||
if (my_stream_could_start && (get_used_mem() >= out_channels * sizeof(uint16_t) * FRAMES_PER_BUFFER))
|
||||
{
|
||||
start_stream();
|
||||
} // end if (my_stream_could_start && (get_used_mem() >= out_channels * sizeof(uint16_t) * FRAMES_PER_BUFFER))
|
||||
|
||||
|
||||
SHOW_TIME("wave_write > LEAVE");
|
||||
|
||||
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
@@ -974,7 +986,7 @@ int wave_close(void* theHandler)
|
||||
SHOW_TIME("wave_close > LEAVE (NULL stream)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if( Pa_IsStreamStopped( pa_stream ) )
|
||||
{
|
||||
SHOW_TIME("wave_close > LEAVE (stopped)");
|
||||
@@ -986,7 +998,7 @@ int wave_close(void* theHandler)
|
||||
SHOW_TIME("wave_close > LEAVE (NULL stream)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if( Pa_StreamActive( pa_stream ) == false && mInCallbackFinishedState == false )
|
||||
{
|
||||
SHOW_TIME("wave_close > LEAVE (not active)");
|
||||
@@ -1002,20 +1014,20 @@ int wave_close(void* theHandler)
|
||||
SHOW_TIME("wave_close > LEAVE (stopStreamCount)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Comment from Audacity-1.2.4b adapted to the eSpeak context.
|
||||
|
||||
// Comment from Audacity-1.2.4b adapted to the eSpeak context.
|
||||
//
|
||||
// We got here in one of two ways:
|
||||
//
|
||||
// 1. The calling program calls the espeak_Cancel function and we
|
||||
// therefore want to stop as quickly as possible.
|
||||
// 1. The calling program calls the espeak_Cancel function and we
|
||||
// therefore want to stop as quickly as possible.
|
||||
// So we use AbortStream(). If this is
|
||||
// the case the portaudio stream is still in the Running state
|
||||
// (see PortAudio state machine docs).
|
||||
//
|
||||
// 2. The callback told PortAudio to stop the stream since it had
|
||||
// reached the end of the selection.
|
||||
// The event polling thread discovered this by noticing that
|
||||
// reached the end of the selection.
|
||||
// The event polling thread discovered this by noticing that
|
||||
// wave_is_busy() returned false.
|
||||
// wave_is_busy() (which calls Pa_GetStreamActive()) will not return
|
||||
// false until all buffers have finished playing, so we can call
|
||||
@@ -1030,7 +1042,7 @@ int wave_close(void* theHandler)
|
||||
// call StopStream if the callback brought us here, and AbortStream
|
||||
// if the user brought us here.
|
||||
//
|
||||
|
||||
|
||||
#if (USE_PORTAUDIO == 19)
|
||||
if (pa_stream)
|
||||
{
|
||||
@@ -1114,14 +1126,14 @@ int wave_is_busy(void* theHandler)
|
||||
if (pa_stream)
|
||||
{
|
||||
#if USE_PORTAUDIO == 18
|
||||
active = Pa_StreamActive(pa_stream)
|
||||
active = Pa_StreamActive(pa_stream)
|
||||
&& (mInCallbackFinishedState == false);
|
||||
#else
|
||||
active = Pa_IsStreamActive(pa_stream)
|
||||
&& (mInCallbackFinishedState == false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
SHOW("wave_is_busy: %d\n",active);
|
||||
|
||||
|
||||
@@ -1160,7 +1172,7 @@ int wave_get_remaining_time(uint32_t sample, uint32_t* time)
|
||||
|
||||
if (!time || !pa_stream)
|
||||
{
|
||||
SHOW("event get_remaining_time> %s\n","audio device not available");
|
||||
SHOW("event get_remaining_time> %s\n","audio device not available");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1246,7 +1258,7 @@ void add_time_in_ms(struct timespec *ts, int time_in_ms)
|
||||
{
|
||||
SHOW("event > add_time_in_ms ns: %d sec %Lu nsec \n", ts->tv_sec, t_ns);
|
||||
ts->tv_sec += 1;
|
||||
t_ns -= ONE_BILLION;
|
||||
t_ns -= ONE_BILLION;
|
||||
}
|
||||
ts->tv_nsec = (long int)t_ns;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user