Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2912

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

$
0
0

公式ドキュメントは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ファイルにするだけでした。


Viewing all articles
Browse latest Browse all 2912

Trending Articles