こんな方におすすめ
- 英語のプレゼンの練習をしたい
- 英語のテキストを正しく読んでほしい
今回は、英語でのプレゼンを控えている方は必見です。Pythonで制御したgoogleのAPIにより、英語テキストをネィティブが読んでくれます。
これを使ってプレゼン練習すれば、英語のプレゼンも怖くありません。
プログラムの流れ
Google text to speechのAPIをPythonで制御して、プレゼンで話すテキストを音声変換し、MP3ファイルを作成します。このプログラムは、Google text to speechの事前設定が必要になります。
以下の記事を参考に事前に設定してください。
プログラムの内容
英語のテキストを読み上げたMP3を作成します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#必要なモジュールのインポート from google.cloud import texttospeech # Instantiates a client client = texttospeech.TextToSpeechClient() # ここにプレゼンする内容を書き込む synthesis_input = texttospeech.SynthesisInput(text="\ \ Thank you all for coming to my presentation today.\ Let me introduce my self first.\ My name is MAYR.I'm in the development group of python application.\ I'd like to talk to you about studying English.\ ") # Build the voice request, select the language code ("en-US") and the ssml # 声の設定をする。voice gender ("neutral") voice = texttospeech.VoiceSelectionParams( language_code="en-US", ssml_gender=texttospeech.SsmlVoiceGender.NEUTRAL ) # MP3の設定をする audio_config = texttospeech.AudioConfig( audio_encoding=texttospeech.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( input=synthesis_input, voice=voice, audio_config=audio_config ) # MP3ファイルを作成する。 with open("output.mp3", "wb") as out: # Write the response to the output file. out.write(response.audio_content) print('Audio content written to file "output.mp3"') |
まとめ
今回は以下の文章を読み上げました。
”Thank you all for coming to my presentation today.Let me introduce my self first.My name is MAYR.I'm in the development group of python application. I'd like to talk to you about studying English.”
この内容を読み上げたMP3ファイルが以下になります。なかなか自然に読めていると思います。
ぜひ、ご自分の英語プレゼンのテキストを読ませてプレゼンの練習をしてみてください。また、韓国語など他の言語で読ませることも可能です。