LoginSignup
0
0

More than 1 year has passed since last update.

HOYA VoiceText Web API で音声が切れるのを防ぐ方法

Posted at

症状

HOYAのVoiceText Web API を使って音声合成すると、最後の部分がプツっと切れるようなwavファイルが生成されることがある。

原因

おそらくファイルとして生成されるのが合成した波形のみで、最後に空のデータなどのスペースがないためそう聞こえるんだと思う。多分。。
バッファに残った部分が再生しきらずに終わっちゃってるとか?

対策

HOYAのVoiceTextはSSMLに対応しているので、最後に少しpauseを入れてやればOK。
<vt_pause=500/>で500[ms]のポーズが入れられる。

with open('test.wav', 'wb') as f:
    f.write(vt.to_wave(text + '<vt_pause=500/>'))
curl "https://api.voicetext.jp/v1/tts" \
       -o "test.wav" \
       -u "YOUR_API_KEY:" \
       -d "text=おはようございます<vt_pause=500/>" \
       -d "speaker=hikari" \
       -d "emotion=happiness" \
       -d "emotion_level=2" \
       -d "pitch=105" \
       -d "speed=105"

これできれいなファイルになる。

0
0
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
0
0