2 # -*- coding: utf-8 -*-
5 # This script is a modified version to support Linux TTS fiel genration using PicoTTS
7 # Sound pack maintainers (incomplete list) by language alphabetical order
9 # French : Bertrand Songis & André Bernet
10 # English : Rob Thompson & Martin Hotar
11 # German : Romolo Manfredini (Some corrections by Peer)
12 # Italian : Romolo Manfredini
13 # Portuguese : Romolo Manfredini
14 # Spanish : Romolo Manfredini (With the help of Jose Moreno)
16 # from __future__ import print_function
23 from tts_common
import *
27 sys
.setdefaultencoding('utf8')
29 SOURCE_DIRECTORY
= os
.path
.dirname(os
.path
.realpath(__file__
))
30 lib_path
= os
.path
.abspath(os
.path
.join(SOURCE_DIRECTORY
, '..', '..', 'radio', 'util'))
31 sys
.path
.append(lib_path
)
33 def generate(str, filename
):
36 command
= 'pico2wave -l=%s -w=%s "%s"' % (voice
, output
, str)
37 os
.system(command
.encode('utf-8'))
38 command
= "sox %s -r 32000 %s reverse silence 1 0.1 0.1%% reverse" % (output
, filename
)
39 os
.system(command
.encode('utf-8'))
41 output
= u
"output.mp3"
42 tts
= gTTS(text
=str, lang
=voice
[:2])
44 command
= "sox %s -r 32000 %s tempo 1.2 norm" % (output
, filename
)
45 os
.system(command
.encode('utf-8'))
46 command
= "rm -f output.mp3"
47 os
.system(command
.encode('utf-8'))
49 ################################################################
51 if __name__
== "__main__":
53 from tts_en
import systemSounds
, sounds
58 elif "fr" in sys
.argv
:
59 from tts_fr
import systemSounds
, sounds
64 elif "it" in sys
.argv
:
65 from tts_it
import systemSounds
, sounds
70 elif "de" in sys
.argv
:
71 from tts_de
import systemSounds
, sounds
76 elif "es" in sys
.argv
:
77 from tts_es
import systemSounds
, sounds
82 elif "cz" in sys
.argv
:
83 from tts_cz
import systemSounds
, sounds
88 elif "ru" in sys
.argv
:
89 from tts_ru
import systemSounds
, sounds
94 elif "pt" in sys
.argv
:
95 from tts_pt
import systemSounds
, sounds
101 print("which language?")
104 if "csv" in sys
.argv
:
105 path
= "/tmp/SOUNDS/" + directory
+ "/SYSTEM/"
106 if not os
.path
.exists(path
):
109 with
open("%s-%s.csv" % (voice
, board
), "wb") as csvFile
:
110 for s
, f
in systemSounds
:
113 if board
in ("sky9x", "taranis"):
114 l
+= u
"SOUNDS/%s/SYSTEM;" % directory
115 l
+= f
+ u
";" + s
+ u
"\n"
116 csvFile
.write(l
.encode("utf-8"))
120 if board
in ("sky9x", "taranis"):
121 l
+= u
"SOUNDS/%s;" % directory
122 l
+= f
+ u
";" + s
+ u
"\n"
123 csvFile
.write(l
.encode("utf-8"))
125 if "psv" in sys
.argv
:
126 path
= "/tmp/SOUNDS/" + directory
+ "/"
127 if not os
.path
.exists(path
):
130 with
open("%s-%s.psv" % (voice
, board
), "wb") as csvFile
:
131 for s
, f
in systemSounds
:
133 l
= u
"SYSTEM|" + f
.replace(".wav", "") + u
"|" + s
+ u
"\r\n"
134 csvFile
.write(l
.encode("windows-1251"))
137 l
= u
"|" + f
.replace(".wav", "") + u
"|" + s
+ u
"\r\n"
138 csvFile
.write(l
.encode("windows-1251"))
141 if "files" in sys
.argv
:
142 path
= "/tmp/SOUNDS/" + directory
+ "/SYSTEM/"
143 if not os
.path
.exists(path
):
146 for s
, f
in systemSounds
: