63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
list prompt example
|
|
"""
|
|
from __future__ import print_function, unicode_literals
|
|
|
|
from pprint import pprint
|
|
|
|
from PyInquirer import prompt, Separator
|
|
from examples import custom_style_2
|
|
|
|
|
|
import os
|
|
from text_to_speech import text_to_speech, resample
|
|
from translator import llm_translator
|
|
from encode import encode_lc3
|
|
|
|
ANNOUNCEMENT_DIR = os.path.join(os.path.dirname(__file__), 'announcements')
|
|
os.makedirs(ANNOUNCEMENT_DIR, exist_ok=True)
|
|
|
|
def synthesize_resample_encode(text, tts_model, output_file):
|
|
text_to_speech.synthesize(text, tts_model, output_file)
|
|
resample.resample(output_file, output_file)
|
|
encode_lc3.encode_lc3(output_file)
|
|
|
|
|
|
def announcement_from_german_text(text_de):
|
|
synthesize_resample_encode(text_de, 'de_DE-kerstin-low', f'{ANNOUNCEMENT_DIR}/announcement_de.wav')
|
|
|
|
text_en = llm_translator.translator_de_en(text_de)
|
|
synthesize_resample_encode(text_en, 'en_US-lessac-medium', f'{ANNOUNCEMENT_DIR}/announcement_en.wav')
|
|
|
|
text_fr = llm_translator.translator_de_fr(text_de)
|
|
synthesize_resample_encode(text_fr, 'fr_FR-siwis-medium', f'{ANNOUNCEMENT_DIR}/announcement_fr.wav')
|
|
|
|
text_fr = llm_translator.translator_de_es(text_de)
|
|
synthesize_resample_encode(text_fr, 'es_ES-sharvard-medium', f'{ANNOUNCEMENT_DIR}/announcement_fr.wav')
|
|
|
|
# questions = [
|
|
# {
|
|
# 'type': 'list',
|
|
# 'name': 'theme',
|
|
# 'message': 'What type of annoucement would you like to make?',
|
|
# 'choices': [
|
|
# 'predefined',
|
|
# 'custom',
|
|
# 'audio'
|
|
# ]
|
|
# },
|
|
# ]
|
|
|
|
# answers = prompt(questions, style=custom_style_2)
|
|
# pprint(answers)
|
|
|
|
if __name__ == '__main__':
|
|
import time
|
|
from test_content import test_content
|
|
import logging as log
|
|
log.basicConfig(level=log.INFO)
|
|
|
|
start= time.time()
|
|
announcement_from_german_text(test_content.TESTSENTENCE_DE_RAINBOW)
|
|
print("Generating the announcement took", time.time() - start) |