> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tryhamsa.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Stream Speech with Style (v3)

> Streams speech for `text` as raw audio chunks: 16-bit PCM mono at 16 kHz (8 kHz with `sampleRate: "8k"`), or 8 kHz µ-law with `mulaw: true`. The stream has no WAV header: add one to play it as a file, or use [Generate Speech with Style](/api-reference/endpoint/rt-generate-tts-v3). Errors come before any audio. Same as the v1 route, plus the style fields `emotion`, `casual`, `autoEmotion`, `mapFillers`, `useNativeEnglish` and `generationId`. There is no `expressiveness`, and `dialect` also takes `eng` (English).



## OpenAPI

````yaml /api-reference/openapi.json post /v3/realtime/tts-stream
openapi: 3.0.1
info:
  title: Hamsa API
  description: >-
    The Hamsa API: voice agents and their calls, phone numbers, batch calls and
    knowledge bases; speech to text, text to speech, voices and AI content.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tryhamsa.com
security: []
paths:
  /v3/realtime/tts-stream:
    post:
      summary: Stream speech with style
      description: >-
        Streams speech for `text` as raw audio chunks: 16-bit PCM mono at 16 kHz
        (8 kHz with `sampleRate: "8k"`), or 8 kHz µ-law with `mulaw: true`. The
        stream has no WAV header: add one to play it as a file, or use [Generate
        Speech with Style](/api-reference/endpoint/rt-generate-tts-v3). Errors
        come before any audio. Same as the v1 route, plus the style fields
        `emotion`, `casual`, `autoEmotion`, `mapFillers`, `useNativeEnglish` and
        `generationId`. There is no `expressiveness`, and `dialect` also takes
        `eng` (English).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RtTtsV3Request'
            examples:
              style:
                summary: Palestinian, happy and casual
                value:
                  text: أهلاً، كيف بقدر أساعدك اليوم؟
                  speaker: Amjad
                  dialect: pls
                  emotion: happy
                  casual: true
                  autoEmotion: false
                  generationId: reply-7f3a2c
      responses:
        '200':
          description: Audio stream (chunked).
          content:
            audio/wav:
              schema:
                type: string
                format: binary
          headers:
            Transfer-Encoding:
              description: The audio is streamed.
              schema:
                type: string
                example: chunked
        '400':
          description: >-
            Invalid body, for example "The Emotion field's allowed values are:
            neutral, happy, ...!", or `sampleRate` sent with `mulaw: true`. The
            body is the message as plain text.
          content:
            text/plain:
              schema:
                type: string
        '401':
          description: Missing or invalid API key. The body is the message as plain text.
          content:
            text/plain:
              schema:
                type: string
        '402':
          description: Insufficient balance. The body is the message as plain text.
          content:
            text/plain:
              schema:
                type: string
        '403':
          description: >-
            The API key does not have the `realtime:create` scope, or the
            request origin is not allowed for this key. The body is the message
            as plain text.
          content:
            text/plain:
              schema:
                type: string
        '404':
          description: >-
            Voice not found or not available for this API key. The body is the
            message as plain text.
          content:
            text/plain:
              schema:
                type: string
        '422':
          description: >-
            A value the voice model can't use; `message` gives the reason. The
            body is the message as plain text.
          content:
            text/plain:
              schema:
                type: string
        '429':
          description: >-
            Too many requests: over 100 realtime requests a minute with this key
            ("Rate limit exceeded for this API key"), or too many requests from
            your IP address. Wait for the `Retry-After` seconds when it is sent,
            then retry.
        '500':
          description: Server Side Error. The body is the message as plain text.
          content:
            text/plain:
              schema:
                type: string
        '503':
          description: >-
            Service is busy: retry shortly. The body is the message as plain
            text.
          content:
            text/plain:
              schema:
                type: string
      security:
        - ApiKeyAuth: []
