LoginSignup
4
2

More than 3 years have passed since last update.

Google Cloud Text-to-Speechで生成した音声をwavで取得メモ

Last updated at Posted at 2020-01-14

公式ドキュメントはmp3でのやり方だったのでメモ

curl -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  -H "Content-Type: application/json; charset=utf-8" \
  --data "{
    'input':{
      'text':'こんにちは'
    },
    'voice':{
      'languageCode':'ja-JP',
      'name':'ja-JP-Wavenet-B',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'LINEAR16'
    }
  }" "https://texttospeech.googleapis.com/v1/text:synthesize" > synthesize-text.txt

LINEAR16で出力してから

cat synthesize-text.txt | grep 'audioContent' | \
sed 's|audioContent| |' | tr -d '\n ":{},' > tmp.txt && \
base64 -d tmp.txt --decode > synthesize-text-audio.wav && \
rm tmp.txt

wavファイルにするだけでした。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2