Fixes #2579: Added support for Trainer signal alarm
[opentx.git] / radio / util / tts.py
blobd0cf30f72a5cd9991ba908888db81728a895b3a8
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
5 # To use this script you need the following installed within python
6 # Python 2.5 http://www.python.org/download/releases/2.5.4/
7 # Python 2.7 http://www.python.org/download/releases/2.7.3/
8 # PyTTS http://pypi.python.org/pypi/pyTTS
9 # PyWin32 http://sourceforge.net/projects/pywin32/files/pywin32/
11 # Note
12 # At the moment, pyTTS is only available for Python 2.3, 2.4 and 2.5. To use it for later versions without having to
13 # recompile it, a quick and dirty solution is to:
14 # copy the entire pyTTS directory from Python25\Lib\site-packages to Python26 or Python27
15 # replace TTSFast.py with an empty file. This way the version-dependent pyd file isn't loaded.
17 # in addition you will need some tools.
18 # ffmpeg, sox, adconvertor ttscmd (2cnd speach centre)
19 # have fun!
20 # Sound pack maintainers (incomplete list) by language alphabetical order
21 # Czech : Martin Hotar
22 # French : Bertrand Songis & André Bernet
23 # English : Rob Thompson & Martin Hotar
24 # German : Romolo Manfredini (Some corrections by Peer)
25 # Italian : Romolo Manfredini
26 # Portuguese : Romolo Manfredini
27 # Spanish : Romolo Manfredini (With the help of Jose Moreno)
29 import os, sys, shutil, platform, subprocess, wave, zipfile, httplib, urllib
31 NO_ALTERNATE = 1024
33 def filename(idx, alternate=0):
34 if "gruvin9x" in sys.argv:
35 ext = ".ad4"
36 else:
37 ext = ".wav"
38 if isinstance(idx, int):
39 result = "%04d%s" % (idx, ext)
40 elif board in ('sky9x', 'taranis'):
41 result = idx + ext
42 else:
43 if alternate >= NO_ALTERNATE:
44 return None
45 result = "%04d%s" % (alternate, ext)
46 return result
48 def wavstrip(filename):
49 output = "_" + filename
50 subprocess.Popen(["sox", filename, output, "silence", "1", "0.1", "0.1%", "reverse", "silence", "1", "0.1", "0.1%", "reverse"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
51 os.remove(filename)
52 os.rename(output, filename)
55 def generate(str, filename):
56 print filename, str
58 if not str:
59 str = " !" #this is so blank wav files never exist!
61 if "speak" in sys.argv:
62 if "sapi" in sys.argv:
63 tts.Speak(str)
64 elif "espeak" in sys.argv:
65 subprocess.Popen(["espeak", "-v", espeakVoice, "-s", espeakspeed, "-z", str.encode("utf-8")], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
66 elif "google" in sys.argv:
67 "speak not implemented with google tts engine"
68 exit()
69 else:
70 print "which speach engine?"
71 exit()
72 else:
73 if "sapi" in sys.argv:
74 ttsfilename = "ttsfile.wav"
75 tts.SpeakToWave(ttsfilename, str)
76 elif "sapi2" in sys.argv:
77 ttsfilename = "ttsfile.wav"
78 subprocess.Popen(["ttscmd", "/ttw", str.encode("utf-8"), ttsfilename, "-v", voiceID, "-b", "32","-s", "\"-3\"","-w","32","-f","47"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
79 elif "espeak" in sys.argv:
80 ttsfilename = "ttsfile.wav"
81 subprocess.Popen(["espeak", "-v", espeakVoice, "-s", espeakspeed, "-z", "-w", ttsfilename, str.encode("utf-8")], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
82 elif "google" in sys.argv:
83 ttsmp3 = "ttsfile.mp3"
84 ttsfilename = "ttsfile.wav"
85 conn = httplib.HTTPConnection("translate.google.com")
86 params = urllib.urlencode({'ie': "UTF-8", 'tl': directory, 'q': str.encode("utf-8")})
87 headers = {"User-Agent": "Mozilla"}
88 conn.request("GET", u"/translate_tts?%s" % params, headers=headers)
89 # conn.request("GET", "/translate_tts?ie=UTF-8&tl=%s&q=%s" % (directory, urllib.urlencode(str)), headers={"User-Agent": "Mozilla"})
90 resp = conn.getresponse()
91 file(ttsmp3, "wb").write(resp.read())
92 subprocess.Popen(["ffmpeg", "-y", "-i", ttsmp3, "-acodec", "pcm_s16le", ttsfilename], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
93 conn.close()
95 else:
96 print "which speach engine?"
97 exit()
99 wavstrip(ttsfilename)
101 if board in ('sky9x', 'taranis'):
102 if 'sox' in sys.argv:
103 maxvolume = subprocess.Popen(["sox", ttsfilename, "-n", "stat", "-v"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1]
104 if "not sound" in maxvolume:
105 subprocess.Popen(["sox", "--show-progress", filename, ttsfilename], stdout=subprocess.PIPE).communicate()[0];
106 else:
107 subprocess.Popen(["sox", "--show-progress","-v", maxvolume, filename, ttsfilename], stdout=subprocess.PIPE).communicate()[0];
108 if board == 'sky9x':
109 subprocess.Popen(["sox", "-twav", ttsfilename, "-b1600", "-c1", "-e", "a-law", filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
110 else:
111 subprocess.Popen(["sox", "-twav", ttsfilename, "-b32000", "-c1", "-e", "a-law", filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
112 else:
113 if board == 'sky9x':
114 subprocess.Popen(["ffmpeg", "-y", "-i", ttsfilename, "-acodec", defaultcodec, "-ar", "16000", filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
115 else:
116 subprocess.Popen(["ffmpeg", "-y", "-i", ttsfilename, "-acodec", defaultcodec, "-ar", "32000", filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
117 elif board == 'gruvin9x':
118 subprocess.Popen(["AD4CONVERTER", "-E4", ttsfilename], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
119 os.rename(ttsfilename.replace(".wav", ".ad4"), filename)
120 else:
121 subprocess.Popen(["ffmpeg", "-y", "-i", ttsfilename, "-acodec", "pcm_u8", "-ar", "16000", filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
122 os.remove(ttsfilename)
124 ################################################################
126 def ttsEn():
127 systemSounds = []
128 sounds = []
130 for i in range(100):
131 systemSounds.append((str(i), filename(PROMPT_SYSTEM_BASE+i)))
132 for i in range(9):
133 systemSounds.append((str(100*(i+1)), filename(PROMPT_SYSTEM_BASE+100+i)))
134 for i, s in enumerate(["thousand", "and", "minus", "point"]):
135 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+109+i)))
136 for i, s in enumerate(["volt", "volts",
137 "amp", "amps",
138 "milliamp", "milliamps",
139 "knot", "knots",
140 "meter per second", "meters per second",
141 "foot per second", "feet per second",
142 "kilometer per hour", "kilometers per hour",
143 "mile per hour", "miles per hour",
144 "meter", "meters",
145 "foot", "feet",
146 "degree celsius", "degrees celsius",
147 "degree fahrenheit", "degrees fahrenheit",
148 "percent", "percent",
149 "milliamp-hour", "milliamp-hours",
150 "watt", "watts",
151 "db", "db",
152 "r p m", "r p m",
153 "g", "g",
154 "degree", "degrees",
155 "milliliter", "milliliters",
156 "fluid ounce", "fluid ounces",
157 "hour", "hours",
158 "minute", "minutes",
159 "second", "seconds",
161 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+115+i)))
162 for i, s in enumerate(["point zero", "point one", "point two", "point three",
163 "point four", "point five", "point six",
164 "point seven", "point eight", "point nine"]):
165 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+165+i)))
166 for s, f, a in [(u"trim center", "midtrim", 495),
167 (u"maximum trim reached", "endtrim", NO_ALTERNATE),
168 (u"transmitter battery low", "lowbatt", 485),
169 (u"inactivity alarm", "inactiv", 486),
170 (u"throttle warning", "thralert", 481),
171 (u"switch warning", "swalert", 482),
172 (u"bad eeprom", "eebad", 483),
173 (u"Welcome to open tea ex!", "tada", 480),
174 (u"twenty. seconds", "timer20", 500),
175 (u"thirty. seconds", "timer30", 501),
176 (u"A1,low", "a1_org", NO_ALTERNATE),
177 (u"A1,critical", "a1_red", NO_ALTERNATE),
178 (u"A2,low", "a2_org", NO_ALTERNATE),
179 (u"A2,critical", "a2_red", NO_ALTERNATE),
180 (u"A3,low", "a3_org", NO_ALTERNATE),
181 (u"A3,critical", "a3_red", NO_ALTERNATE),
182 (u"A4,low", "a4_org", NO_ALTERNATE),
183 (u"A4,critical", "a4_red", NO_ALTERNATE),
184 (u"RF signal, low", "rssi_org", NO_ALTERNATE),
185 (u"RF signal, critical", "rssi_red", NO_ALTERNATE),
186 (u"radio antenna defective", "swr_red", NO_ALTERNATE),
187 (u"telemetry lost", "telemko", NO_ALTERNATE),
188 (u"telemetry recovered", "telemok", NO_ALTERNATE),
189 (u"trainer signal lost", "trainko", NO_ALTERNATE),
190 (u"trainer signal recovered", "trainok", NO_ALTERNATE),
192 systemSounds.append((s, filename(f, a)))
193 for i, (s, f) in enumerate([
194 (u"gear!, up!", "gearup"),
195 (u"gear!, down!", "geardn"),
196 (u"flaps!, up!", "flapup"),
197 (u"flaps!, down!", "flapdn"),
198 (u"spoiler!, up!", "splrup"),
199 (u"spoiler!, down!", "splrdn"),
200 (u"trainer!, on!", "trnon"),
201 (u"trainer!, off!", "trnoff"),
202 (u"engine!, off!", "engoff"),
203 (u"too. high!", "tohigh"),
204 (u"too. low!", "tolow"),
205 (u"low. battery!", "lowbat"),
206 (u"crow!, on!", "crowon"),
207 (u"crow!, off!", "crowof"),
208 (u"rf. signal!, low!", "siglow"),
209 (u"rf. signal!, critical!", "sigcrt"),
210 (u"high. speed. mode!, active", "spdmod"),
211 (u"thermal. mode!, on", "thmmod"),
212 (u"normal. mode!, on", "nrmmod"),
213 (u"landing. mode!, on", "lnding"),
214 (u"acro. mode!, on", "acro"),
215 (u"flight. mode!, one", "fm-1"),
216 (u"flight. mode!, two", "fm-2"),
217 (u"flight. mode!, three", "fm-3"),
218 (u"flight. mode!, four", "fm-4"),
219 (u"flight. mode!, five", "fm-5"),
220 (u"flight. mode!, six", "fm-6"),
221 (u"flight. mode!, seven", "fm-7"),
222 (u"flight. mode!, eight", "fm-8"),
223 (u"vario!, on", "vrion"),
224 (u"vario!, off", "vrioff"),
225 (u"flight mode!, power", "fm-pwr"),
226 (u"flight mode!, land", "fm-lnd"),
227 (u"flight mode!, float", "fm-flt"),
228 (u"flight mode!, speed", "fm-spd"),
229 (u"flight mode!, fast", "fm-fst"),
230 (u"flight mode!, normal", "fm-nrm"),
231 (u"flight mode!, cruise", "fm-crs"),
232 (u"flight mode!, acro", "fm-acr"),
233 (u"flight mode!, race", "fm-rce"),
234 (u"flight mode!, launch", "fm-lch"),
235 (u"flight mode!, ping", "fm-png"),
236 (u"flight mode!, thermal", "fm-thm"),
237 (u"flight mode!, thermal left", "fm-thml"),
238 (u"flight mode!, thermal right", "fm-thmr"),
240 sounds.append((s, filename(f, PROMPT_CUSTOM_BASE+i)))
241 return systemSounds, sounds
243 ################################################################
245 def ttsFr():
246 systemSounds = []
247 sounds = []
249 for i in range(100):
250 systemSounds.append((str(i), filename(PROMPT_SYSTEM_BASE+i)))
251 for i in range(10):
252 systemSounds.append((str(100*(i+1)), filename(PROMPT_SYSTEM_BASE+100+i)))
253 for i, s in enumerate(["une", "onze", "vingt et une", "trente et une", "quarante et une", "cinquante et une", "soixante et une", "soixante et onze", "quatre vingt une"]):
254 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+110+i)))
255 for i, s in enumerate(["virgule", "et", "moins", "minuit", "midi"]):
256 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+119+i)))
257 for i, s in enumerate(["volts", u"ampères", u"milli ampères", u"knots", u"mètres seconde", u"pieds par seconde", u"kilomètre heure", u"miles par heure", u"mètres", "pieds", u"degrés", u"degrés fahrenheit", "pourcents", u"milli ampères / heure", "watt", "db", "tours minute", "g", u"degrés", "millilitres", "onces", "heure", "minute", "seconde"]):
258 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+125+i)))
259 #for i, s in enumerate(["timer", "", "tension", "tension", u"émission", u"réception", "altitude", "moteur",
260 # "essence", u"température", u"température", "vitesse", "distance", "altitude", u"élément lipo",
261 # "total lipo", "tension", "courant", "consommation", "puissance", u"accelération X", u"accelération Y", u"accelération Z",
262 # "orientation", "vario"]):
263 # systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+146+i)))
264 for i, s in enumerate(["virgule 0", "virgule 1", "virgule 2", "virgule 3", "virgule 4", "virgule 5", "virgule 6", "virgule 7", "virgule 8", "virgule 9"]):
265 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+180+i)))
266 for s, f, a in [(u"Batterie radio faible !", "lowbatt", 485),
267 (u"Radio inactive !", "inactiv", 486),
268 (u"Alerte manche des gaz", "thralert", 481),
269 (u"Alerte inters", "swalert", 482),
270 (u"éprome corrompue", "eebad", 483),
271 (u"Bienvenue sur Open TI X!", "tada", 480),
272 (u"vingt secondes", "timer20", 500),
273 (u"trente secondes", "timer30", 501),
274 (u"A1,faible", "a1_org", NO_ALTERNATE),
275 (u"A1,critique", "a1_red", NO_ALTERNATE),
276 (u"A2,faible", "a2_org", NO_ALTERNATE),
277 (u"A2,critique", "a2_red", NO_ALTERNATE),
278 (u"A3,faible", "a3_org", NO_ALTERNATE),
279 (u"A3,critique", "a3_red", NO_ALTERNATE),
280 (u"A4,faible", "a4_org", NO_ALTERNATE),
281 (u"A4,critique", "a4_red", NO_ALTERNATE),
282 (u"Signal RF, faible", "rssi_org", NO_ALTERNATE),
283 (u"Signal RF, critique", "rssi_red", NO_ALTERNATE),
284 (u"Antenne défectueuse", "swr_red", NO_ALTERNATE),
285 (u"Plus de télémétrie", "telemko", NO_ALTERNATE),
286 (u"Télémétrie retrouvée", "telemok", NO_ALTERNATE),
287 (u"Signal écolage perdu", "trainko", NO_ALTERNATE),
288 (u"Signal écolage retrouvé", "trainok", NO_ALTERNATE),
290 systemSounds.append((s, filename(f, a)))
291 for i, (s, f) in enumerate([
292 (u"altitude", "altitude"),
293 (u"température moteur", "moteur"),
294 (u"température contrôleur", "cntrleur"),
295 (u"train rentré", "gearup"),
296 (u"train sorti", "geardn"),
297 (u"volets rentrés", "flapup"),
298 (u"volets sortis", "flapdn"),
299 (u"atterrissage", "attero"),
300 (u"écolage", "trnon"),
301 (u"fin écolage", "trnoff"),
302 (u"moteur coupé", "engoff"),
304 sounds.append((s, filename(f, PROMPT_CUSTOM_BASE+i)))
305 return systemSounds, sounds
307 ################################################################
309 def ttsIt():
310 systemSounds = []
311 sounds = []
313 for i in range(101):
314 systemSounds.append((str(i), filename(PROMPT_SYSTEM_BASE+i)))
315 systemSounds.append(("mila", filename(PROMPT_SYSTEM_BASE+101)))
316 systemSounds.append(("mille", filename(PROMPT_SYSTEM_BASE+102)))
317 for i, s in enumerate(["virgola", "un", "e", "meno", "ora", "ore", "minuto", "minuti", "secondo", "secondi"]):
318 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+103+i)))
319 for i, s in enumerate(["", "",
320 "volt", "volt",
321 "ampere", "ampere",
322 "milliampers", "milliampers",
323 "nodo", "nodi",
324 "metro al secondo", "metri al secondo",
325 "piede al secondo", "piedi al secondo",
326 "chilometro ora", "chilometri ora",
327 "miglio per ora", "miglia per ora",
328 "metro", "metri",
329 "piede", "piedi",
330 "grado celsius", "gradi celsius",
331 "grado fahrenheit", "gradi fahrenheit",
332 "percento", "percento",
333 "milliampere ora", "milliampere ora",
334 "watt", "watt",
335 "decibel", "decibel",
336 "R P M", "R P M",
337 "g", "g",
338 "grado", "gradi",
339 "millilitro", "millilitri",
340 "oncia", "once"]):
341 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+113+i)))
342 for s, f, a in [(u"radio inattiva controllare", "inactiv", 486),
343 (u"batteria della radio scarica", "lowbatt", 485),
344 (u"controllo motore non in posizione, verificare", "thralert", 481),
345 (u"interruttori non in posizione, verificare", "swalert", 482),
346 (u"eeprom corrotta", "eebad", NO_ALTERNATE),
347 (u"formattazone eeprom in corso", "eeformat", NO_ALTERNATE),
348 (u"errore", "error", NO_ALTERNATE),
349 (u"trim centrato", "midtrim", 495),
350 (u"potenziometro centrato", "midpot", 496),
351 (u"massimo trim raggiunto", "endtrim", NO_ALTERNATE),
352 (u"venti secondi", "timer20", 500),
353 (u"trenta secondi", "timer30", 501),
354 (u"assorbimento elevato", "highmah", NO_ALTERNATE),
355 (u"temperatura elevata", "hightemp", NO_ALTERNATE),
356 (u"A1 in allarme", "a1_org", NO_ALTERNATE),
357 (u"A1 critico", "a1_red", NO_ALTERNATE),
358 (u"A2 in allarme", "a2_org", NO_ALTERNATE),
359 (u"A2 critico", "a2_red", NO_ALTERNATE),
360 (u"A3 in allarme", "a3_org", NO_ALTERNATE),
361 (u"A3 critico", "a3_red", NO_ALTERNATE),
362 (u"A4 in allarme", "a4_org", NO_ALTERNATE),
363 (u"A4 critico", "a4_red", NO_ALTERNATE),
364 (u"Segnale radio basso", "rssi_org", NO_ALTERNATE),
365 (u"Segnale radio critico", "rssi_red", NO_ALTERNATE),
366 (u"Problema all'antenna della radio", "swr_red", NO_ALTERNATE),
367 (u"Telemetria assente", "telemko", NO_ALTERNATE),
368 (u"Telemetria disponibile", "telemok", NO_ALTERNATE),
370 systemSounds.append((s, filename(f, a)))
371 for i, s in enumerate([u"timer", u"", u"tensione", u"tensione", u"trasmissione", u"ricezione", u"altitudine", u"motore",
372 u"carburante", u"temperatura", u"temperatura", u"velocità", "distanza", u"altitudine", u"cella lipo",
373 u"totale lipo", u"tensione", u"corrente", u"consumo", u"potenza", u"accellerazione X", u"accellerazione Y", u"accellerazione Z",
374 u"direzione", u"variometro",u"minimo",u"massimo"]):
375 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+135+i)))
376 for i, (s, f) in enumerate([
377 (u"carrello chiuso", "gearup"),
378 (u"carrello aperto", "geardn"),
379 (u"flap rientrati", "flapup"),
380 (u"flap estesi", "flapdn"),
381 (u"atterraggiio", "attero"),
382 (u"modalità maestro attiva", "trnon"),
383 (u"modalità maestro disattiva", "trnoff"),
384 (u"motore spento", "engoff"),
385 (u"troppo alto", "tohigh"),
386 (u"troppo basso", "tolow"),
387 (u"batteria scarica", "lowbat"),
388 (u"crow on", "crowon"),
389 (u"crow off", "crowof"),
390 (u"modo velocità", "spdmod"),
391 (u"modo termica", "thmmod"),
392 (u"modo volo normale", "nrmmod"),
393 (u"fase di volo 1", "fltmd1"),
394 (u"fase di volo 2", "fltmd2"),
395 (u"fase di volo 3", "fltmd3"),
396 (u"fase di volo 4", "fltmd4"),
397 (u"fase di volo 5", "fltmd5"),
398 (u"fase di volo 6", "fltmd6"),
399 (u"fase di volo 7", "fltmd7"),
400 (u"fase di volo 8", "fltmd8"),
401 (u"fase di volo 9", "fltmd9"),
403 sounds.append((s, filename(f, PROMPT_CUSTOM_BASE+i)))
404 return systemSounds, sounds
406 ################################################################
408 def ttsPt():
409 systemSounds = []
410 sounds = []
412 for i in range(101):
413 systemSounds.append((str(i), filename(PROMPT_SYSTEM_BASE+i)))
414 systemSounds.append(("cento", filename(PROMPT_SYSTEM_BASE+101)))
415 systemSounds.append(("duzentos", filename(PROMPT_SYSTEM_BASE+102)))
416 systemSounds.append(("trezentos", filename(PROMPT_SYSTEM_BASE+103)))
417 systemSounds.append(("quatrocentos", filename(PROMPT_SYSTEM_BASE+104)))
418 systemSounds.append(("quinhentos", filename(PROMPT_SYSTEM_BASE+105)))
419 systemSounds.append(("seiscentos", filename(PROMPT_SYSTEM_BASE+106)))
420 systemSounds.append(("setecentos", filename(PROMPT_SYSTEM_BASE+107)))
421 systemSounds.append(("oitocentos", filename(PROMPT_SYSTEM_BASE+108)))
422 systemSounds.append(("novecentos", filename(PROMPT_SYSTEM_BASE+109)))
423 systemSounds.append(("mil", filename(PROMPT_SYSTEM_BASE+110)))
424 for i, s in enumerate(["virgula", "uma", "duas", "e", "menos", "hora", "horas", "minuto", "minutos", "segundo", "segundos"]):
425 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+111+i)))
426 for i, s in enumerate([u"Volt", u"ampére", u"metros por segundo", u"", u"quilômetros por hora", u"metros", u"graus", u"cento", u"miliamperes", u"miliamperes por hora", u"watt", u"db", u"pés", u"nós", u"horas", u"minutos", u"segundos", u"RPM", u"g", u"mililitri", u"onças"]):
427 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+122+i)))
428 for s, f, a in [(u"atenção, o rádio foi esquecido ligado, por favor desligue-o", "inactiv", 486),
429 (u"bateria do rádio fraca", "lowbatt", 485),
430 (u"atenção,acelerador não está no mínimo", "thralert", 481),
431 (u"atenção, certifique-se que os interruptores estão na posição certa", "swalert", 482),
432 (u"eeprom corrompida", "eebad", NO_ALTERNATE),
433 (u"formatação da eeprom em curso", "eeformat", NO_ALTERNATE),
434 (u"erro", "error", NO_ALTERNATE),
435 (u"trim centrado", "midtrim", 495),
436 (u"potenciómetro centrado", "midpot", 496),
437 (u"trim no máximo", "endtrim", NO_ALTERNATE),
438 (u"20 segundos", "timer20", 500),
439 (u"30 segundos", "timer30", 501),
440 (u"assorbimento elevato", "highmah", NO_ALTERNATE),
441 (u"temperatura elevata", "hightemp", NO_ALTERNATE),
442 (u"Alarme A1", "a1_org", NO_ALTERNATE),
443 (u"A1 critica", "a1_red", NO_ALTERNATE),
444 (u"Alarme A2", "a2_org", NO_ALTERNATE),
445 (u"A2 critica", "a2_red", NO_ALTERNATE),
446 (u"recepção de sinal muito baixa", "rssi_org", NO_ALTERNATE),
447 (u"recepção de sinal crítica", "rssi_red", NO_ALTERNATE),
448 (u"Problema com a antena do transmissor", "swr_red", NO_ALTERNATE),
450 systemSounds.append((s, filename(f, a)))
451 for i, s in enumerate([u"cronómetro", u"cronómetro", u"transmissão", u"recepção", u"A1", u"A2", u"altitude", u"motor",
452 u"combustível", u"temperatura", u"temperatura", u"velocidade", u"distância", u"altitude", u"célula lipo",
453 u"Total lipo", u"tensão", u"corrente", u"consumo", u"potência", u"aceleração X", u"aceleração Y", u"aceleração Z",
454 u"Direcção", u"variómetro", u"mínimo", u"máximo"]):
455 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+141+i)))
456 for i, (s, f) in enumerate([
457 (u"trem, em cima.", "gearup"),
458 (u"trem, em baixo.", "geardn"),
459 (u"flaps recolhidos", "flapup"),
460 (u"flaps estendidos", "flapdn"),
461 (u"aterragem", "attero"),
462 (u"modo de treino ligado", "trnon"),
463 (u"modo de treino desligado", "trnoff"),
464 (u"motor desligado", "engoff"),
465 (u"muito alto", "tohigh"),
466 (u"muito baixo", "tolow"),
467 (u"bateria fraca", "lowbat"),
468 (u"crou, activo", "crowon"),
469 (u"crou, desligado", "crowof"),
470 (u"modo de velocidade", "spdmod"),
471 (u"modo de térmica", "thmmod"),
472 (u"modo de voo normal", "nrmmod"),
473 (u"fase de voo 1", "fltmd1"),
474 (u"fase de voo 2", "fltmd2"),
475 (u"fase de voo 3", "fltmd3"),
476 (u"fase de voo 4", "fltmd4"),
477 (u"fase de voo 5", "fltmd5"),
478 (u"fase de vôo 6", "fltmd6"),
479 (u"fase de voo 7", "fltmd7"),
480 (u"fase de voo 8", "fltmd8"),
481 (u"fase de voo 9", "fltmd9"),
483 sounds.append((s, filename(f, PROMPT_CUSTOM_BASE+i)))
484 return systemSounds, sounds
486 ################################################################
488 def ttsEs():
489 systemSounds = []
490 sounds = []
492 for i in range(101):
493 systemSounds.append((str(i), filename(PROMPT_SYSTEM_BASE+i)))
494 systemSounds.append(("ciento", filename(PROMPT_SYSTEM_BASE+101)))
495 systemSounds.append(("doscientos", filename(PROMPT_SYSTEM_BASE+102)))
496 systemSounds.append(("trescientos", filename(PROMPT_SYSTEM_BASE+103)))
497 systemSounds.append(("cuatrocientos", filename(PROMPT_SYSTEM_BASE+104)))
498 systemSounds.append(("quinientos", filename(PROMPT_SYSTEM_BASE+105)))
499 systemSounds.append(("sescientos", filename(PROMPT_SYSTEM_BASE+106)))
500 systemSounds.append(("setecientos", filename(PROMPT_SYSTEM_BASE+107)))
501 systemSounds.append(("ochocientos", filename(PROMPT_SYSTEM_BASE+108)))
502 systemSounds.append(("nuevecientos", filename(PROMPT_SYSTEM_BASE+109)))
503 systemSounds.append(("mil", filename(PROMPT_SYSTEM_BASE+110)))
504 for i, s in enumerate(["coma", "un", "una", "y", "meno", "hora", "horas", "minuto", "minutos", "segundo", "segundos"]):
505 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+111+i)))
506 for i, s in enumerate([u"Voltio", u"ampério", u"metros por segundo", u"", u"kilómetro por hora", u"metros", u"grados", u"por ciento", u"miliamperios", u"miliamperios por hora", u"vatio", u"db", u"pés", u"nós", u"horas", u"minutos", u"segundos", u"RPM", u"g", u"mililitro", u"onzas"]):
507 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+122+i)))
508 for s, f, a in [(u"me tienes abandonada", "inactiv", 486),
509 (u"batería del transmisor baja", "lowbatt", 485),
510 (u"El acelerador está activado, por favor, corrijalo", "thralert", 481),
511 (u"Los interruptores no están en la posición correcta, por favor corrijalo", "swalert", 482),
512 (u"eeprom corrompida", "eebad", NO_ALTERNATE),
513 (u"Formateo de eeprom en curso", "eeformat", NO_ALTERNATE),
514 (u"error", "error", NO_ALTERNATE),
515 (u"trim centrado", "midtrim", 495),
516 (u"potenciómetro centrado", "midpot", 496),
517 (u"trim al máximo", "endtrim", NO_ALTERNATE),
518 (u"20 segundos", "timer20", 500),
519 (u"30 segundos", "timer30", 501),
520 (u"assorbimiento elevado", "highmah", NO_ALTERNATE),
521 (u"temperatura elevada", "hightemp", NO_ALTERNATE),
522 (u"Alarma A1", "a1_org", NO_ALTERNATE),
523 (u"A1 crítica", "a1_red", NO_ALTERNATE),
524 (u"Alarma A2", "a2_org", NO_ALTERNATE),
525 (u"A2 crítica", "a2_red", NO_ALTERNATE),
526 (u"recepcion de señal baja", "rssi_org", NO_ALTERNATE),
527 (u"recepción de señal crítica", "rssi_red", NO_ALTERNATE),
528 (u"Problemas con la antena del transmisor", "swr_red", NO_ALTERNATE),
529 (u"Sin telemetría", "telemko", NO_ALTERNATE),
530 (u"Telemetría disponible", "telemok", NO_ALTERNATE),
532 systemSounds.append((s, filename(f, a)))
533 for i, s in enumerate([u"cronómetro", u"cronómetro", u"transmisión", u"recepción", u"A1", u"A2", u"altitud", u"motor",
534 u"combustible", u"temperatura", u"temperatura", u"velocidad", u"distancia", u"altitude", u"célula lipo",
535 u"Total lipo", u"voltaje", u"corriente", u"consumo", u"potencia", u"aceleración X", u"aceleración Y", u"aceleración Z",
536 u"dirección", u"variómetro", u"minimo", u"máximo"]):
537 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+141+i)))
538 for i, (s, f) in enumerate([
539 (u"tren arriba.", "gearup"),
540 (u"tren abajo.", "geardn"),
541 (u"flaps arriba", "flapup"),
542 (u"flaps abajo", "flapdn"),
543 (u"aterrizaje", "attero"),
544 (u"modo de entrenamiento activado", "trnon"),
545 (u"modo de entrenamiento deshabilitado", "trnoff"),
546 (u"motor apagado", "engoff"),
547 (u"muy alto", "tohigh"),
548 (u"muy bajo", "tolow"),
549 (u"bateria baja", "lowbat"),
550 (u"crou, activo", "crowon"),
551 (u"crou, desligado", "crowof"),
552 (u"modo de velocidad", "spdmod"),
553 (u"modo de térmica", "thmmod"),
554 (u"modo de vuelo normal", "nrmmod"),
555 (u"fase de vuelo 1", "fltmd1"),
556 (u"fase de vuelo 2", "fltmd2"),
557 (u"fase de vuelo 3", "fltmd3"),
558 (u"fase de vuelo 4", "fltmd4"),
559 (u"fase de vuelo 5", "fltmd5"),
560 (u"fase de vuelo 6", "fltmd6"),
561 (u"fase de vuelo 7", "fltmd7"),
562 (u"fase de vuelo 8", "fltmd8"),
563 (u"fase de vuelo 9", "fltmd9"),
565 sounds.append((s, filename(f, PROMPT_CUSTOM_BASE+i)))
566 return systemSounds, sounds
568 ################################################################
570 def ttsDe():
571 systemSounds = []
572 sounds = []
574 for i in range(101):
575 systemSounds.append((str(i), filename(PROMPT_SYSTEM_BASE+i)))
576 systemSounds.append(("tausend", filename(PROMPT_SYSTEM_BASE+101)))
577 for i, s in enumerate(["comma", "und", "minus", "uhr", "minute", "minuten", "sekunde", "sekunden"]):
578 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+102+i)))
579 for i, s in enumerate(["", "Volt", "Ampere", "MilliAmpere", "Knoten", "Meter pro sekunde", "Fuesse pro sekunde", "kilometer pro stunde", "Meilen pro Stunde", "Meter", "Fuesse", "Grad", "Grad Fahrenheit", "Prozent", "Milliampere pro stunde", "Watt", "db", "R P M", "g", "Milliliter", "Unze", "Uhr", "Minuten", "Secunden",]):
580 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+110+i)))
581 for s, f, a in [(u"Sender ist inaktiv,bitte Ueberpruefen Sie", "inactiv", 486),
582 (u"Senderakku niedrig", "lowbatt", 485),
583 (u"Gaskanal nicht Null, bitte pruefen", "thralert", 481),
584 (u"Schalten fehlpositioniert, bitte pruefen", "swalert", 482),
585 (u"Das EEPROM ist fehlerhaft", "eebad", NO_ALTERNATE),
586 (u"Das EEPROM ist immer formatiert", "eeformat", NO_ALTERNATE),
587 (u"fehler", "error", NO_ALTERNATE),
588 (u"Trim zentriert", "midtrim", 495),
589 (u"Poti zentriert", "midpot", 496),
590 (u"Maximale trimmung erreicht", "endtrim", NO_ALTERNATE),
591 (u"20 sekunden", "timer20", 500),
592 (u"30 sekunden", "timer30", 501),
593 (u"Senderstrom ist zu hoch!", "highmah", NO_ALTERNATE),
594 (u"Sendertemperatur ist zu hoch!", "hightemp", NO_ALTERNATE),
595 (u"A1 schlecht!", "a1_org", NO_ALTERNATE),
596 (u"A1 kritisch!", "a1_red", NO_ALTERNATE),
597 (u"A2 schlecht!", "a2_org", NO_ALTERNATE),
598 (u"A2 kritisch!", "a2_red", NO_ALTERNATE),
599 (u"A3 schlecht!", "a3_org", NO_ALTERNATE),
600 (u"A3 kritisch!", "a3_red", NO_ALTERNATE),
601 (u"A4 schlecht!", "a4_org", NO_ALTERNATE),
602 (u"A4 kritisch!", "a4_red", NO_ALTERNATE),
603 (u"Funksignal schlecht!", "rssi_org", NO_ALTERNATE),
604 (u"Funksignal kritisch!", "rssi_red", NO_ALTERNATE),
605 (u"Problem mit der sender Antenna", "swr_red", NO_ALTERNATE),
606 (u"Telemetrie verloren", "telemko", NO_ALTERNATE),
607 (u"Telemetrie wiederhergestellt", "telemok", NO_ALTERNATE),
608 (u"Schülersignal verloren", "trainko", NO_ALTERNATE),
609 (u"Schülersignal wiederhergestellt", "trainok", NO_ALTERNATE),
611 systemSounds.append((s, filename(f, a)))
612 for i, s in enumerate(["Timer", "Timer", "Sendung", "Empfang", "A1", "A2", "Hoehe", "Motor",
613 "Treibstoff", "Temperatur", "Temperatur", "Geschwindigkeit", "Ferne", "Hoehe", "Lipo-Zelle",
614 "Zellen gesamt", "Spannung", "Strom", "Verbrauch", "Power", "Beschleunigung X", "Beschleunigung Y", "Beschleunigung Z",
615 "Richtung", "Variometer","Minimum","Maximum"]):
616 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+134+i)))
617 for i, (s, f) in enumerate([
618 (u"Fahrwerk eingezogen", "gearup"),
619 (u"Fahrwerk ausgefahren", "geardn"),
620 (u"Klappen eingefahren", "flapup"),
621 (u"Klappen ausgefahren", "flapdn"),
622 (u"Landung", "attero"),
623 (u"Trainer-Modus ein", "trnon"),
624 (u"Trainer-Modus aus", "trnoff"),
625 (u"Motor aus", "engoff"),
626 (u"zu hoch", "tohigh"),
627 (u"zu niedrig", "tolow"),
628 (u"Batterie schwach", "lowbat"),
629 (u"crow ein", "crowon"),
630 (u"crow aus", "crowof"),
631 (u"Schnell-Modus ist aktiviert", "spdmod"),
632 (u"Thermik-Modus ist aktiviert", "thmmod"),
633 (u"Normal-Modus ist aktiviert", "nrmmod"),
634 (u"Regime 1", "fltmd1"),
635 (u"Regime 2", "fltmd2"),
636 (u"Regime 3", "fltmd3"),
637 (u"Regime 4", "fltmd4"),
638 (u"Regime 5", "fltmd5"),
639 (u"Regime 6", "fltmd6"),
640 (u"Regime 7", "fltmd7"),
641 (u"Regime 8", "fltmd8"),
642 (u"Regime 9", "fltmd9"),
644 sounds.append((s, filename(f, PROMPT_CUSTOM_BASE+i)))
645 return systemSounds, sounds
647 ################################################################
649 def ttsCz():
650 systemSounds = []
651 sounds = []
653 for i, s in enumerate(["nula", "jedna", "dva"]):
654 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+i)))
655 for i in range(97):
656 systemSounds.append((str(3+i), filename(PROMPT_SYSTEM_BASE+3+i)))
657 for i, s in enumerate(["sto", u"dvěsta", u"třista", u"čtyřista", u"pětset", u"šestset", "sedmset", "osmset",
658 u"devětset", u"tisíc"]):
659 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+100+i)))
660 for i, s in enumerate([u"tisíce", "jeden", "jedno", u"dvě", u"celá", u"celé", u"celých", u"mínus"]):
661 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+110+i)))
663 for i, s in enumerate(["volt", "volty", u"voltů", "voltu",
664 u"ampér", u"ampéry", u"ampérů", u"ampéru",
665 "metr za sekundu", "metry za sekundu", u"metrů za sekundu", "metru za sekundu",
666 "jednotka", "jednotky", "jednotek", "jednotky",
667 "kilometr za hodinu", "kilometry za hodinu", u"kilometrů za hodinu", "kilometru za hodinu",
668 "metr", "metry", u"metrů", "metru",
669 u"stupeň", u"stupně", u"stupňů", u"stupně",
670 "procento", "procenta", "procento", "procenta",
671 u"miliampér", u"miliampéry", u"miliampérů", u"miliampéru",
672 u"miliampérhodina", u"miliampérhodiny", u"miliampérhodin", u"miliampérhodiny",
673 "vat", "vaty", u"vatů", "vatu",
674 "decibel", "decibely", u"decibelů", "decibelu",
675 "stopa", "stopy", "stop", "stopy",
676 u"míle za hodinu", u"míle za hodinu", u"mil za hodinu", "míle za hodinu",
677 "hodina", "hodiny", "hodin", "hodiny",
678 "minuta", "minuty", "minut", "minuty",
679 "sekunda", "sekundy", "sekund", "sekundy",
680 u"otáčka za minutu", u"otáčky za minutu", u"otáček za minutu", u"otáčky za minutu",
681 u"gé", u"gé", u"gé", u"gé"]):
682 systemSounds.append((s, filename(PROMPT_SYSTEM_BASE+118+i)))
684 for s, f, a in [(u"střed trimu", "midtrim", 495),
685 (u"maximum trimu", "endtrim", NO_ALTERNATE),
686 (u"baterie rádia je vybitá", "lowbatt", 485),
687 (u"zapoměl jsi na mě!", "inactiv", 486),
688 (u"plyn není na nule", "thralert", 481),
689 (u"přepínače nejsou ve výchozí poloze", "swalert", 482),
690 (u"neplatná eeprom", "eebad", 483),
691 (u"Oupn najn iks", "tada", 480),
692 (u"dvacet sekund", "timer20", 500),
693 (u"třicet sekund", "timer30", 501),
694 (u"A1,nízká", "a1_org", NO_ALTERNATE),
695 (u"A1,kritická", "a1_red", NO_ALTERNATE),
696 (u"A2,nízká", "a2_org", NO_ALTERNATE),
697 (u"A2,kritická", "a2_red", NO_ALTERNATE),
698 (u"A3,nízká", "a3_org", NO_ALTERNATE),
699 (u"A3,kritická", "a3_red", NO_ALTERNATE),
700 (u"A4,nízká", "a4_org", NO_ALTERNATE),
701 (u"A4,kritická", "a4_red", NO_ALTERNATE),
702 (u"nízký RF signál", "rssi_org", NO_ALTERNATE),
703 (u"kritický RF signál", "rssi_red", NO_ALTERNATE),
704 (u"problém s anténou rádia", "swr_red", NO_ALTERNATE),
705 (u"telemetrie ztracena", "telemko", NO_ALTERNATE),
706 (u"telemetrie je funkční", "telemok", NO_ALTERNATE),
708 systemSounds.append((s, filename(f, a)))
709 for i, (s, f) in enumerate([
710 (u"podvozek je zasunut", "podvoz0"),
711 (u"podvozek je vysunut", "podvoz1"),
712 (u"klapky jsou zapnuty", "klapky1"),
713 (u"klapky jsou vypnuty", "klapky0"),
714 (u"trenér je zapnut", "trener1"),
715 (u"trenér je vypnutý", "trener0"),
716 (u"motor je vypnut", "motor0"),
717 (u"motor je aktivován", "motor1"),
718 (u"jsi příliš vysoko", "vysoko"),
719 (u"jsi příliš nízko", "nizko"),
720 (u"baterie modelu je vybitá", "batvybit"),
721 (u"dochází palivo", "palivo"),
722 (u"nízký signál!", "nsignal"),
723 (u"kritický signál!", "ksignal"),
724 (u"rychlý režim aktivován", "r_rychly"),
725 (u"termický režim aktivován", "r_termik"),
726 (u"normální režim aktivován", "r_norm"),
727 (u"režim start aktivován", "r_start"),
728 (u"režim přistání aktivován", "r_prista"),
729 (u"vario je zapnuto", "vario0"),
730 (u"vario je vypnuto", "vario1"),
731 (u"start povolen", "startok"),
733 sounds.append((s, filename(f, PROMPT_CUSTOM_BASE+i)))
734 return systemSounds, sounds
736 ################################################################
738 if __name__ == "__main__":
740 if "sky9x" in sys.argv:
741 board = "sky9x"
742 PROMPT_CUSTOM_BASE = 256
743 PROMPT_SYSTEM_BASE = 0
744 elif "taranis" in sys.argv:
745 board = "taranis"
746 PROMPT_CUSTOM_BASE = 256
747 PROMPT_SYSTEM_BASE = 0
748 elif "gruvin9x" in sys.argv:
749 board = "gruvin9x"
750 PROMPT_CUSTOM_BASE = 0
751 PROMPT_SYSTEM_BASE = 256
752 else:
753 board = "stock"
754 PROMPT_CUSTOM_BASE = 0
755 PROMPT_SYSTEM_BASE = 256
757 if "sapi" in sys.argv:
758 import pyTTS
759 tts = pyTTS.Create()
760 # tts.SetOutputFormat(16, 16, 1)
761 # tts.Volume = 40
762 # tts.SetRate(1)
763 if "list" in sys.argv:
764 print tts.GetVoiceNames()
765 exit()
767 if "mulaw" in sys.argv:
768 defaultcodec = "pcm_mulaw"
769 else:
770 defaultcodec = "pcm_alaw"
772 if "en" in sys.argv:
773 directory = "en"
774 voice = "english"
775 if "sapi" in sys.argv:
776 if "scottish" in sys.argv:
777 tts.SetVoiceByName("ScanSoftFiona_Full_22kHz")
778 voice = "english-scottish"
779 elif "american" in sys.argv:
780 tts.SetVoiceByName("ScanSoftJennifer_Full_22kHz")
781 voice = "english-american"
782 elif "australian" in sys.argv:
783 tts.SetVoiceByName("ScanSoftKaren_Full_22kHz")
784 voice = "english-australian"
785 elif "irish" in sys.argv:
786 tts.SetVoiceByName("ScanSoftMoira_Full_22kHz")
787 voice = "english-irish"
788 else:
789 tts.SetVoiceByName("ScanSoftFiona_Full_22kHz")
790 voice = "english-english"
791 elif "sapi2" in sys.argv:
792 if "scottish" in sys.argv:
793 voiceID = "17"
794 voice = "english-scottish"
795 elif "american" in sys.argv:
796 voiceID = "18"
797 voice = "english-american"
798 elif "australian" in sys.argv:
799 voiceID = "20"
800 voice = "english-australian"
801 elif "irish" in sys.argv:
802 voiceID = "21"
803 voice = "english-irish"
804 elif "french" in sys.argv:
805 voiceID = "19"
806 voice = "english-french"
807 elif "german" in sys.argv:
808 voiceID = "22"
809 voice = "english-german"
810 else:
811 voiceID = "17"
812 voice = "english-english"
814 elif "espeak" in sys.argv:
815 espeakVoice = "mb-us1"
816 espeakspeed = "150"
817 systemSounds, sounds = ttsEn()
819 elif "fr" in sys.argv:
820 directory = "fr"
821 voice = "french"
822 if "sapi" in sys.argv:
823 tts.SetVoiceByName("ScanSoftVirginie_Full_22kHz")
824 elif "espeak" in sys.argv:
825 espeakVoice = "mb-fr4+f4"
826 espeakspeed = "140"
827 systemSounds, sounds = ttsFr()
829 elif "it" in sys.argv:
830 directory = "it"
831 voice = "italian"
832 if "sapi" in sys.argv:
833 tts.SetVoiceByName("ScanSoftVirginie_Full_22kHz")
834 elif "espeak" in sys.argv:
835 espeakVoice = "mb-it4"
836 espeakspeed = "160"
837 systemSounds, sounds = ttsIt()
839 elif "de" in sys.argv:
840 directory = "de"
841 voice = "german"
842 if "sapi" in sys.argv:
843 tts.SetVoiceByName("ScanSoftVirginie_Full_22kHz")
844 elif "espeak" in sys.argv:
845 espeakVoice = "mb-de4"
846 espeakspeed = "160"
847 systemSounds, sounds = ttsDe()
849 elif "pt" in sys.argv:
850 directory = "pt"
851 voice = "portuguese"
852 if "sapi" in sys.argv:
853 tts.SetVoiceByName("ScanSoftVirginie_Full_22kHz")
854 elif "espeak" in sys.argv:
855 espeakVoice = "mb-pt1+f1"
856 espeakspeed = "160"
857 systemSounds, sounds = ttsPt()
859 elif "es" in sys.argv:
860 directory = "es"
861 voice = "spanish"
862 if "sapi" in sys.argv:
863 tts.SetVoiceByName("ScanSoftVirginie_Full_22kHz")
864 elif "espeak" in sys.argv:
865 espeakVoice = "mb-es1+f1"
866 espeakspeed = "160"
867 systemSounds, sounds = ttsEs()
869 elif "cz" in sys.argv:
870 directory = "cz"
871 voice = "czech"
872 if "sapi" in sys.argv:
873 tts.SetVoiceByName("ScanSoftZuzana_Full_22kHz")
874 elif "espeak" in sys.argv:
875 espeakVoice = "mb-cz2"
876 espeakspeed = "150"
877 systemSounds, sounds = ttsCz()
879 else:
880 print "which language?"
881 exit()
883 if "csv" in sys.argv:
884 csvFile = open("%s-%s.csv" % (voice, board), "w")
885 for s, f in systemSounds:
886 if s and f:
887 l = u""
888 if board in ("sky9x", "taranis"):
889 l += u"SOUNDS/%s/SYSTEM;" % directory
890 l += f + u";" + s + u"\n"
891 csvFile.write(l.encode("utf-8"))
892 for s, f in sounds:
893 if s and f:
894 l = u""
895 if board in ("sky9x", "taranis"):
896 l += u"SOUNDS/%s;" % directory
897 l += f + u";" + s + u"\n"
898 csvFile.write(l.encode("utf-8"))
899 csvFile.close()
901 if "zip" in sys.argv:
902 zip_name = "%s-%s.zip" % (voice, board)
903 zip = zipfile.ZipFile(zip_name, "w", zipfile.ZIP_DEFLATED)
904 for s, f in systemSounds:
905 if s and f:
906 generate(s, f)
907 if board in ("sky9x", "taranis"):
908 zip.write(f, "SOUNDS/%s/SYSTEM/" % directory + f)
909 else:
910 zip.write(f, f)
911 os.remove(f)
912 for s, f in sounds:
913 if s and f:
914 generate(s, f)
915 if board in ("sky9x", "taranis"):
916 zip.write(f, "SOUNDS/%s/" % directory + f)
917 else:
918 zip.write(f, f)
919 os.remove(f)
920 zip.close()