components:
  schemas:
    RtTtsV3Request:
      type: object
      required:
        - text
        - speaker
      properties:
        text:
          type: string
          minLength: 1
          maxLength: 2000
          example: أهلاً، كيف بقدر أساعدك اليوم؟
          description: >-
            Text to speak, 1 to 2,000 characters. May contain `<pause_short>`
            and `<pause_long>`; a line break counts as a short pause. Numbers,
            dates and units are read out in words.
        speaker:
          type: string
          example: Amjad
          description: >-
            The voice: a voice name, or the ID of one of your cloned voices
            (preload it first with the [Preload Cloned Voice
            endpoint](/api-reference/endpoint/preload-cloned-tts-voice)). An
            unknown voice, or a voice ID that isn't yours, gets 404.
        dialect:
          type: string
          nullable: true
          enum:
            - uae
            - ksa
            - kuw
            - qat
            - bah
            - oma
            - egy
            - jor
            - pls
            - leb
            - syr
            - irq
            - msa
            - eng
          example: pls
          description: >-
            Overrides the voice's dialect. Leave it out (or send `null`) for the
            voice's own dialect. `uae` Emirati, `ksa` Saudi, `kuw` Kuwaiti,
            `qat` Qatari, `bah` Bahraini, `oma` Omani, `egy` Egyptian, `jor`
            Jordanian, `pls` Palestinian, `leb` Lebanese, `syr` Syrian, `irq`
            Iraqi, `msa` Modern Standard Arabic, `eng` English.
        languageId:
          type: string
          default: ar
          enum:
            - ar
            - en
          description: 'Language of the text: `ar` or `en`.'
        mulaw:
          type: boolean
          description: '`true`: 8 kHz µ-law (phone audio). `false`: 16-bit PCM.'
          example: false
          default: false
        sampleRate:
          type: string
          enum:
            - 8k
            - 16k
          description: >-
            PCM output rate: `8k` or `16k`. Not allowed with `mulaw: true`
            (mu-law is always 8 kHz).
          default: 16k
          example: 16k
        model:
          type: string
          enum:
            - default
            - hamsa-tts-en
          default: default
          description: >-
            `default`, or `hamsa-tts-en` for the English model. Any other value
            uses `default`.
        generationId:
          type: string
          nullable: true
          minLength: 1
          maxLength: 128
          example: reply-7f3a2c
          description: >-
            Send the same ID with every piece of one reply, so voice and tone
            stay continuous across them. Make a new one for each reply. 1 to 128
            characters.
        emotion:
          type: string
          nullable: true
          enum:
            - neutral
            - happy
            - excited
            - calm
            - sympathetic
            - sad
            - frustrated
            - angry
            - surprised
            - hesitant
            - tired
            - whispering
          example: happy
          description: >-
            Speaking style for this request: `neutral`, `happy`, `excited`,
            `calm`, `sympathetic`, `sad`, `frustrated`, `angry`, `surprised`,
            `hesitant`, `tired` or `whispering`. Leave it out (or send `null`)
            for `neutral`.
        casual:
          type: boolean
          nullable: true
          example: true
          description: >-
            Relaxed, spontaneous speech with natural hesitations. Leave it out
            (or send `null`) for `false`.
        autoEmotion:
          type: boolean
          nullable: true
          example: false
          description: >-
            Picks an emotion from the text (an apology sounds sympathetic,
            laughter happy) and turns `casual` off for that request. Set `false`
            so your `emotion` and `casual` are always used. Leave it out (or
            send `null`) for `true`.
        mapFillers:
          type: boolean
          nullable: true
          example: true
          description: >-
            Turns written fillers into real filler sounds (امم or "Hmm" is said
            as "umm"). Leave it out (or send `null`) for `true`.
        useNativeEnglish:
          type: boolean
          nullable: true
          example: false
          description: >-
            `false`: English words are said with the voice's Arabic accent.
            `true`: English parts get a native English pronunciation. Leave it
            out (or send `null`) for `false`.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Pass the API key in the Authorization header, You need to put Token
        keyword before the API key. e.g. 'Authorization: Token <api-key>'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.