Skip to navigation

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 import instead of require, so save it as quickstart.mjs and run node quickstart.mjs (Node 18+).
  • The cURL commands add --fail. A rejected request, such as a wrong API key, prints The requested URL returned error: 401 instead of writing the error into hello.wav or output.wav.
  • The Python requests snippet calls response.raise_for_status(), so a failed request raises an error instead of printing “Saved output.wav”.
  • The Python SDK snippet writes output.wav only 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-level await.

→ Text to speech quickstart · Speech to text quickstart