Provide guidance on creating a header for `streaming_synthesize` in streaming_tts_quickstart.py
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Dokumentation
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- documentation
Rechercherichtung
Beginnen Sie bei texttospeech/snippets/streaming_tts_quickstart.py etwa in den Zeilen 46–48 und prüfen Sie die verknüpfte WAV-Spezifikation. Ermitteln Sie, wie der Header für die headerlosen Antworten mit 24.000 Hz LINEAR16 erstellt werden sollte, und aktualisieren Sie anschließend das Beispiel, um eine Anleitung bereitzustellen, die abspielbares Audio erzeugt. Bestätigen Sie, dass die Handhabung der resultierenden Ausgabe für Benutzer, die die Streaming-Synthese debuggen, klar ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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]))
- Vorherrschende Sprache
- Jupyter Notebook
- Sterne
- 8.1k
- Forks
- 6.7k
- Ø Merge
- 4 T. 4 Std.
- Gemergte PRs (30 T.)
- 8
Entwicklungsumgebung
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus GoogleCloudPlatform/python-docs-samples
-
samples
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
GoogleCloudPlatform/python-docs-samples#14609 ·
Maintainer antworten meist innerhalb von 1 Tag
-
samples
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
GoogleCloudPlatform/python-docs-samples#14610 ·
Maintainer antworten meist innerhalb von 1 Tag
-
samples
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
GoogleCloudPlatform/python-docs-samples#14611 ·
Maintainer antworten meist innerhalb von 1 Tag
-
chore(generative_ai) Update model references for generative_ai samplesEvtl. wieder frei @XrossFox hat das vor 151 Tagen übernommen, und es ist kein Pull Request offen. Offensamples
GoogleCloudPlatform/python-docs-samples#14117 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Fix Pipeline dependency issues for geospatial-classification/serving_appEvtl. wieder frei @XrossFox hat das vor 163 Tagen übernommen, und es ist kein Pull Request offen. Offensamples
GoogleCloudPlatform/python-docs-samples#14091 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in GoogleCloudPlatform/python-docs-samples
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 94/100
Maintainer antworten meist innerhalb von 1 Tag
-
issue-doc-idea needs-triage
Schwierigkeit 2/5 1-2 Tage Anfängerfreundlichkeit 86/100
MicrosoftDocs/PowerShell-Docs#13306 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
coder/coder#29955 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
documentation good first issue
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
Maintainer antworten meist innerhalb von 1 Tag