Provide guidance on creating a header for `streaming_synthesize` in streaming_tts_quickstart.py
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- documentation
Hướng nghiên cứu
Bắt đầu với texttospeech/snippets/streaming_tts_quickstart.py quanh các dòng 46-48 và xem xét đặc tả WAV được liên kết. Xác định cách tạo header cho các phản hồi LINEAR16 24.000 Hz không có header, sau đó cập nhật sample để cung cấp hướng dẫn tạo ra âm thanh có thể phát được. Xác nhận rằng cách xử lý output tạo ra là rõ ràng đối với người dùng đang debug quá trình tổng hợp streaming.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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]))
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 8.1k
- Fork
- 6.7k
- Merge trung bình
- 4 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 8
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của GoogleCloudPlatform/python-docs-samples
-
samples
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
samples
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
samples
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
samples
GoogleCloudPlatform/python-docs-samples#14117 · 1 người được giao ·
-
samples
GoogleCloudPlatform/python-docs-samples#14091 · 1 người được giao ·
Tất cả issue của GoogleCloudPlatform/python-docs-samples
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
Mintplex-Labs/anything-llm#6490 ·
-
bug needs response
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Adyen/adyen-dotnet-api-library#1869 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
w3c/webdriver-bidi#1168 ·
-
Templating diagram is misleading Đang mởarea/documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
rancher/fleet-product-docs#393 ·
-
Type/Improvement
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
OpenNSW/nsw-srilanka#522 ·