Google Text to Speech(Windows)
問題
- Google Text to Speechで遊びたい
- Quick StartだとGoogleCloudSDKインストールが必要で、Proxy超える必要がある。
実際のコードはこちら
この記事を読んでできること
- Proxy環境でのGoogleTextToSpeech
- Pythonでテキストを音声にする
- 付録
設定
サービスアカウントキーを手に入れておく
Pythonでpip
# Python3.6環境 pip install --upgrade google-cloud-texttospeech # googleapiclient使いたい pip install --upgrade google-api-python-client conda upgrade pip pip install --upgrade oauth2client
ソースの参考資料
basy64でエラーが起きた場合
TypeError: a bytes-like object is required, not 'str'
audio再生部分
VIMからキック
- こんな感じのスクリプトを書いておきます
"google text to speech"{{{ function! s:get_google_zihou()" let s:py_script = "c:/pg/google_text2speech/post_text.py" silent execute '!D:/Anaconda3/envs/dev/python.exe ' . ' ' . s:py_script . ' -c time' unlet! s:py_script endfunction augroup END" command! -nargs=0 GetZihou call s:get_google_zihou() function! s:get_google_text()" let s:file = tempname() silent execute ":write " . s:file let s:py_script = "c:/pg/google_text2speech/post_text.py" execute '!D:/Anaconda3/envs/dev/python.exe ' . ' ' . s:py_script . ' -f ' . s:file call delete(s:file) unlet! s:file unlet! s:py_script endfunction augroup END" command! -nargs=0 ChangeTex call s:get_google_text() "}}}