Provide guidance on creating a header for `streaming_synthesize` in streaming_tts_quickstart.py
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
texttospeech/snippets/streaming_tts_quickstart.py の46〜48行目付近から始め、リンク先のWAV仕様を確認してください。ヘッダーのない24,000 Hz LINEAR16レスポンスに対してヘッダーをどのように作成すべきかを判断し、その後、再生可能な音声を生成するためのガイダンスを提供するようサンプルを更新してください。ストリーミング合成をデバッグするユーザーにとって、生成された出力の処理方法が明確であることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
From https://github.com/googleapis/google-cloud-python/issues/13405, the response to streaming_synthesize is headerless LINEAR16 audio with a sample rate of 24000.. The code sample below prints the size of the audio content but does not include the necessary header to actually play the audio.
This may not be the purpose of the code sample, however having this extra information in the code sample will help with debugging customer issues such as https://github.com/googleapis/google-cloud-python/issues/13405.
I added code which includes the raw audio header, however there is likely an easier way to achieve this. We should provide guidance on how folks should create the audio header.
# This is a raw header based on the spec at https://docs.fileformat.com/audio/wav/
header = b'RIFF\x00\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\xc0]\x00\x00\x80\xbb\x00\x00\x02\x00\x10\x00data\x00\x00\x00\x00'
total_length = 0
with open(f"output.wav", "wb") as out:
out.write(header)
for response in streaming_responses:
# calculate the length of the content
total_length += len(response.audio_content)
out.write(response.audio_content)
# Position 40 - 43: Size of the data section
out.seek(40)
out.write(bytes([total_length & 0xFF, (total_length >> 8) & 0xFF, (total_length >> 16) & 0xFF, (total_length >> 24) & 0xFF]))
import os
file_size = os.path.getsize("output.wav")
with open(f"output.wav", "r+b") as out:
# Position 4-7: Size of the overall file - 8 bytes, in bytes (32-bit integer). Typically, you’d fill this in after creation.
out.seek(4)
out.write(bytes([file_size & 0xFF, (file_size >> 8) & 0xFF, (file_size >> 16) & 0xFF, (total_length >> 24) & 0xFF]))
- 主要言語
- Jupyter Notebook
- スター
- 8.1k
- フォーク
- 6.7k
- 平均マージ
- 4日 4時間
- マージ済み PR(30日)
- 8
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
GoogleCloudPlatform/python-docs-samples のほかの issue
-
samples
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
samples
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
samples
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
samples
GoogleCloudPlatform/python-docs-samples#14117 · 担当者 1 名 ·
-
samples
GoogleCloudPlatform/python-docs-samples#14091 · 担当者 1 名 ·
GoogleCloudPlatform/python-docs-samples の issue をすべて見る
似ている issue
-
rules
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
difficulty/starter 🚀 good first issue kind/consumer-experience kind/documentation platform/ios 🍎 platform/wasm 🌐 project/documentation 📖 project/non-ui ⚙️ triage/untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
unoplatform/uno#24649 ·
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
Перевод устарел
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100