diff --git a/.gitignore b/.gitignore index 57deddf..8b44455 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ venv __pycache__ *secret* sounds -lessons \ No newline at end of file +lessons +images +videos +sound_cache.csv \ No newline at end of file diff --git a/INSTALL.sh b/INSTALL.sh index 69a66f8..f47789d 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -1,4 +1,6 @@ #!/bin/bash +sudo apt install especk ffmpeg + virtualenv -p python3 venv source venv/bin/activate pip install -r requirements.txt diff --git a/README.md b/README.md index 5d7377e..852bc88 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # en_de -Generate audio from a dictionary. +Generate audio/video from a dictionary. + +Uses espeak for audio generation, Pillow for images with text overlay, OpenCV for video combining, ffmpeg for combining. ## install @@ -10,6 +12,14 @@ Generate audio from a dictionary. # run +Change the lesson + +``` +python generate.py +``` + +# old run + You first need a service account secret from [Google Cloud Text-To-Speech API](https://cloud.google.com/text-to-speech/docs/quickstart-client-libraries#client-libraries-install-python) (go through the steps of `Before you begin` section, the rest is handled by the app). Modify what you need from the `generate.py` file: diff --git a/generate.py b/generate.py index 2a44525..d1f31b8 100644 --- a/generate.py +++ b/generate.py @@ -1,16 +1,26 @@ +import sys + +import cv2 +from PIL import ImageFont, Image, ImageDraw import csv import os from shutil import copyfile from time import sleep, time -import tts from pydub import AudioSegment SHORT_SILENCE = 500 LONG_SILENCE = 1000 +SOUNDS_DIR = "sounds" +IMAGES_DIR = "images" +AUDIO_LESSONS_DIR = "lessons" +VIDEOS_DIR = "videos" SOUND_CACHE_FPATH = 'sound_cache.csv' WORDS_FPATH = 'words.csv' +for d in [SOUNDS_DIR, IMAGES_DIR, AUDIO_LESSONS_DIR, VIDEOS_DIR]: + os.makedirs(d, exist_ok=True) + EXPONENTIAL_BACKOFF = 1.5 LANG_REGIONS = { 'en': 'en-US', @@ -21,7 +31,7 @@ SOUND_CACHE = {} def load_sound_cache(): - with open(SOUND_CACHE_FPATH, 'r') as csvFile: + with open(SOUND_CACHE_FPATH, 'w+') as csvFile: reader = csv.reader(csvFile) for line, row in enumerate(reader): wordid, lang, word = row[0], row[1], row[2] @@ -33,6 +43,15 @@ def get_cached_sound(word, lang): return wordid +def gen_speech(phrase, lang, filepath): + wav_fpath = filepath.split('.')[0] + '.wav' + # +f1 -k1 -s100 + cmd = 'espeak -v{lang} "{phrase}" --stdout > {wav_fpath} && ffmpeg -y -i {wav_fpath} {filepath} && rm {wav_fpath}' + cmd = cmd.format(lang=lang, phrase=phrase, filepath=filepath, wav_fpath=wav_fpath) + print(cmd) + os.system(cmd) + + def generate_sound(word, lang, wordid): lang_region = LANG_REGIONS.get(lang) cached_wordid = get_cached_sound(word, lang) @@ -40,14 +59,14 @@ def generate_sound(word, lang, wordid): print(" Found in cache: {}".format(word)) if cached_wordid != wordid: # TODO: this is duplicating space, but my brain is fried, should be mapping - cached_filepath = os.path.join("sounds", "{}_{}.mp3".format(cached_wordid, lang)) - word_filepath = os.path.join("sounds", "{}_{}.mp3".format(wordid, lang)) + cached_filepath = os.path.join(SOUNDS_DIR, "{}_{}.mp3".format(cached_wordid, lang)) + word_filepath = os.path.join(SOUNDS_DIR, "{}_{}.mp3".format(wordid, lang)) copyfile(cached_filepath, word_filepath) else: filename = "{}_{}.mp3".format(wordid, lang) - filepath = os.path.join("sounds", filename) + filepath = os.path.join(SOUNDS_DIR, filename) start = time() - tts.gen_speech(word, lang_region, filepath) + gen_speech(word, lang_region, filepath) duration = time() - start print(" Generated ({} - {} s): {}".format(lang, duration, word)) SOUND_CACHE[(word, lang)] = wordid @@ -66,7 +85,9 @@ def gen_tts(wordids=None): wordid, german, english = row[0], row[1], row[2] if wordid not in wordids: continue - print("Generating {}: {}, {}".format(wordid, german, english)) + print("Generating image..") + image_gen(wordid, german, english) + print("Generating sound {}: {}, {}".format(wordid, german, english)) backoff, attempt = 1, 0 while True: try: @@ -102,18 +123,87 @@ def concatenate(filename="lesson1", wordids=None): silence = AudioSegment.silent(duration=SHORT_SILENCE) long_silence = AudioSegment.silent(duration=LONG_SILENCE) gen_tts(wordids=wordids) + images_durations = [] for wordid in wordids: start = time() sound_de = AudioSegment.from_mp3("sounds/{}_de.mp3".format(wordid)) sound_en = AudioSegment.from_mp3("sounds/{}_en.mp3".format(wordid)) - lessons = lessons + sound_de + silence + sound_en + silence + sound_de + long_silence + this_phrase = sound_de + silence + sound_en + silence + sound_de + long_silence + images_durations.append((wordid, this_phrase.duration_seconds)) + lessons = lessons + this_phrase duration = time() - start print("Concatenated {} - {}s".format(wordid, duration)) - lessons.export(os.path.join("lessons", "{}.mp3".format(filename)), format="mp3") + lessons.export(os.path.join(AUDIO_LESSONS_DIR, "{}.mp3".format(filename)), format="mp3") + create_video(filename, images_durations) + + +def image_gen(wordid, de_text, en_text): + width, height = 800, 450 + margin, initial_font_size, font_step = 50, 120, 4 + filename = os.path.join(IMAGES_DIR, "{}.png".format(wordid)) + image = Image.new(mode="RGB", size=(width, height), color="black") + draw = ImageDraw.Draw(image) + font_size = initial_font_size + while True: + fnt = ImageFont.truetype('arial.ttf', font_size) + de_w, de_h = draw.textsize(de_text, font=fnt) + en_w, en_h = draw.textsize(en_text, font=fnt) + if de_w + 2 * margin > width or en_w + 2 * margin > width: + font_size -= font_step + continue + break + draw.text(((width - de_w) / 2, height / 2 - margin - de_h), de_text, font=fnt, fill=(255, 255, 255)) + draw.text(((width - en_w) / 2, height / 2 + margin), en_text, font=fnt, fill=(255, 255, 255)) + draw.line((0, height / 2, width, height / 2), fill=(255, 0, 0), width=2) + image.save(filename) + + +def create_video(lesson_name, images_durations): + tmp_video_name = '{}_tmp.mp4'.format(lesson_name) + tmp_video_filepath = os.path.join(VIDEOS_DIR, tmp_video_name) + + fourcc = cv2.VideoWriter_fourcc(*'MP4V') # define the video codec + + frame = cv2.imread(os.path.join(IMAGES_DIR, "{}.png".format(images_durations[0][0]))) + height, width, layers = frame.shape + + frames = 24 + + video = cv2.VideoWriter(tmp_video_filepath, fourcc, frames, (width, height)) + for image, image_duration in images_durations: + image_frames = int(image_duration * frames) + for _ in range(image_frames): + video.write(cv2.imread(os.path.join(IMAGES_DIR, "{}.png".format(image)))) + + cv2.destroyAllWindows() + video.release() + + os.system("ffmpeg -y -i {video_name} -i {audio_name} -c:v copy -c:a copy {video_output}".format( + video_name=tmp_video_filepath, + audio_name=os.path.join(AUDIO_LESSONS_DIR, "{}.mp3".format(lesson_name)), + video_output=os.path.join(VIDEOS_DIR, "{}.mp4".format(lesson_name)), + )) + os.remove(tmp_video_filepath) + + +ERROR_MSG = "First argument needs to be the lesson to be generated" if __name__ == "__main__": load_sound_cache() - wordids = filter_words("lesson05") - concatenate(filename="lesson05", wordids=wordids) + if len(sys.argv) != 2: + print(ERROR_MSG) + exit(1) + lesson = sys.argv[1] + if not lesson.isdigit(): + print(ERROR_MSG) + exit(1) + lesson = int(lesson) + if not 0 < lesson < 100: + print(ERROR_MSG) + exit(1) + print(lesson) + lesson = "lesson{:02d}".format(lesson) + concatenate(filename=lesson, + wordids=filter_words(lesson)) diff --git a/RUN.sh b/old_RUN.sh similarity index 100% rename from RUN.sh rename to old_RUN.sh diff --git a/requirements.txt b/requirements.txt index b885777..69115bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,4 @@ -cachetools==3.1.0 -certifi==2019.3.9 -chardet==3.0.4 -google-api-core==1.8.0 -google-auth==1.6.3 -google-cloud-texttospeech==0.4.0 -googleapis-common-protos==1.5.8 -grpcio==1.19.0 -idna==2.8 -protobuf==3.7.1 -pyasn1==0.4.5 -pyasn1-modules==0.2.4 -pydub==0.23.1 -pytz==2019.1 -requests==2.21.0 -rsa==4.0 -six==1.12.0 -urllib3==1.24.1 +numpy==1.22.1 +opencv-python==4.5.5.62 +Pillow==9.0.0 +pydub==0.25.1 diff --git a/sound_cache.csv b/sound_cache.csv deleted file mode 100644 index bd07a88..0000000 --- a/sound_cache.csv +++ /dev/null @@ -1,1200 +0,0 @@ -1,de,was -1,en,what -2,de,heissen -2,en,to be called -3,de,das -3,en,that -4,de,Was heisst das? -4,en,What’s that? -5,de,wie -5,en,how -6,de,Wie heisst du? -6,en,How are you called? -7,de,wer -7,en,who -8,de,Wer bist du? -8,en,Who are you? -9,de,Freut mich -9,en,it's a pleasure -76,de,reden -76,en,to talk -78,de,red weiter -78,en,go on -79,de,"Aber bitte, red' weiter" -79,en,but please keep talking -10,de,auch -10,en,also -11,de,Freut mich auch -11,en,it's a pleasure to me too -12,de,Angenehm -12,en,Nice to meet you -13,de,Wie geht’s? -13,en,How’s it going -14,de,woher -14,en,from where -15,de,kommen -15,en,to come -16,de,Woher kommst du? -16,en,Where do you come from? -17,de,aus -17,en,from -18,de,Ich komme aus -18,en,I come from -19,de,das Land -19,en,country -20,de,die Stadt -20,en,city -21,de,wo -21,en,where -22,de,wohnen -22,en,to live -23,de,Wo wohnst du? -23,en,Where do you live? -24,de,Ich wohne in -24,en,I live in -25,de,der Wohnort -25,en,residence -26,de,Schönen Tag -26,en,Have a nice day -27,de,gleichfalls -27,en,likewise -28,de,Bis bald -28,en,See you soon -29,de,die Schweiz -29,en,Switzerland -30,de,Er kommt aus der Schweiz -30,en,He comes from Switzerland -31,de,das Deutschland -31,en,Germany -32,de,jetzt -32,en,now -33,de,Er wohnt jetzt in Deutschland -33,en,He lives in Germany -34,de,mögen -34,en,to like -35,de,Was magst du? -35,en,What do you like? -36,de,der Sport -36,en,sport -37,de,Ich mag Sport -37,en,I like sport -38,de,Es geht -38,en,it's going -39,de,lernen -39,en,to learn -40,de,Ich lerne Deutsch -40,en,I'm learning German -41,de,studieren -41,en,to study -42,de,Entschuldigung -42,en,excuse me -43,de,schreiben -43,en,to write -44,de,Wie schreibt man das? -44,en,How one writes? -45,de,Das schreibt man -45,en,One writes -46,de,buchstabieren -46,en,to spell -47,de,bitte -47,en,please -48,de,Buchstabieren Sie bitte -48,en,Spell that please -49,de,Vielen Dank -49,en,Thank you very much -50,de,Was mögen Sie? -50,en,formally: What do you like? -51,de,die Musik -51,en,music -52,de,Er mag Musik -52,en,He likes music -53,de,der Fussball -53,en,football -54,de,der Kaffee -54,en,coffee -55,de,das Kino -55,en,cinema -56,de,die Kunst -56,en,art -57,de,Du magst Kunst -57,en,You like art -58,de,die Mode -58,en,fashion -59,de,die Pizza -59,en,pizza -60,de,die Schokolade -60,en,chocolate -61,de,die Technik -61,en,technology -62,de,Wer mag Technik? -62,en,Who likes technology? -63,de,nichts -63,en,nothing -64,de,Was magst du liebe -64,en,What do you prefer? -65,de,hören -65,en,to hear -66,de,noch einmal -66,en,once more -67,de,Hören Sie noch einmal -67,en,Hear one more time -68,de,lesen -68,en,to read -69,de,Lesen Sie die Dialoge -69,en,Read the dialog -70,de,die Frage -70,en,question -71,de,Ich habe eine Frage -71,en,I have a question -72,de,antworten -72,en,to answer -73,de,Fragen and antworten Sie -73,en,Ask and answer -74,en,so -74,de,also -75,de,aber -75,en,but -77,de,weiter -77,en,further -80,de,ich bin -80,en,I am -81,de,du bist -81,en,You are -82,de,"er, sie, es. ist" -82,en,"He, she, it. is" -83,de,wir sind -83,en,We are -84,de,ihr seid -85,de,sie sind -85,en,They are -86,de,Wie geht's dir? -86,en,How are you? -87,de,ganz -87,en,quite -88,de,ganz gut -88,en,quite well -89,de,sehr -89,en,very -90,de,sehr gut -90,en,very well -91,de,endlich -91,en,at last -92,de,warm -92,en,warm -93,de,Endlich est es warm -93,en,It's finally warm -95,de,Endlich Sommer -95,en,It's summer at last -96,de,heiss -96,en,hot -97,de,heute -97,en,today -98,de,die Zeit -98,en,time -99,de,für -99,en,for -100,de,das Eis -100,en,icecream -101,de,Heiss heute - zeit für ein Eis -101,en,It's hot today - time for an icecream -102,de,immer -102,en,always -103,de,Eis ist immer gut -103,en,Icecream is always good -104,de,arbeiten -104,en,to work -105,de,Wo arbeiten Sie? -105,en,Where do you work? -106,de,bei -106,en,at -107,de,Wir arbeiten bei Google -107,en,We work at Google -108,de,als -108,en,as -109,de,der Verkäufer -109,en,salesman -110,de,Er arbeitet als Verkäufer -110,en,He works as salesman -111,de,die Ärztin -111,en,female doctor -112,de,Sie ist Ärztin -112,en,She is a doctor -113,de,machen -113,en,to make -114,de,Was machen Sie? -114,en,What are you doing? -115,de,der Ingenier -115,en,engineer -116,de,Ich arbeite als Ingenier -116,en,I work as engineer -117,de,das ist interessant -117,en,that's interesting -118,de,Das Stimmt -118,en,That's true -120,de,Ich arbeite bei Google -120,en,I work at Google -121,de,die Firma -121,en,company -122,de,arbeiten bei Firma -122,en,work at company -123,de,der Beruf -123,en,job -124,de,arbeiten als Beruf -124,en,work as job -125,de,von Beruf sein -125,en,by profession -126,de,Was sind Sie von Beruf? -126,en,What is your profession? -127,de,der Arzt -127,en,male doctor -128,de,Ich bin Arzt von Beruf -128,en,I am a doctor by profession -129,de,der Musiker -129,en,musician -130,de,der Lehrer -130,en,teacher -131,de,die Reinigungskraft -131,en,cleaner -132,de,der Busfahrer -132,en,bus driver -133,de,der Elektriker -133,en,electrician -134,de,Wie ist Ihre Vorname? -134,en,What's your first name -135,de,Mein Vorname ist Daniel -135,en,My first name is Daniel -136,de,der Nachname -136,en,surname -137,de,wissen -137,en,to know -138,de,nicht -138,en,not -139,de,Ich weiss nicht -139,en,I don't know -140,de,Keine Ahnung -140,en,No idea -141,de,die Erdbeere -141,en,strawberry -142,de,Magst du Erdbeereis -142,en,Do you like strawberry icecream -143,de,lecker -143,en,delicious -144,de,gern -144,en,gladly -145,de,lieben -145,en,to love -146,de,Sie liebt Frankreich -146,en,She loves France -147,de,sagen -147,en,to say -148,de,welche -148,en,which -149,de,falsch -149,en,incorrect -150,de,richtig -150,en,correct -151,de,gehen -151,en,to go -152,de,hier -152,en,here -153,de,dann -153,en,then -154,de,spielen -154,en,to play instrument -234,de,neu -234,en,new -235,de,gross -235,en,big -236,de,klein -236,en,small -155,de,da -157,de,Was heisst das auf Deutsch? -157,en,What’s that in German? -158,de,Was ist das? -158,en,What is that? -159,de,Das ist ein Bleistift -159,en,This is a pencil -160,de,das Buch -160,en,book -161,de,das Fenster -161,en,window -162,de,die Flasche -162,en,bottle -163,de,das Handy -163,en,mobile phone -164,de,die Jacke -164,en,jacket -165,de,der Kugelschreiber -165,en,ballpen -166,de,die Lampe -166,en,lamp -167,de,der Papierkorb -167,en,waste paper bin -168,de,der Radiergummi -168,en,rubber -169,de,der Stuhl -169,en,chair -170,de,das Tablet -170,en,tablet -171,de,die Tafel -171,en,blackboard -172,de,die Tasse -172,en,cup -173,de,der Tisch -173,en,table -174,de,die Tür -174,en,door -175,de,der Zettel -175,en,note -176,de,die Brille -176,en,glasses -177,de,der Stift -177,en,pencil -178,de,das Bild -178,en,picture -179,de,die Süssigkeit -179,en,sweet -180,de,das Auto -180,en,car -181,de,die Kanne -181,en,teapot -182,de,die Zeitung -182,en,newspaper -183,de,die Füller -183,en,fountain pen -184,de,die Kamera -184,en,camera -185,de,der Computer -185,en,computer -186,de,der Laptop -186,en,laptop -187,de,die Maus -187,en,mouse -188,de,viele -188,en,many -189,de,das Ding -189,en,thing -190,de,Hier sing viele Dinge -190,en,Here are many things -191,de,Wie viele? -191,en,How many? -192,de,Wie viele Stühle sing hier? -192,en,How many chairs are here? -193,de,Hier sind sechs Stühle -193,en,Here are six chairs -194,de,Ist das ein Tisch? -194,en,Is that a table? -195,de,Nien das ist eine Tür -195,en,No that is a door -196,de,Das sind keine Süssigkeiten -196,en,These are not sweets -197,de,Wie ist der Artikel? -197,en,What is the article? -198,de,wiederholen -198,en,to repeat -199,de,Wiederholen Sie bitte -199,en,Repeat please -200,de,kosten -200,en,to cost -201,de,Was kostet die Zeitung? -201,en,What costs the newspaper -202,de,Er kostet 3 Euro -202,en,It costs 3 euro -203,de,verstehen -203,en,to understand -204,de,Verstehen Sie? -204,en,Do you understand -205,de,Ich verstehe -205,en,I understand -206,de,Ich verstehe nicht -206,en,I don't understand -207,de,funktionieren -207,en,to function -208,de,gelb -208,en,yellow -209,de,teuer -209,en,expensive -210,de,aber sie sind auch sehr teuer -210,en,but they are also very expensive -211,de,billig -211,en,cheap -212,de,aber sie sind nicht billig -212,en,But they are not cheap -213,de,schnell -213,en,fast -214,de,Es ist nicht sehr schnell -214,en,It is not very fast -215,de,langsam -215,en,slow -216,de,leider -216,en,unfortunately -217,de,Er ist leider sehr langsam -217,en,He is unfortunately very slow -219,de,alt -219,en,old -220,de,Wie alt ist der Computer? -220,en,How old is the computer -222,de,erste -222,en,first -223,de,weltweit -223,en,worldwide -224,de,Das ist der erste Computer weltweit -224,en,This is the first computer worldwide -225,de,die Geige -225,en,violin -226,de,über -226,en,over -227,de,das Jahr -227,en,year -228,de,Die Geige ist über 678 Jahre alt -228,en,The violin is over 678 years old -229,de,klingen -229,en,to sound -230,de,fantastisch -230,en,fantastic -231,de,Sie klingt fantastrich -231,en,She sounds fantastic -232,de,schon -232,en,already -233,de,Er ist schon 62 Jahre alt -233,en,He is already 62 years old -237,de,lustig -237,en,funny -238,de,langweilig -238,en,boring -239,de,bunt -239,en,colorful -240,de,schön -240,en,beautiful -241,de,rund -241,en,round -242,de,das Beispiel -242,en,example -283,de,das Heft -283,en,notebook -292,de,der Bleistift -295,de,die Uhr -295,en,clock -305,de,die Tasche -305,en,bag -218,de,Tut mir leid -218,en,I'm sorry -243,de,kurz -243,en,short -244,de,klar -244,en,clear -245,de,mit -245,en,with -246,de,die Batterie -246,en,battery -247,de,die Sonnenbrille -247,en,sunglasses -248,de,die CD -248,en,CD -249,de,das Theater -249,en,theatre -250,de,das Foto -250,en,photograph -251,de,der Mann -251,en,man -252,de,der Preis -252,en,price -253,de,das Geschäft -253,en,shop -254,de,der Ring -254,en,ring -255,de,ordnen -255,en,to order -256,de,das Wort -256,en,word -257,de,zu -257,en,to -258,de,ergänzen -258,en,to complete -259,de,Ordnen Sie die Wörter zu und ergänzen Sie den Plural -259,en,Match the words and add the plural -260,de,kennen -261,de,helfen -261,en,to help -262,de,Kann ich Ihnen helfen? -262,en,Can I help you? -263,de,glauben -263,en,to believe -264,de,suchen -264,en,to search -265,de,der Koffer -265,en,suitcase -266,de,Was suchen Sie? -266,en,What are you looking for? -267,de,Ich glaube Franzi sucht Koffers -267,en,I believe Franzi is looking for suitcases -268,de,shoppen -268,en,to shop -269,de,shoppen gehen -269,en,to go shopping -270,de,Gehen sie gern shoppen? -270,en,Do you like to go shopping? -271,de,Shoppen Sie gern? -271,en,Do you like to shop? -272,de,denken -272,en,to think -273,de,kaufen -273,en,to buy -274,de,der Hut -274,en,hat -275,de,"Ich denke, ich kaufe den Hut" -275,en,I think I will buy the hat -276,de,Was kaufen Sie gern? -276,en,What do you like to buy? -277,de,Ich kaufe gern Sonnenbrillen -277,en,I like to buy sunglasses -278,de,"Nein, ich gehe nicht gern shoppen" -278,en,"No, I do not like shopping" -279,de,schlecht -279,en,bad -280,de,Nicht schlecht -280,en,not bad -281,de,brauchen -281,en,to need -282,de,wirklich -282,en,really -284,de,Brauchst du das Heft wirklich? -284,en,Do you really need the notebook? -285,de,das Kleid -285,en,dress -286,de,Ich brauche ein Kleid -286,en,I need a dress -287,de,der Freund -287,en,friend -288,de,möchten -288,en,would like -289,de,Sie und Ihr Freund möchten shoppen gehen -289,en,You and your friend want to go shopping -290,de,Was brauchen Sie? -290,en,What do you need? -291,de,haben -291,en,to have -293,de,Ich habe leider keinen Bleistift -293,en,Unfortunately I do not have a pencil -294,de,finden -294,en,to find -296,de,Wie findet ihr die Uhr? -296,en,How do you like the clock? -297,de,der Traum -297,en,dream -298,de,Shoppen in Zürich - ein Traum -298,en,Shopping in Zurich - a dream -299,de,ersten -300,de,Hören Sie den ersten Dialog noch einmal -300,en,Listen to the first dialogue again -301,de,Gehen wir shoppen? -301,en,Shall we go shopping? -302,de,Gute idee -302,en,good idea -303,de,Bitte schön -303,en,You're welcome -304,de,Schau mal -304,en,Look! -306,de,vielleicht -306,en,perhaps -307,de,der Schuh -307,en,shoe -308,de,Ich brauche eine Tasche und vielleicht auch noch Schuhe -308,en,I need a bag and maybe some shoes -309,de,denn -309,en,because -310,de,Was brauchst du denn? -311,de,alles -311,en,all -312,de,Ist das alles? -312,en,Is that all? -313,de,nur -313,en,only -314,de,das Ladekabel -314,en,charger -315,de,Ich brauche nur ein Ladekabel -315,en,I only need a charging cable -316,de,günstig -317,de,Das ist günstig -317,en,That is cheap -318,de,hast -318,en,he has -319,de,die Handyhülle -319,en,phone case -320,de,Du hast schon sechs Hüllen -320,en,You already have six cases -321,de,die Kette -321,en,necklace -322,de,Haben Sie keine Ketten? -322,en,Don't you have neclaces? -323,de,der Lippenstift -323,en,lipstick -324,de,"Nein, wir haben keine Lippenstifte" -324,en,"No, we do not have lipsticks" -325,de,die Hose -325,en,trousers -326,de,"Doch, wir haben Hosen" -326,en,"Yes, we have pants" -327,de,toll -327,en,great -328,de,Zürich ist toll -328,en,Zurich is great -329,de,die Woche -329,en,week -330,de,Ich bin schon eine Woche in Zürich -330,en,I've been in Zurich for a week already -331,de,der Tipp -331,en,hint -332,de,Und das sind meine Tipps -332,en,And these are my tips -333,de,der Tee -333,en,tea -334,de,dort -334,en,there -335,de,Ich finde den Tee dort fantastisch! -335,en,I think the tea is fantastic there! -336,de,kennt -336,en,he knows -337,de,Wer kennt das teehaus? -337,en,Who knows the tea house -338,de,fein -338,en,fine -339,de,besonders -339,en,especially -340,de,das Schiff -340,en,ship -341,de,Ich finde die Schiffe besonders elegant -341,en,I find the ships especially elegant -342,de,berühmt -342,en,famous -343,de,Es ist sehr berühmt -343,en,It is very famous -344,de,der Hafen -344,en,harbor -345,de,Wie findest du den Hafen? -345,en,How do you like the harbor? -346,de,Was machen Sie gern? -346,en,What do you like doing? -347,de,er liest -347,en,he reads -348,de,Ich lese gern Bücher -348,en,I like reading books -350,de,Musik hören -350,en,listen to music -351,de,Ich höre gern Musik -351,en,I like to listen to music -353,de,die Freizeit -353,en,free time -354,de,Was macht man in der Freizeit? -354,en,What do you do in your free time? -356,de,Was glauben Sie? -356,en,What do you think? -357,de,Was macht Frank gern? -357,en,What do you think Frank likes to do? -358,de,kochen -358,en,to cook -359,de,"Ich glaube, Frank kocht gern." -359,en,I think Frank likes to cook -360,de,wandern -360,en,to hike -361,de,"Ich glaube, Sonja wandert gern." -361,en,I think Sonia likes to hike -364,de,Zeit haben -364,en,to have time -365,de,Ich habe leider keine Zeit -365,en,Unfortunately I have no time -366,de,fernsehen -366,en,to watch TV -367,de,sie sieht fern -367,en,she watches TV -368,de,das Fahrrad -368,en,bycicle -369,de,fahren -369,en,to ride -370,de,er fährt -370,en,he drives -371,de,Fahrrad fahren -371,en,to ride a bicycle -372,de,Sie färt gern Fahrrad -372,en,She likes to ride a bycicle -373,de,der Ski -373,en,ski -374,de,Ski fahren -374,en,to ski -375,de,Ich fahre nicht gern Ski -375,en,I do not like skiing -376,de,der Schlittschuh -376,en,ice skate -377,de,laufen -377,en,to run -378,de,sie läuft -378,en,she runs -379,de,Schlittschuh laufen -379,en,to ice skate -380,en,to play -381,de,Volleball spielen -381,en,to play Volleyball -382,de,spielt gern Volleyball -382,en,likes to play Volleyball -383,de,Tommi spielt gern Fussball -383,en,Tommi likes to play football -384,de,Sport machen -384,en,to do sport -385,de,treffen -385,en,to meet -386,de,Freunde treffen -386,en,meeting friends -387,de,Triffst du gern Freunde? -387,en,Do you like meeting friends? -388,de,Sie trifft gern Freunde -388,en,She likes to meet friends -389,de,die Jahrezeit -389,en,season -390,de,der Frühling -390,en,spring -391,de,im Frühling -391,en,in spring -392,de,der Sommer -392,en,summer -393,de,der Herbst -393,en,autumn -394,de,der Winter -394,en,winter -395,de,Was machst du im Herbst? -395,en,What do you do in autumn? -396,de,Im Winter fahre ich Ski -396,en,In winter I ski -398,de,Wer macht was gern? -398,en,Who likes to do something? -399,de,schwimmen -399,en,to swim -400,de,Jana schwimmt gern -400,en,Jana likes to swim -401,de,"Ja, das stimmt" -401,en,Yes that's true -402,de,"Nein, das stimmt nicht. Ich wandere gern." -402,en,"No, that is not right. I like hiking." -403,de,fotografieren -403,en,to take photographs -404,de,tanzen -404,en,to dance -405,de,sehen -405,en,to see -406,de,sie seiht -406,en,she sees -407,de,der Film -407,en,film -408,de,Filme sehen -408,en,see movies -409,de,schlafen -409,en,to sleep -410,de,er schläft -410,en,he sleeps -411,de,lange schlafen -411,en,sleep late -413,de,Wie -414,de,Wie fragen Sie -414,en,How do you ask? -415,de,Was ist Sie von Beruf? -415,en,What is your occupation? -416,de,die Botschaft -416,en,embassy -417,de,Ich arbeite in der deutschen Botschaft -417,en,I work in the German Embassy -418,de,oft -418,en,often -419,de,Wie oft? -419,en,How often? -420,de,der Tag -420,en,day -421,de,5 Tage pro Woche -421,en,5 days a week -422,de,der Alltag -422,en,everyday life -423,de,der Montag -423,en,Monday -424,de,der Dienstag -424,en,Tuesday -425,de,der Mittwoch -425,en,Wednesday -426,de,der Donnerstag -426,en,Thursday -427,de,am Donnerstag -427,en,on Thursday -428,de,der Freitag -428,en,Friday -429,de,der Samstag -429,en,Saturday -430,de,der Sonntag -430,en,Sunday -431,de,das Wochenende -431,en,weekend -432,de,am Wochenende -432,en,in the weekend -433,de,anfangen -433,en,to begin -434,de,er fängt an -434,en,he starts -435,de,In Ägypten fängt die Woche am Sonntag an -435,en,"In Egypt, the week starts on Sunday" -436,de,aufhören -436,en,to end -437,de,Hört am Donnerstag auf -437,en,Ends on Thursday -438,de,leicht -438,en,easy -440,de,Das ist nicht immer leicht -440,en,That's not always easy -441,de,wegfahren -441,en,to drive away -442,de,er fährt weg -442,en,he drives away -443,de,Ich fahre am Freitag oft weg -443,en,I often drive away on Friday -444,de,Schweiz ist toll -444,en,Switzerland is great -445,de,es gibt -445,en,there is -446,de,die Sehenswürdigkeit -446,en,sight -447,de,das Meer -447,en,sea -448,de,"Ägypten ist toll - es gibt die Pyramiden, viele Sehenswürdigkeiten und das Meer." -448,en,"Egypt is great - there are the pyramids, many sights and the sea." -449,de,einladen -449,en,to invite -450,de,sie lädt ein -450,en,she invites -451,de,der Gast -451,en,guest -452,de,manchmal -452,en,sometimes -453,de,Am Sonntag und am Dienstag lade ich manchmal Gäste ein -453,en,On Sundays and Tuesdays I sometimes invite guests -454,de,der Ausflug -454,en,excursion -455,de,Wir machen Ausflüge -455,en,We make excursions -456,de,die Leute -456,en,people -457,de,Ich mag die Leute -457,en,I like the people -458,de,selten -458,en,rarely -459,de,Leider sehe ich meine Kinder sehr selten -459,en,"Unfortunately, I rarely see my children" -460,de,die Eltern -460,en,parents -461,de,dreimal -461,en,3 times -462,de,dreimal pro Jahr -462,en,three times a year -463,de,anrufen -463,en,to call -464,de,Am Mittwoch rufe ich oft meine Eltern an. -464,en,"On Wednesday, I often call my parents." -466,de,lange -466,en,long -467,de,sprechen -467,en,to speak -468,de,sie spricht -468,en,she speaks -469,de,dann sprechen wir lange -469,en,then we talk for a long time -470,de,leben -472,de,Ich lebe schon sieben Jahre in Argentinien -472,en,I have been living in Argentina for seven years -473,de,die Arbeit -474,de,die Stunde -474,en,hour -475,de,jeden -475,en,each -476,de,jeden Tag -476,en,every day -477,de,Ich arbeite jeden Tag zehn Stunden am Mittwoch auch zwölf. -477,en,I work ten hours a day and twelve on Wednesday. -478,de,müde -478,en,tired -479,de,Dann bin ich immer sehr müde. -479,en,Then I am always very tired. -480,de,ausgehen -480,en,to go out -481,de,gehe ich manchmal aus -481,en,I go out sometimes -482,de,gehe ins Kino -482,en,go to the cinema -483,de,einkaufen -484,de,kaufe ich immer ein -484,en,I always go shopping -485,de,die Wohnung -485,en,flat -486,de,aufräumen -486,en,to tidy up -487,de,räumen ich die Wohnung auf -487,en,I tidy up the flat -489,de,Ich sehe nur selten fern -489,en,I only rarely watch TV -490,de,der Berg -490,en,mountain -491,de,weit -491,en,far -492,de,Die Berge sind hier nicht weit -492,en,The mountains are not far from here -493,de,Herr Rauter fährt am Freitag oft weg -493,en,Mr. Rauter often drives away on Friday -494,de,wann -494,en,when -495,de,Wann ruft sie die Kinder an? -495,en,When does she call the children? -496,de,Wie oft sieht er fern? -496,en,How often does he watch TV? -497,de,Sie sieht selten fern -497,en,She rarely watches TV -499,de,anders -499,en,different -500,de,Welche Tage sind anders? -500,en,Which days are different? -501,de,Ich lade selten Gäste ein. -501,en,I rarely invite guests. -502,de,Wie oft kaufst du ein? -502,en,How often do you go shopping? -503,de,Sag mal -503,en,Tell me -504,de,Was machst du am Donnerstag? -504,en,What are you doing on Thursday? -505,de,Am Freitag habe ich leider auch keine Zeit -505,en,Unfortunately I have no time on Friday -506,de,Gehen wir aus? -506,en,Let's go out? -507,de,Gehen wir ins Konzert? -507,en,Are we going to the concert? -509,de,75 -509,en,75 -510,de,das Prozent -510,en,percent -512,de,die Bücher -512,en,books -514,de,75 Prozent lesen gern Bücher -514,en,75 percent like to read books -515,de,bei uns -515,en,in our country -516,de,bis -516,en,until -517,de,nie -517,en,never -518,de,Tanzt du gern? -518,en,Do you like dancing? -519,de,Was machst du im Frühling? -519,en,What are you doing in the spring? -520,de,Im Sommer wandere ich gern -520,en,I like to hike in the summer -521,de,Am Wochenende habe ich frei. -521,en,I'm free on the weekend. -522,de,Gehen wir am Dienstag aus? -522,en,Are we going out on Tuesday? -523,de,Am Samstag koche ich -523,en,On Saturday I cook -524,de,Was macht man in der Schweiz in der Freizeit? -524,en,What do people do in Switzerland during their free time? -525,de,In der Schweiz macht man gern Sport. -525,en,In Switzerland people like to do sports. -526,de,62 Prozent gehen gern ins Kino -526,en,62 percent like to go to the cinema -527,de,der Garten -527,en,garden -528,de,86% gehen im Garten arbeiten -528,en,86% work in the garden -529,de,Die Schweizer machen gern Sport -529,en,The Swiss like to do sports -531,de,glück -531,en,luck -532,de,glücklich -532,en,happy -533,de,der Wunch -533,en,wish -534,de,herzlich -534,en,heartily -535,de,Herzlichen Glückwunsch! -535,en,Congratulations -536,en,husband -537,de,"Schau mal, Hannah, das ist mein Mann." -537,en,"Look, Hannah, this is my husband" -538,de,verheiratet -538,en,married -539,de,Wir sind jetzt vier Jahre verheiratet. -539,en,We are married for four years now -540,de,ledig -540,en,single -541,de,verlobt -541,en,engaged -542,de,geschieden -542,en,divorced -543,de,Sie ist 22 Jahre alt -543,en,She is 22 years old -544,de,Ich bin 27 Jahre alt -544,en,I am 27 years old -545,de,süss -546,de,Der ist süss -546,en,He is sweet -547,de,die Geschwister -547,en,siblings -548,de,der Bruder -548,en,brother -549,de,die Schwester -549,en,sister -550,de,Meine Schwester Emma arbeitet viel im Ausland. -550,en,My sister Emma works a lot abroad. -551,de,Ist die Schwester von Mia verheiratet? -551,en,Is Mia's sister married? -552,de,aussehen -552,en,to look -554,de,umwerfend -554,en,stunning -555,de,Sie sieht umwerfend aus. -555,en,She looks stunning -556,de,hat -556,en,has -557,de,das Kind -557,en,child -558,de,Hat sie auch Kinder? -558,en,Does she have children? -559,de,Sie hat keine Kinder. -559,en,She has no children -560,de,der Sohn -560,en,son -561,de,die Tochter -561,en,daughter -563,de,von -563,en,of -564,de,Wie alt ist der Sohn von Mia? -564,en,How old is Mia's son? -565,de,Wie findet Hannah den Sohn von Mia? -565,en,How does Hannah find Mia's son? -566,de,deine -566,en,your -568,de,nett -568,en,nice -569,de,Deine Eltern sehen auch nett aus. -569,en,Your parents also look nice. -570,de,die Mutter -570,en,mother -571,de,der Vater -571,en,father -572,de,die Familie -572,en,family -573,de,Das is der Sohn von Mia -573,en,This is Mia's son -574,de,die Ehe -574,en,marriage -575,de,der Ehepartner -576,de,die Ehepartnerin -576,en,wife -577,de,meine -577,en,my -578,de,die Grosseltern -578,en,grandparents -579,de,Meine Grosseltern wohnen in Norddeutschland -579,en,my grandparents live in northern Germany -580,de,die Grossmutter -580,en,grandmother -581,de,der Grossvater -581,en,grandfather -582,de,Jan ist mein Bruder -582,en,Jan is my brother -584,de,Wer ist Nicole? -586,de,Was glaubst du? -587,de,Ich glaube Sascha ist dein Vater -588,de,vorstellen -588,en,to introduce -589,de,Julia und Jan stellen ihre Familien vor. -589,en,Julia and Jan introduce their families. -591,de,Sprechen Sie weiter -591,en,Keep talking -592,de,unsere -592,en,our -593,de,Das ist unsere Tochter -593,en,This is our daughter -594,de,die Einladung -594,en,invitation -595,de,die Party -595,en,party -596,de,Einladung zu einer Party -596,en,Invitation to a party -598,de,Sie möchten Freunde zu einer Party einladen -598,en,You would like to invite friends to a party -599,en,What do you do? -600,de,der Brief -600,en,letter -601,de,Einen Brief schreiben. -601,en,Write a letter. -603,de,posten -603,en,to post -604,de,die Nachricht -604,en,message -605,de,Eine Nachricht posten -605,en,Post a message -606,de,Mache am Freitag eine Party -606,en,Make a party on Friday -607,de,Ich lade alle helrzlich ein! -607,en,I invite everyone! -608,de,hoffen -608,en,to hope -609,de,bringen -609,en,to bring -610,de,die Laune -610,en,mood -611,de,"Ich hoffe, ihr kommt alle und bringt gute Laune mit!" -611,en,I hope you all come and bring a good mood! -612,de,seine -612,en,his -613,de,Wer lädt seine Freunde ein? -613,en,Who invites his friends? -614,de,feiern -614,en,to celebrate -615,de,die Feier -615,en,celebration -616,de,Wann ist die Feier? -616,en,When is the celebration -617,de,Was fiert die Person? -617,en,What is the person celebrating? -618,en,How many -619,de,Wie viele Personen kommen? -619,en,How many people are coming? -620,de,die Sprechblasen -620,en,speech bubbles -622,de,sympathisch -622,en,sympathetic -624,de,"Tolle Party, nicht?" -624,en,"Great party, right?" -625,de,können -625,en,can -626,de,Wir können gern du sagen -626,en,We can say you informally -627,de,Ich lebe in Hamburg -627,en,I live in Hamburg -628,de,Echt? -628,en,Really? -629,de,war -629,en,was -631,de,Ich war schon in Spanien -631,en,I have been in Spain -632,de,warst -632,en,were -633,de,Wo warst du denn? -633,en,Where have you been? -634,de,das Ausland -634,en,abroad -635,de,der Deutcher -635,en,male German -636,de,die Deutsche -636,en,female German -637,de,die Sprache -637,en,language -638,de,Ich spreche Deutch. -638,en,I speak German -639,de,Ich bin Deutcher -639,en,I am German -584,en,Who is Nicole? -587,en,I think Sascha is your father -508,de,In der Schweiz liest man sehr gern und oft. -508,en,In Switzerland one reads very much and often. diff --git a/tts.py b/tts.py deleted file mode 100644 index ea95bbc..0000000 --- a/tts.py +++ /dev/null @@ -1,34 +0,0 @@ -from google.cloud import texttospeech - -# Instantiates a client -client = texttospeech.TextToSpeechClient() - - -def gen_speech(text, language_code, output_file): - """Synthesizes speech from the input string of text or ssml. - - Note: ssml must be well-formed according to: - https://www.w3.org/TR/speech-synthesis/ - """ - - # Set the text input to be synthesized - synthesis_input = texttospeech.types.SynthesisInput(text=text) - - # Build the voice request, select the language code ("en-US") and the ssml - # voice gender ("neutral") - voice = texttospeech.types.VoiceSelectionParams( - language_code=language_code, - ssml_gender=texttospeech.enums.SsmlVoiceGender.NEUTRAL) - - # Select the type of audio file you want returned - audio_config = texttospeech.types.AudioConfig( - audio_encoding=texttospeech.enums.AudioEncoding.MP3) - - # Perform the text-to-speech request on the text input with the selected - # voice parameters and audio file type - response = client.synthesize_speech(synthesis_input, voice, audio_config) - - # The response's audio_content is binary. - with open(output_file, 'wb') as out: - # Write the response to the output file. - out.write(response.audio_content) \ No newline at end of file