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

# Synthesize speech from text

> Converts text into spoken audio using text-to-speech synthesis.

## Features
- Multiple voices and languages
- Configurable sample rate (44100, 22050, 16000 Hz)
- Automatic resampling
- Streaming audio output (chunked transfer encoding)

## Sample Rate
The TTS engine outputs audio at 44100 Hz by default. If you specify a different
`sample_rate`, the audio will be automatically resampled to match your request.

## Example Request
```json
{
  "text": "Hello, how are you today?",
  "model": "melo-tts-en",
  "language": "en",
  "voice": "default",
  "sample_rate": 44100
}
```

## Response
The response is binary PCM audio data (raw audio, not WAV format) streamed using HTTP chunked
transfer encoding. To play the audio, you'll need to convert it to WAV format using the
provided `pcm_to_wav.py` script:
```bash
python pcm_to_wav.py speech.pcm speech.wav --rate 44100 --channels 1 --bits 16
```

## Supported Parameters
Check model capabilities via `/tts/models` to see which parameters are supported:
- `gender`: Voice gender (if supported)
- `style`: Speaking style (if supported)
- `sample_rate`: Output sample rate (if supported)
- `parameters`: Additional fine-tuning options




## OpenAPI

````yaml /Ubuntu/ai-workflows/api-specs/audio-analytics/openapi.yaml post /tts/synthesize
openapi: 3.0.3
info:
  title: Audio Analytics API
  version: 1.0.0
  description: >
    REST API providing AI-powered audio processing: speech recognition (ASR),

    text translation (T2T), and speech synthesis (TTS).


    ## Services


    | Service | Endpoint prefix | Description |

    |---------|----------------|-------------|

    | ASR | `/transcriptions/` | Whisper-based speech-to-text (file or live
    WebSocket streaming) |

    | T2T | `/translations/` | Opus/NLLB text translation (batch supported) |

    | TTS | `/tts/` | MeloTTS speech synthesis; returns raw PCM audio |


    ## Audio formats (ASR input)

    - WAV, 16-bit PCM; 16 kHz mono recommended; max 25 MB


    ## TTS output

    - Supported sample rates: 44100, 22050, 16000 Hz (auto-resampled)


    ## WebSocket streaming sequence


    ```

    App                                           Server
     |===POST /transcriptions/create================>|
     |<==200 {session_id, state: asr_initialized}====|
     |
     |===WS /stream=================================>|
     |<==  {state: connection_established}===========|
     |
     |===WS {transcriptions_session_audio} (loop)===>|
     |<===WS {transcript.event,     speech_start}====|
     |<===WS {transcript.text.delta, ...}============|  (zero or more)
     |<===WS {transcript.event,     speech_end}======|
     |<===WS {transcript.text.done,  ...}============|
     |
     |===POST /transcriptions/close=================>|  (after transcript.text.done)
    ```


    ## Authentication

    None required.
  contact:
    name: Qualcomm Support Forums
    url: https://mysupport.qualcomm.com/supportforums/s/
  license:
    name: BSD-3-Clause-Clear
    url: https://opensource.org/licenses/BSD-3-Clause-Clear
servers:
  - url: http://{device-ip}:{device-port}/audio-analytics/v1/api
    description: Audio Analytics API Server
    variables:
      device-ip:
        description: IP address and port of the host device running the Audio Analytics API
        default: localhost
      device-port:
        default: '8085'
security: []
tags:
  - name: Health
    description: Service health and status endpoints
  - name: Transcriptions
    description: Speech-to-text audio transcription (ASR)
  - name: Translations
    description: Text-to-text translation between languages
  - name: TTS
    description: Text-to-speech synthesis
  - name: WebSocket
    description: Real-time streaming communication
paths:
  /tts/synthesize:
    post:
      tags:
        - TTS
      summary: Synthesize speech from text
      description: >
        Converts text into spoken audio using text-to-speech synthesis.


        ## Features

        - Multiple voices and languages

        - Configurable sample rate (44100, 22050, 16000 Hz)

        - Automatic resampling

        - Streaming audio output (chunked transfer encoding)


        ## Sample Rate

        The TTS engine outputs audio at 44100 Hz by default. If you specify a
        different

        `sample_rate`, the audio will be automatically resampled to match your
        request.


        ## Example Request

        ```json

        {
          "text": "Hello, how are you today?",
          "model": "melo-tts-en",
          "language": "en",
          "voice": "default",
          "sample_rate": 44100
        }

        ```


        ## Response

        The response is binary PCM audio data (raw audio, not WAV format)
        streamed using HTTP chunked

        transfer encoding. To play the audio, you'll need to convert it to WAV
        format using the

        provided `pcm_to_wav.py` script:

        ```bash

        python pcm_to_wav.py speech.pcm speech.wav --rate 44100 --channels 1
        --bits 16

        ```


        ## Supported Parameters

        Check model capabilities via `/tts/models` to see which parameters are
        supported:

        - `gender`: Voice gender (if supported)

        - `style`: Speaking style (if supported)

        - `sample_rate`: Output sample rate (if supported)

        - `parameters`: Additional fine-tuning options
      operationId: synthesizeSpeech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SynthesizeRequest'
            example:
              text: Hello, how are you today?
              model: melo-tts-en
              language: en
              voice: default
              sample_rate: 44100
              output_speaker: false
      responses:
        '200':
          description: Speech synthesized successfully
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
                description: >-
                  Raw PCM audio data (16-bit little-endian). Not WAV — convert
                  before playback.
        '400':
          description: Bad request - invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SynthesizeRequest:
      type: object
      description: Text-to-speech synthesis request
      properties:
        text:
          type: string
          description: Text to synthesize into speech
          example: Hello, how are you today?
        model:
          type: string
          description: TTS model ID
          example: melo-tts-en
        language:
          type: string
          description: ISO 639-1 language code
          example: en
        voice:
          type: string
          description: Voice identifier (if model supports multiple voices)
          example: default
        gender:
          type: string
          description: Voice gender preference (if supported by model)
          enum:
            - male
            - female
            - neutral
          example: neutral
        style:
          type: string
          description: Speaking style (if supported by model)
          example: neutral
        sample_rate:
          type: integer
          description: >-
            Output sample rate in Hz (if supported by model). Audio will be
            resampled if different from native rate.
          example: 44100
        parameters:
          type: object
          additionalProperties:
            type: string
          description: Additional synthesis parameters (e.g., speaking_rate, pitch, gain)
          example:
            speaking_rate: '1.0'
            pitch: '1.0'
            gain: '0.0'
        output_speaker:
          type: boolean
          description: Output audio data results to speaker
          example: false
      required:
        - text
        - model
    ErrorResponse:
      type: object
      description: Standard error response structure
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message
              example: Invalid request, missing 'file' parameter
            type:
              type: string
              description: Error type or category
              example: invalid_request_error
            param:
              type: string
              nullable: true
              description: Parameter related to the error (if applicable)
              example: file
            code:
              type: string
              nullable: true
              description: Error code (if applicable)
              example: null
          required:
            - message
            - type
      required:
        - error

````