Provide guidance on creating a header for `streaming_synthesize` in streaming_tts_quickstart.py
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 35/100
- Issue 類型
- 文件
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
從 texttospeech/snippets/streaming_tts_quickstart.py 第 46-48 行附近開始,並檢視連結的 WAV 規格。確定應如何為不含 header 的 24,000 Hz LINEAR16 回應建立 header,然後更新範例,以提供能產生可播放音訊的指引。確認對於除錯串流合成的使用者而言,產生輸出的處理方式是清楚的。
由索引模型根據 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 小時
- 30 天內合併 PR
- 8
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 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
-
automated issue report
難度 2/5 1-3 小時 新手友好度 84/100
-
documentation
難度 2/5 1-3 小時 新手友好度 68/100
components-web-app/docs#99 ·
-
難度 1/5 1 小時以內 新手友好度 90/100
TheOdinProject/curriculum#31423 ·
-
難度 1/5 1 小時以內 新手友好度 75/100
-
hcocena 未關閉policies-accepted pre-review precheck-passed
難度 1/5 1 小時以內 新手友好度 88/100
Bioconductor/BiocContributions#214 · 5 則留言 ·