PageRenderTime 49ms CodeModel.GetById 33ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/native/external/espeak/platforms/windows/make_espeak.iss

http://eyes-free.googlecode.com/
Unknown | 394 lines | 340 code | 54 blank | 0 comment | 0 complexity | 35246a6ebd99f69fe663d0377a0fb40e MD5 | raw file
  1; This is the script for "Inno Setup 5" to create the setup_espeak.exe installer for Windows
  2
  3[Setup]
  4AppName=eSpeak
  5AppVerName=eSpeak version 1.39
  6AppCopyright=Licensed under GNU General Public License version 3.   (See file License.txt for details).
  7WindowVisible=yes
  8
  9DefaultDirName={pf}\eSpeak
 10DefaultGroupName=eSpeak
 11OutputBaseFilename=setup_espeak
 12Compression=lzma
 13SolidCompression=yes
 14ShowLanguageDialog=auto
 15
 16[InstallDelete]
 17Type: files; Name: "{app}\espeak.dll"
 18
 19[Dirs]
 20Name: "{app}\espeak-data\soundicons"
 21Name: "{app}\espeak-data\mbrola"
 22
 23[Files]
 24Source: "espeak_sapi.dll"; DestDir: "{app}"; Flags: regserver promptifolder replacesameversion
 25Source: "TTSApp.exe"; DestDir:"{app}"
 26Source: "espeak-data\*"; DestDir: "{app}\espeak-data"; Flags: recursesubdirs
 27Source: "dictsource\*"; DestDir: "{app}\dictsource"; Flags: recursesubdirs
 28Source: "docs\*"; DestDir: "{app}\docs"; Flags: recursesubdirs
 29Source: "command_line\*"; DestDir: "{app}\command_line"
 30Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
 31Source: "License.txt"; DestDir: "{app}";
 32
 33[Registry]
 34Root: HKLM; Subkey: "Software\Microsoft\Speech\Voices\Tokens\eSpeak"; Flags: deletekey uninsdeletekey
 35Root: HKLM; Subkey: "Software\Microsoft\Speech\Voices\Tokens\eSpeak_1"; Flags: deletekey uninsdeletekey
 36Root: HKLM; Subkey: "Software\Microsoft\Speech\Voices\Tokens\eSpeak_2"; Flags: deletekey uninsdeletekey
 37Root: HKLM; Subkey: "Software\Microsoft\Speech\Voices\Tokens\eSpeak_3"; Flags: deletekey uninsdeletekey
 38Root: HKLM; Subkey: "Software\Microsoft\Speech\Voices\Tokens\eSpeak_4"; Flags: deletekey uninsdeletekey
 39Root: HKLM; Subkey: "Software\Microsoft\Speech\Voices\Tokens\eSpeak_5"; Flags: deletekey uninsdeletekey
 40Root: HKLM; Subkey: "Software\Microsoft\Speech\PhoneConverters\Tokens\eSpeak"; Flags: deletekey uninsdeletekey
 41
 42
 43[Languages]
 44Name: "en"; MessagesFile: "compiler:Default.isl"
 45Name: "af"; MessagesFile: "compiler:Languages\Afrikaans.isl"
 46Name: "bs"; MessagesFile: "compiler:Languages\Bosnian.isl"
 47Name: "cs"; MessagesFile: "compiler:Languages\Czech.isl"
 48Name: "de"; MessagesFile: "compiler:Languages\German.isl"
 49Name: "el"; MessagesFile: "compiler:Languages\Greek.isl"
 50Name: "es"; MessagesFile: "compiler:Languages\Spanish.isl"
 51Name: "fi"; MessagesFile: "compiler:Languages\Finnish.isl"
 52Name: "fr"; MessagesFile: "compiler:Languages\French.isl"
 53Name: "hr"; MessagesFile: "compiler:Languages\Croatian.isl"
 54Name: "hu"; MessagesFile: "compiler:Languages\Hungarian.isl"
 55Name: "it"; MessagesFile: "compiler:Languages\Italian.isl"
 56Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl"
 57Name: "no"; MessagesFile: "compiler:Languages\Norwegian.isl"
 58Name: "pl"; MessagesFile: "compiler:Languages\Polish.isl"
 59Name: "pt"; MessagesFile: "compiler:Languages\Portuguese.isl"
 60Name: "ro"; MessagesFile: "compiler:Languages\Romanian.isl"
 61Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl"
 62Name: "sk"; MessagesFile: "compiler:Languages\Slovak.isl"
 63Name: "sr"; MessagesFile: "compiler:Languages\Serbian.isl"
 64Name: "tr"; MessagesFile: "compiler:Languages\Turkish.isl"
 65
 66[CustomMessages]
 67v1=Select which voices to install
 68v2=or press Enter to accept defaults
 69v3=Enter voice names, eg: (for Portuguese)   pt,  or with a variant, eg: pt+f3
 70
 71bs.v1=Odaberite jezik kojeg želite instalirati
 72bs.v2=ili pritisnite Enter za prihvat zadanih.
 73bs.v3=Upišite, npr. bs (za Bosanski) ili s varjantom: bs+f3
 74
 75fr.v1=Sélectionnez les voix ? installer
 76fr.v2=ou appuyez sur Entrée pour accepter les valeurs par défaut.
 77fr.v3=Entrez le nom des voix, ex : (pour le Français) fr, ou avec une variante ex : fr+f3
 78
 79hr.v1=Odaberite jezik kojeg želite instalirati
 80hr.v2=ili pritisnite Enter za prihvat zadanih.
 81hr.v3=Upišite, npr. hr (za Hrvatski) ili s varjantom: hr+f3
 82
 83pt.v1=Seleccione as vozes que pretende instalar
 84pt.v2=ou precione enter para aceitar as predefinidas.
 85pt.v3=Introduza os nomes das vozes, ex: (Brazil) pt (ou Portugal) pt-pt, ou com outras caracter?sticas, ex: pt+f3
 86
 87sr.v1=Molimo vas da odaberete glasove, koje želite da instalirate
 88sr.v2=ili pritisnite Enter za instalaciju podrazumevanih glasova.
 89sr.v3=Da odaberete glas, unesite ime glasa kojeg želite instalirati, na primer sr, ili sr+f3
 90
 91
 92[Code]
 93var
 94  UILanguage: Integer;
 95  UIVoice: String;
 96  Page: TInputQueryWizardPage;
 97
 98const
 99  sEspeak = 'eSpeak-';
