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

# Text to Speech (Streaming)

> Generates speech from text with one of your voices and streams the audio as it is produced.



## OpenAPI

````yaml post /v2/Speech/Stream
openapi: 3.0.1
info:
  title: NLPearl Client API
  description: A sample API that demonstrates features in the OpenAPI specification
  version: v2
servers:
  - url: https://api.nlpearl.ai
    description: Production Environement
security:
  - bearer_auth: []
  - oauth2_client_credentials: []
tags:
  - name: Pearl
    description: >-
      Manage your Pearls, the AI agents that handle your inbound and outbound
      calls. Create and configure Pearls, retrieve their details and settings,
      run or pause them, list and bulk-export their calls, monitor calls in
      progress, get analytics, and reset a customer's conversation memory.
  - name: Speech
    description: >-
      Turn text into speech with your voices, as a single clip or as a stream,
      and clone new voices from a recording.
paths:
  /v2/Speech/Stream:
    post:
      tags:
        - Speech
      summary: Text to Speech (Streaming)
      description: >-
        Generates speech from text with one of your voices and streams the audio
        as it is produced.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpeechRequestApi'
            example:
              text: Your appointment is confirmed for Thursday at ten.
              voiceId: 1cf704d389adfc067d749a51
              modelId: nlpearl-v2-preview
              pace: medium
              tier: standard
              outputFormat: mp3_44100_128
      responses:
        '200':
          description: The audio, streamed as it is generated.
          headers:
            X-Generation-Id:
              description: The id of this generation.
              schema:
                type: string
            X-Output-Format:
              description: The audio format, for example `mp3_44100_128`.
              schema:
                type: string
            X-Model:
              description: The model used.
              schema:
                type: string
            X-Tier:
              description: The tier you asked for.
              schema:
                type: string
            X-Tier-Charged:
              description: >-
                The tier you were charged for: `priority` only when the request
                went ahead of waiting requests, otherwise `standard`.
              schema:
                type: string
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
            audio/wav:
              schema:
                type: string
                format: binary
            audio/ogg:
              schema:
                type: string
                format: binary
            audio/L16:
              schema:
                type: string
                format: binary
            audio/basic:
              schema:
                type: string
                format: binary
            audio/x-alaw-basic:
              schema:
                type: string
                format: binary
        '400':
          description: '`invalid_request`. The message names the field.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpeechErrorApi'
        '401':
          description: Missing or invalid credentials.
        '402':
          description: '`insufficient_credits` or `debt_limit_reached`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpeechErrorApi'
        '403':
          description: '`insufficient_scope` or `account_suspended`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpeechErrorApi'
        '404':
          description: '`voice_not_found`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpeechErrorApi'
        '429':
          description: '`concurrency_limit_exceeded`.'
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
            X-Concurrency-Limit:
              description: Speech requests your account may have in flight.
              schema:
                type: integer
            X-Concurrency-In-Use:
              description: Speech requests in flight when this one was refused.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpeechErrorApi'
        '503':
          description: '`system_busy` or `account_unverified`.'
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpeechErrorApi'
components:
  schemas:
    SpeechRequestApi:
      required:
        - text
        - voiceId
      type: object
      properties:
        text:
          maxLength: 5000
          minLength: 1
          type: string
          description: The text to speak, in the voice's language.
        voiceId:
          type: string
          description: >-
            The voice to use. List your voices with [Get
            Voices](/api-reference/v2/pearlSettings/get-voices).
        modelId:
          type: string
          enum:
            - nlpearl-v2-preview
          default: nlpearl-v2-preview
          description: The speech model.
        pace:
          type: string
          enum:
            - very_slow
            - slow
            - medium
            - fast
            - very_fast
          default: medium
          description: How fast the voice speaks.
        tier:
          type: string
          enum:
            - standard
            - priority
          default: standard
          description: >-
            Your place in the queue when the service is busy. `priority` goes
            ahead of waiting `standard` requests and is charged at the Priority
            rate only when it did.
        outputFormat:
          type: string
          enum:
            - pcm_8000
            - pcm_16000
            - pcm_22050
            - pcm_24000
            - pcm_44100
            - pcm_48000
            - wav_8000
            - wav_16000
            - wav_22050
            - wav_24000
            - wav_44100
            - wav_48000
            - ulaw_8000
            - alaw_8000
            - mp3_22050_32
            - mp3_44100_32
            - mp3_44100_64
            - mp3_44100_96
            - mp3_44100_128
            - mp3_44100_192
            - opus_48000_32
            - opus_48000_64
            - opus_48000_96
            - opus_48000_128
            - opus_48000_192
          default: mp3_44100_128
          description: >-
            Codec, sample rate and bitrate of the audio, for example
            `mp3_44100_128`, `pcm_16000` or `ulaw_8000`.
      additionalProperties: false
    SpeechErrorApi:
      type: object
      properties:
        code:
          type: string
          description: The error code, for example `voice_not_found`.
        message:
          type: string
          description: What went wrong.
  securitySchemes:
    bearer_auth:
      type: http
      description: >-
        Specify the authorization token.


        For more information, check out the [Authorization
        Guide](/api-reference/authorization).
      scheme: bearer
    oauth2_client_credentials:
      type: oauth2
      description: >-
        OAuth2 client_credentials grant. Use the Id of an OAuth API key as
        `client_id` and its one-time secret as `client_secret`.
      flows:
        clientCredentials:
          tokenUrl: /oauth/token
          scopes:
            pearls:read: List and view Pearls
            pearls:write: >-
              Create and update Pearls (settings, conversation flows, voices);
              implies pearls:read
            pearls:moderate: Run/pause Pearls and reset customer memory; implies pearls:read
            pearls:analytics: Read Pearl analytics; implies pearls:read
            pearls:leads: Manage and read outbound leads; implies pearls:read
            pearls:calls: >-
              Read calls and recordings, make and delete calls; implies
              pearls:read
            account:phone_numbers: >-
              Read account phone numbers and text channels, manage custom VoIP
              numbers, import Twilio numbers and delete phone numbers
            account:users: Read account users
            account:advanced: Manage advanced account settings (blacklist)
            account:billing: Read account information and credit balance
            account:audit_log: Read the audit log
            tts: Synthesise speech and clone voices

````

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