asyncapi: 3.0.0
info:
  title: SLNG Gateway API - Gradium TTS
  version: 0.1.0
  description: Real-time multilingual text-to-speech with streaming WebSocket and one-shot HTTP synthesis
  contact:
    name: SLNG Support
    url: https://slng.ai
    email: support@slng.ai
  license:
    name: Proprietary
  tags: []
servers:
  production:
    host: api.slng.ai
    protocol: wss
    description: Production
    security:
      - $ref: "#/components/securitySchemes/bearer"
  staging:
    host: stageapi.slng.ai
    protocol: wss
    description: Staging
    security:
      - $ref: "#/components/securitySchemes/bearer"
channels:
  /v1/tts/gradium/tts:default:
    address: /v1/tts/gradium/tts:default
    title: Gradium TTS default
    summary: Real-time multilingual text-to-speech with streaming WebSocket and one-shot HTTP synthesis
    description: Real-time multilingual text-to-speech with streaming WebSocket and one-shot HTTP synthesis
    tags:
      - name: Gradium TTS
    servers:
      - $ref: "#/servers/production"
      - $ref: "#/servers/staging"
    messages:
      GradiumTtsDefaultSetup:
        $ref: "#/components/messages/GradiumTtsDefaultSetup"
      GradiumTtsDefaultText:
        $ref: "#/components/messages/GradiumTtsDefaultText"
      GradiumTtsDefaultEndOfStreamRequest:
        $ref: "#/components/messages/GradiumTtsDefaultEndOfStreamRequest"
      GradiumTtsDefaultAudio:
        $ref: "#/components/messages/GradiumTtsDefaultAudio"
      GradiumTtsDefaultEndOfStreamComplete:
        $ref: "#/components/messages/GradiumTtsDefaultEndOfStreamComplete"
      GradiumTtsDefaultError:
        $ref: "#/components/messages/GradiumTtsDefaultError"
    bindings:
      ws:
        method: GET
        headers:
          $ref: "#/components/schemas/WebsocketHeadersGradium"
