From 37155363ffc3613b742153dff78e36d75fc45443 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 26 Apr 2017 12:33:12 +0200 Subject: [PATCH] [TTS] gTTS method added --- tools/nightly22/tts.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/nightly22/tts.py b/tools/nightly22/tts.py index 03780db49..aba07a4ac 100755 --- a/tools/nightly22/tts.py +++ b/tools/nightly22/tts.py @@ -22,21 +22,24 @@ import zipfile from tts_common import * board = "taranis" -lib_path = os.path.abspath(os.path.join('code', 'radio', 'util')) +SOURCE_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) +lib_path = os.path.abspath(os.path.join(SOURCE_DIRECTORY, '..', '..', 'radio', 'util')) sys.path.append(lib_path) def generate(str, filename): - - command = "pico2wave -l=" + voice + " -w=output.wav \"" + str + "\"" + if 1: + output = "output.wav" + command = 'pico2wave -l=%s -w=%s ""' % (voice, output, str) + else: + output = "output.mp3" + command = 'gtts-cli -l %s -o %s "%s"' % (voice[:2], output, str) os.system(command.encode('utf-8')) - command = "sox output.wav " + filename + " reverse silence 1 0.1 0.1% reverse" + command = "sox %s %s reverse silence 1 0.1 0.1% reverse" % (output, filename) os.system(command.encode('utf-8')) ################################################################ if __name__ == "__main__": - - if "en" in sys.argv: from tts_en import systemSounds, sounds