> ## 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.

# Generate Speech with Style (v3)

> Generates a WAV file from `text`. 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
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:
    post:
      summary: Generate speech with style (file)
      description: >-
        Generates a WAV file from `text`. 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: The whole WAV file.
          content:
            audio/wav:
              schema:
                type: string
                format: binary
        '400':
          description: >-
            Invalid body, for example "The Emotion field's allowed values are:
            neutral, happy, ...!", or `sampleRate` sent with `mulaw: true`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '402':
          description: Insufficient balance.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '403':
          description: >-
            The API key does not have the `realtime:create` scope, or the
            request origin is not allowed for this key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '404':
          description: Voice not found or not available for this API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '422':
          description: A value the voice model can't use; `message` gives the reason.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '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
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '503':
          description: 'Service is busy: retry shortly.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
      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`.
    ErrorSchema:
      type: object
      properties:
        code:
          type: integer
          description: >-
            Service error code: the HTTP status with a service prefix (for
            example `8404`). Missing when the service has no code for that
            status.
          example: 8404
        message:
          type: string
          description: >-
            What went wrong. Some services (calls and recordings) put the error
            key here, for example `CallNotFoundOrUnavailable`, and send no
            `messageKey`.
          example: Policy not found!
        messageKey:
          type: string
          description: >-
            Stable key for the error, safe to match on in code. Not returned by
            every service.
          example: PolicyNotFound
        params:
          type: object
          additionalProperties: true
          description: >-
            Details for some errors (for example `reason`). Not returned by
            every service.
          example:
            reason: NO_DRAFT
  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.