100  RegVoice1 = 'Software\Microsoft\Speech\Voices\Tokens\eSpeak';
101  RegPhConv = 'Software\Microsoft\Speech\PhoneConverters\Tokens';
102
103
104function VoiceFromLanguage(language: Integer): String;
105var
106  lang_main: Integer;
107
108begin
109  lang_main := language and $3ff;
110  Result := 'en';
111
112  // translation from microsoft codes to language codes
113  case lang_main of
114  $04: Result := 'zh';
115  $05: Result := 'cs';
116  $06: Result := 'da';
117  $07: Result := 'de';
118  $08: Result := 'el';
119  $09: Result := 'en';
120  $0a: Result := 'es-la';
121  $0b: Result := 'fi';
122  $0c: Result := 'fr';
123  $0e: Result := 'hu';
124  $0f: Result := 'is';
125  $10: Result := 'it';
126  $12: Result := 'ko';
127  $13: Result := 'nl';
128  $14: Result := 'no';
129  $15: Result := 'pl';
130  $16: Result := 'pt';
131  $18: Result := 'ro';
132  $19: Result := 'ru';
133  $1a: Result := 'hr';
134  $1b: Result := 'sk';
135  $1d: Result := 'sv';
136  $1f: Result := 'tr';
137  $21: Result := 'id';
138  $2a: Result := 'vi';
139  $2f: Result := 'mk';
140  $36: Result := 'af';
141  $39: Result := 'hi';
142  $41: Result := 'sw';
143  $49: Result := 'ta';
144  $52: Result := 'cy';
145  $87: Result := 'rw';
146  end;
147
148  // is there a match on the full language code?
149  case language of
150  $40a: Result := 'es';
151  $c0a: Result := 'es';
152  $816: Result := 'pt-pt';
153  $41a: Result := 'hr';
154  $81a: Result := 'sr';
155  $c1a: Result := 'sr';
156  $141a: Result := 'bs';
157  end;
158end;
159
160
161function LanguageFromVoice(voice: String): String;
162var
163  value: Integer;
164  lang1: String;
165  len: Integer;
166begin
167  value := $409;   // default en-us
168
169  lang1 := Copy(voice,0,2);
170  if lang1 = 'mb' then
171  begin
172    lang1 := Copy(voice,3,3);
173    len := Length(voice);
174    if len > 8 then
175      lang1 := Copy(voice,8,6);  // eg. mb-de4-en, return 'en'
176  end;
177  
178  case lang1 of
179  'af': value := $436;
180  'bs': value := $41a;   // should be $141a but Jaws crashes on startup
181  'cs': value := $405;
182  'cy': value := $452;
183  'da': value := $406;
184  'de': value := $407;
185  'el': value := $408;
186  'en': value := $409;
187  'es': value := $40a;
188  'fi': value := $40b;
189  'fr': value := $40c;
190  'hi': value := $439;
191  'hr': value := $41a;
192  'hu': value := $40e;
193  'id': value := $421;
194  'is': value := $40f;
195  'it': value := $410;
196  'ko': value := $412;
197  'mk': value := $42f;
198  'nl': value := $413;
199  'no': value := $414;
200  'pl': value := $415;
201  'pt': value := $416;
202  'ro': value := $418;
203  'ru': value := $419;
204  'rw': value := $487;
205  'sk': value := $41b;
206  'sr': value := $81a;
207  'sv': value := $41d;
208  'sw': value := $441;
209  'ta': value := $449;
210  'tr': value := $41f;
211  'vi': value := $42a;
212  'zh': value := $804;
213  // mbrola voices
214  '-af': value := $436;
215  '-br': value := $416;
216  '-ca': value := $c0c;
217  '-cr': value := $41a;
218  '-cz': value := $405;
219  '-de': value := $407;
220  '-en': value := $809;
221  '-es': value := $40a;
222  '-fr': value := $40c;
223  '-gr': value := $408;
224  '-hu': value := $40e;
225  '-ic': value := $40f;
226  '-in': value := $439;
227  '-it': value := $410;
228  '-mx': value := $80a;
229  '-nl': value := $413;
230  '-pl': value := $415;
231  '-pt': value := $816;
232  '-ro': value := $418;
233  '-sw': value := $41d;
234  '-us': value := $409;
235  '-vz': value := $200a;
236  end;
237
238  // check for specific voices
239  case voice of
240  'pt-pt': value := $816;
241  end;
242  
243  Result := Format('%X',[value]);
244end;
245
246
247// is the language number already in a PhoneConvertor ?
248function CheckPhoneConvertors(Lcode: String): Integer;
249var
250  Convertors: TArrayOfString;
251  ix: Integer;
252  len: Integer;
253  s1: String;
254  s2: String;
255  sLangs: String;
256begin
257  Result := 0;
258  len := Length(Lcode);
259  if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, RegPhConv, Convertors) then
260  begin
261    for ix := 0 to GetArrayLength(Convertors) - 1 do
262    begin
263      s1 := RegPhConv + '\' + Convertors[ix] + '\Attributes';
264      if RegQueryStringValue(HKEY_LOCAL_MACHINE, s1, 'Language', sLangs) then
265      begin
266        s2 := Copy(sLangs, 1, len);
267        if s2 = Lcode then
268          Result := 1;
269        if sLangs = Lcode then
270          Result := 1;
271        if Pos(';' + Lcode, sLangs) > 0 then
272          Result := 1;
273      end;
274    end;
275  end;
276end;
277
278// ensure the language number is included in a PhoneConvertor
279procedure SetPhoneConvertor(Lcode: String);
280var
281  done: Boolean;
282  s1: String;
283  sLangs: String;
284begin
285  if CheckPhoneConvertors(Lcode) = 0 then
286  begin
287    done := False;
288    s1 := RegPhConv + '\Universal\Attributes';
289    if RegQueryStringValue(HKEY_LOCAL_MACHINE, s1, 'Language', sLangs) then
290    begin
291      done := RegWriteStringValue(HKEY_LOCAL_MACHINE, s1, 'Language', Lcode + ';' + sLangs);
292    end;
293
294    if done = False then
295    begin
296      s1 := RegPhConv + '\eSpeak\Attributes';
297      if RegQueryStringValue(HKEY_LOCAL_MACHINE, s1, 'Language', sLangs) = False then
298      begin
299        // add 'eSpeak' dummy PhoneConvertor
300        RegWriteStringValue(HKEY_LOCAL_MACHINE, RegPhConv + '\eSpeak', 'CLSID','{9185F743-1143-4C28-86B5-BFF14F20E5C8}');
301        RegWriteStringValue(HKEY_LOCAL_MACHINE, RegPhConv + '\eSpeak', 'PhoneMap','- 0001');
302        RegWriteStringValue(HKEY_LOCAL_MACHINE, s1, 'Language','');
303      end;
304      
305      if RegQueryStringValue(HKEY_LOCAL_MACHINE, s1, 'Language', sLangs) then
306      begin
307        done := RegWriteStringValue(HKEY_LOCAL_MACHINE, s1, 'Language', Lcode + ';' + sLangs);
308      end;
309    end;
310  end;
311end;
312
313
314procedure SetupVoice(Voice, Lcode: String; Index: Integer);
315var
316  RegVoice2: String;
317  RegVoice2a: String;
318  VoiceUC: String;
319  
320begin
321  if Index = 0 then
322    RegVoice2 := RegVoice1
323  else
324    RegVoice2 := RegVoice1 + Format('_%d',[Index]);
325    
326  RegVoice2a := RegVoice2 + '\Attributes';
327
328  if Voice = 'default' then
329    VoiceUC := 'default'
330  else
331    VoiceUC := Uppercase(Voice);
332    
333  RegWriteStringValue(HKEY_LOCAL_MACHINE,RegVoice2,'',sEspeak+VoiceUC);
334  RegWriteStringValue(HKEY_LOCAL_MACHINE,RegVoice2,'CLSID','{BE985C8D-BE32-4A22-AA93-55C16A6D1D91}');
335  RegWriteStringValue(HKEY_LOCAL_MACHINE,RegVoice2,'Path',ExpandConstant('{app}'));
336  RegWriteStringValue(HKEY_LOCAL_MACHINE,RegVoice2,'VoiceName',Voice);
337
338  RegWriteStringValue(HKEY_LOCAL_MACHINE,RegVoice2a,'Name',sEspeak+Voice);
339  RegWriteStringValue(HKEY_LOCAL_MACHINE,RegVoice2a,'Gender','Male');
340  RegWriteStringValue(HKEY_LOCAL_MACHINE,RegVoice2a,'Age','Adult');
341  RegWriteStringValue(HKEY_LOCAL_MACHINE,RegVoice2a,'Language',Lcode);
342  RegWriteStringValue(HKEY_LOCAL_MACHINE,RegVoice2a,'Vendor','Jonathan Duddington');
343  
344  SetPhoneConvertor(Lcode);
345end;
346
347
348
349procedure CurStepChanged(CurStep: TSetupStep);
350var
351  ix: Integer;
352begin
353  if CurStep = ssPostInstall then
354  begin
355
356    for ix := 0 to 5 do begin
357      if Page.Values[ix] <> '' then
358       SetUpVoice(Page.Values[ix],LanguageFromVoice(Page.Values[ix]),ix);
359    end;
360  end;
361end;
362
363
364procedure InitializeWizard;
365var
366  lang: String;
367begin
368  // Create the language selection page
369  lang := ActiveLanguage;
370  Page := CreateInputQueryPage(wpSelectDir,CustomMessage('v1'),CustomMessage('v2'),CustomMessage('v3'));
371
372  // Add items (False means it's not a password edit)
373  Page.Add('', False);
374  Page.Add('', False);
375  Page.Add('', False);
376  Page.Add('', False);
377  Page.Add('', False);
378  Page.Add('', False);
379
380  UILanguage := GetUILanguage;
381  UIVoice := VoiceFromLanguage(UILanguage);
382
383  // Set initial values (optional)
384  Page.Values[0] := UIVoice;
385  Page.Values[1] := UIVoice+'+f2';
386  if UIVoice = 'en' then
387    Page.Values[2] := 'en-r'
388  else
389    Page.values[2] := 'en';
390
391end;
392
393
394