Text and speech quickstart snippets now run and report errors
The text to speech and speech to text quickstart snippets now run as published and fail loudly when a request fails.
Text to speech
- The JavaScript snippet runs. It now uses
importinstead ofrequire, so save it asquickstart.mjsand runnode quickstart.mjs(Node 18+). - The cURL commands add
--fail. A rejected request, such as a wrong API key, printsThe requested URL returned error: 401instead of writing the error intohello.wavoroutput.wav. - The Python
requestssnippet callsresponse.raise_for_status(), so a failed request raises an error instead of printing “Saved output.wav”. - The Python SDK snippet writes
output.wavonly after the audio arrives, so a failed request no longer leaves an empty file. It now prints the file size.
Speech to text
- The JavaScript snippet says to save it as
quickstart.mjs, since it uses top-levelawait.