Overview
HAMS runs two speech models built for Arabic, including speech that switches between Arabic and English mid-sentence. Both are exposed as streaming WebSocket APIs so that audio and text flow in real time, with one persistent connection per stream.
What a client needs
Any server-side WebSocket client works. It must be able to:
- Set a custom
Authorizationheader on the WebSocket handshake. - Send and receive binary messages, which carry the PCM audio.
- Send and receive text messages, which carry JSON configuration, prompts, metadata and results.
- Keep one socket open for the whole session or stream, rather than reconnecting per message.
The API key must stay on a trusted server. Do not put it in browser code, mobile applications, URLs or client-side logs. If your framework cannot attach headers to a WebSocket connection, connect from a server-side service that can.
Audio in and out
Both APIs work with raw, headerless PCM: signed 16-bit little-endian samples, mono. Speech-to-text expects 16,000 Hz; text-to-speech returns 24,000 Hz. Decode and resample other formats before sending, and write the received bytes straight to a PCM sink or wrap them in a container yourself.