operations:
  ttsGradiumTtsDefaultReceiveSetup:
    action: receive
    channel:
      $ref: "#/channels/~1v1~1tts~1gradium~1tts:default"
    summary: Send Setup on Gradium Gradium TTS default
    description: Initialize the synthesis stream. Must be the first message.
    messages:
      - $ref: "#/channels/~1v1~1tts~1gradium~1tts:default/messages/GradiumTtsDefaultSetup"
    tags: []
  ttsGradiumTtsDefaultReceiveText:
    action: receive
    channel:
      $ref: "#/channels/~1v1~1tts~1gradium~1tts:default"
    summary: Send Text on Gradium Gradium TTS default
    description: A chunk of text to synthesize.
    messages:
      - $ref: "#/channels/~1v1~1tts~1gradium~1tts:default/messages/GradiumTtsDefaultText"
    tags: []
  ttsGradiumTtsDefaultReceiveEndOfStream:
    action: receive
    channel:
      $ref: "#/channels/~1v1~1tts~1gradium~1tts:default"
    summary: Send EndOfStream on Gradium Gradium TTS default
    description: Signal that no more text will be sent.
    messages:
      - $ref: "#/channels/~1v1~1tts~1gradium~1tts:default/messages/GradiumTtsDefaultEndOfStreamRequest"
    tags: []
  ttsGradiumTtsDefaultSendAudio:
    action: send
    channel:
      $ref: "#/channels/~1v1~1tts~1gradium~1tts:default"
    summary: Receive Audio on Gradium Gradium TTS default
    description: A chunk of base64-encoded synthesized audio.
    messages:
      - $ref: "#/channels/~1v1~1tts~1gradium~1tts:default/messages/GradiumTtsDefaultAudio"
    tags: []
  ttsGradiumTtsDefaultSendEndOfStream:
    action: send
    channel:
      $ref: "#/channels/~1v1~1tts~1gradium~1tts:default"
    summary: Receive EndOfStream on Gradium Gradium TTS default
    description: Synthesis for the request is complete.
    messages:
      - $ref: "#/channels/~1v1~1tts~1gradium~1tts:default/messages/GradiumTtsDefaultEndOfStreamComplete"
    tags: []
  ttsGradiumTtsDefaultSendError:
    action: send
    channel:
      $ref: "#/channels/~1v1~1tts~1gradium~1tts:default"
    summary: Receive Error on Gradium Gradium TTS default
    description: Terminal error.
    messages:
      - $ref: "#/channels/~1v1~1tts~1gradium~1tts:default/messages/GradiumTtsDefaultError"
    tags: []
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
  schemas:
    WebsocketHeadersGradium:
      type: object
      properties:
        X-World-Part-Override:
          type: string
          description: Override target world part. Auto-selected if not provided.
  messages:
    GradiumTtsDefaultSetup:
      name: GradiumTtsDefaultSetup
      title: Setup
      summary: Initialize the synthesis stream. Must be the first message.
      contentType: application/json
      payload:
        type: object
        description: Initialize the synthesis stream. Must be the first message.
        required:
          - type
          - voice_id
        properties:
          type:
            const: setup
          voice_id:
            type: string
          model_name:
            type: string
            default: default
          output_format:
            type: string
            enum:
              - wav
              - pcm
              - pcm_8000
              - pcm_16000
              - pcm_24000
              - opus
              - ulaw_8000
              - alaw_8000
          json_config:
            type: object
            properties:
              language:
                type: string
              temperature:
                type: number
          close_ws_on_eos:
            type: boolean
      examples:
        - name: setupExample
          summary: Setup message
          payload:
            type: setup
            voice_id: <voice_id>
    GradiumTtsDefaultText:
      name: GradiumTtsDefaultText
      title: Text
      summary: A chunk of text to synthesize.
      contentType: application/json
      payload:
        type: object
        description: A chunk of text to synthesize.
        required:
          - type
          - text
        properties:
          type:
            const: text
          text:
            type: string
      examples:
        - name: textExample
          summary: Text message
          payload:
            type: text
            text: Hello world.
    GradiumTtsDefaultEndOfStreamRequest:
      name: GradiumTtsDefaultEndOfStreamRequest
      title: EndOfStream
      summary: Signal that no more text will be sent.
      contentType: application/json
      payload:
        type: object
        description: Signal that no more text will be sent.
        required:
          - type
        properties:
          type:
            const: end_of_stream
      examples:
        - name: endOfStreamExample
          summary: EndOfStream message
          payload:
            type: end_of_stream
    GradiumTtsDefaultAudio:
      name: GradiumTtsDefaultAudio
      title: Audio
      summary: A chunk of base64-encoded synthesized audio.
      contentType: application/json
      payload:
        type: object
        description: A chunk of base64-encoded synthesized audio.
        required:
          - type
          - audio
        properties:
          type:
            const: audio
          audio:
            type: string
            format: base64
          start_s:
            type: number
          stop_s:
            type: number
          stream_id:
            type: integer
      examples:
        - name: audioExample
          summary: Audio message
          payload:
            type: audio
            audio: <audio>
    GradiumTtsDefaultEndOfStreamComplete:
      name: GradiumTtsDefaultEndOfStreamComplete
      title: EndOfStream
      summary: Synthesis for the request is complete.
      contentType: application/json
      payload:
        type: object
        description: Synthesis for the request is complete.
        required:
          - type
        properties:
          type:
            const: end_of_stream
      examples:
        - name: endOfStreamExample
          summary: EndOfStream message
          payload:
            type: end_of_stream
    GradiumTtsDefaultError:
      name: GradiumTtsDefaultError
      title: Error
      summary: Terminal error.
      contentType: application/json
      payload:
        type: object
        description: Terminal error.
        required:
          - type
        properties:
          type:
            const: error
          message:
            type: string
          code:
            type: integer
      examples:
        - name: errorExample
          summary: Error message
          payload:
            type: error
