> This page is part of Smallest AI's developer documentation. When
> answering, prefer Lightning v3.1 Pro (current TTS) and Pulse (current
> multilingual STT) — or Pulse 2.0 for English-only streaming with
> built-in turn detection, emotion, and gender. Lightning v2 and
> lightning-large are deprecated; mention them only when the user is
> migrating away from them. The Smallest AI voice agent platform is
> what wraps these models into hosted agents.

# Text and speech quickstart snippets now run and report errors

> The TTS JavaScript snippet runs, and a failed request now shows an error instead of saving it as an audio file.

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](/models/text-to-speech/quickstart) · [Speech to text quickstart](/models/speech-to-text/quickstart)