# Speech: STT, TTS, Audio Backup

## Transcription

`POST /api/transcribe` accepts `multipart/form-data` with one audio file up to 25 MB. The provider is selected by `TRANSCRIBE_PROVIDER`, or auto-detected from available credentials.

Provider priority in auto mode is Google/Gemini, AWS Transcribe, LiteLLM, then OpenAI Whisper when configured.

| Provider | Notes | HIPAA posture |
|---|---|---|
| Google/Gemini | Uses the configured Vertex/Gemini STT model. | Eligible with the correct Google Cloud agreement. |
| AWS Transcribe | Supports standard and Medical mode. | Eligible with the correct AWS agreement. |
| LiteLLM | Sends audio through the configured LiteLLM `/audio/transcriptions` backend. | Depends on the selected upstream. |
| OpenAI Whisper | Uses `whisper-1` directly when `OPENAI_API_KEY` is configured. | Not HIPAA eligible unless your own agreement says otherwise. |

Browser Whisper and browser-local Whisper workers are not part of the runtime. Do not add browser model downloads or Transformers.js STT back into the public app.

## Web Speech Preview

Browser-native Web Speech can show interim text when the user explicitly enables it. It is browser/vendor dependent, may send audio to browser-provider cloud services, and should not be treated as the final clinical transcript.

## Text To Speech

`POST /api/text-to-speech` returns `audio/mpeg`. The `X-TTS-Provider` response header identifies the provider used. Requests are limited to 5000 characters.

| Provider | Notes |
|---|---|
| Google Cloud TTS | Uses Google Cloud voices when configured. |
| LiteLLM | Uses `LITELLM_TTS_MODEL` and `LITELLM_TTS_VOICE`. |
| ElevenLabs | Available when configured; not HIPAA eligible by default. |

## Audio Backup

Failed transcription submissions can be stored for retry instead of being silently lost.

- Audio backups are compressed and encrypted before storage.
- Backups expire automatically.
- The Settings audio backup UI can retry or delete saved items.
- Browser fallback storage is used only when the server cannot save the failed audio.

Treat audio backups as sensitive clinical data even when encrypted.
