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

# 根据文本生成 Runway 语音

> 使用 Runway API 通过预设声音或参考音频将文本转换为语音。

使用 `POST /runwayml/v1/text_to_speech` 根据文本创建语音任务。
使用 Bearer 身份验证发送您的 CometAPI API 密钥和 JSON 请求正文。

## 选择模型和声音

每个请求都需要 `model` 和 `promptText`。`voice` 字段对于
`eleven_multilingual_v2`、`eleven_v3` 和 `eleven_v4` 为必填项，对于 `seed_audio` 为可选项。

| 模型 ID | 文本限制 | 声音配置 |
| - | - | - |
| `eleven_multilingual_v2` | 1000 个 UTF-16 代码单元 | `type: runway-preset` 以及一个 `presetId`，例如 `Maya` |
| `eleven_v3` | 5000 个字符 | `type: runway-preset` 以及一个 `presetId`，例如 `Maya` |
| `eleven_v4` | 非空文本 | `type: runway-preset` 以及一个 `presetId`，例如 `Maya` |
| `seed_audio` | 2048 个字符 | 省略 `voice` 以使用默认声音，或使用 `type: reference-audio` 和一个 `audioUri` |

对于预设声音，请从请求架构中选择 `presetId`。对于 `seed_audio`，
请将示例 `audioUri` 替换为可访问的语音参考 HTTPS URL。

## 调整语音表现力

使用 `eleven_v3` 时，`promptText` 可包含诸如 `[whispers]`
或 `[laughs]` 等表现力标签。该模型还接受以下控制项：

| 字段 | 取值 | 含义 |
| - | - | - |
| `stability` | 0 到 1 之间的数字 | 较低的非零值可带来更多表现力；较高的值则更稳定。 |
| `similarityBoost` | 0 到 1 之间的数字 | 较高的值会更紧密地遵循所选声音。 |
| `style` | 0 到 1 之间的数字 | 较高的值会更突出声音风格。 |
| `speed` | 0.7 到 1.2 之间的数字 | `1` 表示正常语速。 |
| `useSpeakerBoost` | `true` | 请求与所选声音更高的相似度。 |
| `languageCode` | ISO 639-1 语言代码 | 引导发音和文本规范化。 |
| `applyTextNormalization` | `auto`, `on`, `off` | 控制数字等文本如何转换为口语词汇。 |
| `seed` | 1 到 4294967295 之间的整数 | 设置采样种子。 |

对于 `stability`、`similarityBoost` 和 `style`，值为 `0` 时使用模型
默认值，省略该字段时也是如此。`useSpeakerBoost: false` 也使用模型
默认值。要设置采样种子，请使用正整数；`seed: 0` 会选择一个种子
自动生成。

## 调整 Eleven v4 语音

使用 `eleven_v4` 时，`promptText` 支持诸如 `[laughs]`、
`[whispers]`以及 `[pause]` 等表现力标签。请使用以下可选控制项：

| 字段 | 取值 | 含义 |
| - | - | - |
| `stability` | 0 到 1 之间的数字 | 较低的值允许更广的情感范围；较高的值则更稳定。 |
| `similarityBoost` | 0 到 1 之间的数字 | 设置输出与所选声音的贴合程度。 |
| `style` | 0 到 1 之间的数字 | 较高的值会增强说话者风格。 |
| `speed` | 0.7 到 1.2 之间的数字 | 低于 1 的值会减慢语速；高于 1 的值会加快语速。 |
| `useSpeakerBoost` | `true` 或 `false` | 当设置为 `true` 时，可增强与所选声音的相似度。 |
| `languageCode` | 2–16 个字符 | 强制指定发音，例如 `en` 或 `pt-BR`。 |
| `previousText` | 字符串 | 从本次请求之前生成的文本继续生成语音。 |
| `nextText` | 字符串 | 将语音引导至本次请求之后生成的文本。 |
| `seed` | 0 到 4294967295 之间的整数 | 选择一个种子以获得更一致的输出。 |

`eleven_v4` 不使用 `applyTextNormalization`。`previousText` 和
`nextText` 字段在生成相邻片段并希望
模型保持过渡连贯时非常有用。

## 调整语音速度和格式

使用 `seed_audio` 时，将 `speechRate` 和 `loudnessRate` 设置为 -50 到 100，或
`pitchRate` 设置为 -12 到 12 个半音。这些控制项接受整数；省略
或使用 `0` 可保留正常值。

将 `sampleRate` 设置为 `8000`、`16000`、`24000`、`32000`、`44100` 或 `48000` Hz。
将 `outputFormat` 设置为 `wav`、`mp3` 或 `ogg_opus`。不要包含 `duration`，
`referenceAudios`，也不要在此端点中使用 `seed_audio` 控制 Eleven v3。

## 获取结果

保存返回的 `id`，然后使用 [获取 Runway 任务](https://apidoc.cometapi.com/zh-Hans/api/video/runway/official-format/runway-to-get-task-details.md)
以获取任务状态。当 `status` 为 `SUCCEEDED` 时，读取其中的音频 URL
`output`。如果任务失败，请检查 `failure` 和 `failureCode`。


## OpenAPI

````yaml api/openapi/video/runway/official-format/post-generate-speech-from-text.openapi.json POST /runwayml/v1/text_to_speech
openapi: 3.1.0
info:
  title: Generate Runway speech from text API
  version: 1.0.0
  description: >-
    Convert text into speech with a preset voice or reference audio using the
    Runway API.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /runwayml/v1/text_to_speech:
    post:
      summary: Generate Runway speech from text
      description: >-
        Convert text into speech with a preset voice or reference audio using
        the Runway API. Save the returned id and retrieve the task to obtain its
        output.
      operationId: runway_text_to_speech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - title: eleven_multilingual_v2
                  type: object
                  properties:
                    model:
                      type: string
                      const: eleven_multilingual_v2
                      enum:
                        - eleven_multilingual_v2
                      description: Model ID for this request.
                    promptText:
                      description: Text to speak, from 1 to 1000 UTF-16 code units.
                      type: string
                      minLength: 1
                      maxLength: 1000
                    voice:
                      description: The voice to use for the generated speech.
                      oneOf:
                        - title: RunwayPresetVoice
                          description: A voice preset from the RunwayML API.
                          type: object
                          properties:
                            type:
                              type: string
                              const: runway-preset
                              enum:
                                - runway-preset
                              description: Input type. Use runway-preset.
                            presetId:
                              description: >-
                                The preset voice ID to use for the generated
                                speech.
                              type: string
                              enum:
                                - Maya
                                - Arjun
                                - Serene
                                - Bernard
                                - Billy
                                - Mark
                                - Clint
                                - Mabel
                                - Chad
                                - Leslie
                                - Eleanor
                                - Elias
                                - Elliot
                                - Grungle
                                - Brodie
                                - Sandra
                                - Kirk
                                - Kylie
                                - Lara
                                - Lisa
                                - Malachi
                                - Marlene
                                - Martin
                                - Miriam
                                - Monster
                                - Paula
                                - Pip
                                - Rusty
                                - Ragnar
                                - Xylar
                                - Maggie
                                - Jack
                                - Katie
                                - Noah
                                - James
                                - Rina
                                - Ella
                                - Mariah
                                - Frank
                                - Claudia
                                - Niki
                                - Vincent
                                - Kendrick
                                - Myrna
                                - Tom
                                - Wanda
                                - Benjamin
                                - Kiana
                                - Rachel
                          required:
                            - type
                            - presetId
                          additionalProperties: false
                      discriminator:
                        propertyName: type
                  required:
                    - promptText
                    - voice
                    - model
                  additionalProperties: false
                  description: Request settings for eleven_multilingual_v2.
                  default:
                    model: eleven_multilingual_v2
                    promptText: Welcome to our audio guide. Let us begin the tour.
                    voice:
                      type: runway-preset
                      presetId: Maya
                - title: eleven_v3
                  type: object
                  properties:
                    model:
                      type: string
                      const: eleven_v3
                      enum:
                        - eleven_v3
                      description: Model ID for this request.
                    promptText:
                      description: >-
                        The text to convert to speech. You can include
                        expressive audio tags like [laughs] or [whispers] in the
                        script.
                      type: string
                      minLength: 1
                      maxLength: 5000
                    voice:
                      description: The voice to use for the generated speech.
                      oneOf:
                        - title: RunwayPresetVoice
                          description: A voice preset from the RunwayML API.
                          type: object
                          properties:
                            type:
                              type: string
                              const: runway-preset
                              enum:
                                - runway-preset
                              description: Input type. Use runway-preset.
                            presetId:
                              description: >-
                                The preset voice ID to use for the generated
                                speech.
                              type: string
                              enum:
                                - Maya
                                - Arjun
                                - Serene
                                - Bernard
                                - Billy
                                - Mark
                                - Clint
                                - Mabel
                                - Chad
                                - Leslie
                                - Eleanor
                                - Elias
                                - Elliot
                                - Grungle
                                - Brodie
                                - Sandra
                                - Kirk
                                - Kylie
                                - Lara
                                - Lisa
                                - Malachi
                                - Marlene
                                - Martin
                                - Miriam
                                - Monster
                                - Paula
                                - Pip
                                - Rusty
                                - Ragnar
                                - Xylar
                                - Maggie
                                - Jack
                                - Katie
                                - Noah
                                - James
                                - Rina
                                - Ella
                                - Mariah
                                - Frank
                                - Claudia
                                - Niki
                                - Vincent
                                - Kendrick
                                - Myrna
                                - Tom
                                - Wanda
                                - Benjamin
                                - Kiana
                                - Rachel
                          required:
                            - type
                            - presetId
                          additionalProperties: false
                      discriminator:
                        propertyName: type
                    stability:
                      description: >-
                        Voice stability from 0 to 1. Lower nonzero values allow
                        more expression; higher values are steadier. Omit or use
                        0 for the model default.
                      type: number
                      minimum: 0
                      maximum: 1
                    similarityBoost:
                      description: >-
                        Voice similarity from 0 to 1. Higher values follow the
                        selected voice more closely. Omit or use 0 for the model
                        default.
                      type: number
                      minimum: 0
                      maximum: 1
                    style:
                      description: >-
                        Style intensity from 0 to 1. Higher values emphasize the
                        selected voice style. Omit or use 0 for the model
                        default.
                      type: number
                      minimum: 0
                      maximum: 1
                    speed:
                      description: >-
                        Speech speed multiplier from 0.7 to 1.2. A value of 1
                        uses normal speed.
                      type: number
                      minimum: 0.7
                      maximum: 1.2
                    useSpeakerBoost:
                      description: >-
                        Set true to request greater similarity to the selected
                        voice. Omit or use false for the model default.
                      type: boolean
                    languageCode:
                      description: >-
                        ISO 639-1 language code to enforce pronunciation and
                        normalization.
                      type: string
                      minLength: 2
                      maxLength: 5
                    applyTextNormalization:
                      description: >-
                        How to normalize spoken text, such as reading numbers as
                        words: auto, on, or off.
                      type: string
                      enum:
                        - auto
                        - 'on'
                        - 'off'
                    seed:
                      description: >-
                        Sampling seed from 1 to 4294967295. Omit or use 0 for an
                        automatically chosen seed.
                      type: integer
                      minimum: 0
                      maximum: 4294967295
                  required:
                    - promptText
                    - voice
                    - model
                  additionalProperties: false
                  description: Request settings for eleven_v3.
                  default:
                    model: eleven_v3
                    promptText: '[whispers] The adventure begins at sunrise.'
                    voice:
                      type: runway-preset
                      presetId: Maya
                    stability: 0.5
                    speed: 1
                - title: eleven_v4
                  type: object
                  properties:
                    model:
                      type: string
                      const: eleven_v4
                      enum:
                        - eleven_v4
                      description: Model ID for this request.
                    promptText:
                      description: >-
                        The text to convert to speech. You can include
                        expressive audio tags like [laughs], [whispers], or
                        [pause] in the script.
                      type: string
                      minLength: 1
                    voice:
                      description: The voice to use for the generated speech.
                      oneOf:
                        - title: RunwayPresetVoice
                          description: A voice preset from the RunwayML API.
                          type: object
                          properties:
                            type:
                              type: string
                              const: runway-preset
                              enum:
                                - runway-preset
                              description: Input type. Use runway-preset.
                            presetId:
                              description: >-
                                The preset voice ID to use for the generated
                                speech.
                              type: string
                              enum:
                                - Maya
                                - Arjun
                                - Serene
                                - Bernard
                                - Billy
                                - Mark
                                - Clint
                                - Mabel
                                - Chad
                                - Leslie
                                - Eleanor
                                - Elias
                                - Elliot
                                - Grungle
                                - Brodie
                                - Sandra
                                - Kirk
                                - Kylie
                                - Lara
                                - Lisa
                                - Malachi
                                - Marlene
                                - Martin
                                - Miriam
                                - Monster
                                - Paula
                                - Pip
                                - Rusty
                                - Ragnar
                                - Xylar
                                - Maggie
                                - Jack
                                - Katie
                                - Noah
                                - James
                                - Rina
                                - Ella
                                - Mariah
                                - Frank
                                - Claudia
                                - Niki
                                - Vincent
                                - Kendrick
                                - Myrna
                                - Tom
                                - Wanda
                                - Benjamin
                                - Kiana
                                - Rachel
                          required:
                            - type
                            - presetId
                          additionalProperties: false
                      discriminator:
                        propertyName: type
                    stability:
                      description: >-
                        Voice stability from 0 to 1. Lower values allow broader
                        emotional range; higher values are steadier.
                      type: number
                      minimum: 0
                      maximum: 1
                    similarityBoost:
                      description: >-
                        How closely the output tracks the selected voice, from 0
                        to 1.
                      type: number
                      minimum: 0
                      maximum: 1
                    style:
                      description: >-
                        Style exaggeration from 0 to 1. Higher values amplify
                        the speaker style.
                      type: number
                      minimum: 0
                      maximum: 1
                    speed:
                      description: >-
                        Speech speed multiplier from 0.7 to 1.2. Values below 1
                        slow the speech down, and values above 1 speed it up.
                      type: number
                      minimum: 0.7
                      maximum: 1.2
                    useSpeakerBoost:
                      description: >-
                        Set true to boost similarity to the selected voice at a
                        small latency cost.
                      type: boolean
                    languageCode:
                      description: >-
                        Language code from 2 to 16 characters to enforce
                        pronunciation, such as en or pt-BR.
                      type: string
                      minLength: 2
                      maxLength: 16
                    seed:
                      description: >-
                        Optional seed from 0 to 4294967295 for more consistent
                        output.
                      type: integer
                      minimum: 0
                      maximum: 4294967295
                    previousText:
                      description: >-
                        Text that comes before this request, so speech can
                        continue from an earlier generation.
                      type: string
                    nextText:
                      description: >-
                        Text that comes after this request, so speech can lead
                        into a later generation.
                      type: string
                  required:
                    - promptText
                    - voice
                    - model
                  additionalProperties: false
                  description: Request settings for eleven_v4.
                  default:
                    model: eleven_v4
                    promptText: '[pause] The museum opens at nine.'
                    voice:
                      type: runway-preset
                      presetId: Maya
                    stability: 0.5
                    speed: 1
                    languageCode: en
                    previousText: The guide takes a breath.
                    nextText: Visitors enter through the west door.
                - title: seed_audio
                  type: object
                  properties:
                    model:
                      type: string
                      const: seed_audio
                      enum:
                        - seed_audio
                      description: Model ID for this request.
                    promptText:
                      description: Text to speak.
                      type: string
                      minLength: 1
                      maxLength: 2048
                    voice:
                      description: >-
                        Optional reference audio that supplies the speaking
                        voice. Omit this field to use a default voice.
                      title: SeedReferenceVoice
                      type: object
                      properties:
                        type:
                          type: string
                          const: reference-audio
                          enum:
                            - reference-audio
                          description: Input type. Use reference-audio.
                        audioUri:
                          description: >-
                            Audio input as an accessible HTTPS URL or base64
                            data URI.
                          anyOf:
                            - description: Accessible HTTPS URL of the audio file.
                              type: string
                              minLength: 13
                              maxLength: 2048
                              pattern: ^https:\/\/.*
                            - description: Base64 audio data URI, up to 5 MB.
                              type: string
                              minLength: 13
                              maxLength: 5242880
                              pattern: ^data:audio\/.*
                      required:
                        - type
                        - audioUri
                      additionalProperties: false
                    speechRate:
                      description: >-
                        Relative speech speed: negative values slow speech,
                        positive values speed it up. Omit or use 0 for normal
                        speed.
                      type: integer
                      minimum: -50
                      maximum: 100
                    loudnessRate:
                      description: >-
                        Relative loudness: negative values reduce volume,
                        positive values increase it. Omit or use 0 for normal
                        loudness.
                      type: integer
                      minimum: -50
                      maximum: 100
                    pitchRate:
                      description: >-
                        Pitch shift in semitones: negative values lower pitch,
                        positive values raise it. Omit or use 0 for unchanged
                        pitch.
                      type: integer
                      minimum: -12
                      maximum: 12
                    sampleRate:
                      description: Output sample rate in Hz.
                      type: integer
                      enum:
                        - 8000
                        - 16000
                        - 24000
                        - 32000
                        - 44100
                        - 48000
                    outputFormat:
                      description: Output audio container/format.
                      type: string
                      enum:
                        - wav
                        - mp3
                        - ogg_opus
                  required:
                    - promptText
                    - model
                  additionalProperties: false
                  description: Request settings for seed_audio.
                  default:
                    model: seed_audio
                    promptText: Welcome to our audio guide. Let us begin the tour.
                    voice:
                      type: reference-audio
                      audioUri: https://your-audio-host/voice-reference.mp3
                    sampleRate: 44100
                    outputFormat: mp3
              discriminator:
                propertyName: model
              default:
                model: eleven_multilingual_v2
                promptText: Welcome to our audio guide. Let us begin the tour.
                voice:
                  type: runway-preset
                  presetId: Maya
            examples:
              eleven_multilingual_v2:
                summary: eleven_multilingual_v2
                value:
                  model: eleven_multilingual_v2
                  promptText: Welcome to our audio guide. Let us begin the tour.
                  voice:
                    type: runway-preset
                    presetId: Maya
              eleven_v3:
                summary: eleven_v3
                value:
                  model: eleven_v3
                  promptText: '[whispers] The adventure begins at sunrise.'
                  voice:
                    type: runway-preset
                    presetId: Maya
                  stability: 0.5
                  speed: 1
              eleven_v4:
                summary: eleven_v4
                value:
                  model: eleven_v4
                  promptText: '[pause] The museum opens at nine.'
                  voice:
                    type: runway-preset
                    presetId: Maya
                  stability: 0.5
                  speed: 1
                  languageCode: en
                  previousText: The guide takes a breath.
                  nextText: Visitors enter through the west door.
              seed_audio:
                summary: seed_audio
                value:
                  model: seed_audio
                  promptText: Welcome to our audio guide. Let us begin the tour.
                  voice:
                    type: reference-audio
                    audioUri: https://your-audio-host/voice-reference.mp3
                  sampleRate: 44100
                  outputFormat: mp3
      responses:
        '200':
          description: Task created. Save the returned id to retrieve task status.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Task ID for GET /runwayml/v1/tasks/{id}.
                  status:
                    type: string
                    description: Task state, when returned.
                  createdAt:
                    type: string
                    description: Task submission timestamp, when returned.
                    format: date-time
                  output:
                    type: array
                    description: Result URLs, when returned.
                    items:
                      type: string
                      format: uri
                  failure:
                    type: string
                    description: Failure explanation, when returned.
                  failureCode:
                    type: string
                    description: Machine-readable failure code, when returned.
                  estimatedCost:
                    type: object
                    description: Task estimate metadata, when returned.
                    properties:
                      credits:
                        type: integer
                        description: Credit value reported with the task.
                    required:
                      - credits
                    additionalProperties: false
                  cost:
                    type: object
                    description: Task cost metadata, when returned.
                    properties:
                      credits:
                        type: integer
                        description: Credit value reported with the task.
                    required:
                      - credits
                    additionalProperties: false
                required:
                  - id
                additionalProperties: false
              example:
                id: 123e4567-e89b-42d3-a456-426614174000
        '400':
          description: Invalid request or unavailable task ID.
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    description: Task request error.
                    properties:
                      code:
                        type:
                          - string
                          - integer
                        description: Machine-readable task error code.
                      message:
                        type: string
                        description: Error explanation.
                      data:
                        description: Additional error details, when returned.
                    required:
                      - code
                      - message
                    additionalProperties: true
                  - type: object
                    description: Request authentication or validation error.
                    properties:
                      error:
                        type: object
                        description: Error details.
                        properties:
                          message:
                            type: string
                            description: Error explanation.
                          type:
                            type: string
                            description: Error category.
                          code:
                            type:
                              - string
                              - integer
                              - 'null'
                            description: Error code, when returned.
                        required:
                          - message
                        additionalProperties: true
                    required:
                      - error
                    additionalProperties: true
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                type: object
                description: Request authentication or validation error.
                properties:
                  error:
                    type: object
                    description: Error details.
                    properties:
                      message:
                        type: string
                        description: Error explanation.
                      type:
                        type: string
                        description: Error category.
                      code:
                        type:
                          - string
                          - integer
                          - 'null'
                        description: Error code, when returned.
                    required:
                      - message
                    additionalProperties: true
                required:
                  - error
                additionalProperties: true
      x-codeSamples:
        - lang: Shell
          label: eleven_multilingual_v2
          source: |
            curl https://api.cometapi.com/runwayml/v1/text_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "eleven_multilingual_v2",
              "promptText": "Welcome to our audio guide. Let us begin the tour.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              }
            }'
        - lang: Python
          label: eleven_multilingual_v2
          source: |
            import os
            import requests

            payload = {   'model': 'eleven_multilingual_v2',
                'promptText': 'Welcome to our audio guide. Let us begin the tour.',
                'voice': {'type': 'runway-preset', 'presetId': 'Maya'}}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/text_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: eleven_multilingual_v2
          source: |
            const payload = {
              "model": "eleven_multilingual_v2",
              "promptText": "Welcome to our audio guide. Let us begin the tour.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              }
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/text_to_speech",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify(payload),
              },
            );
            if (!response.ok) throw new Error(await response.text());
            const task = await response.json();
            console.log(task.id);
        - lang: Shell
          label: eleven_v3
          source: |
            curl https://api.cometapi.com/runwayml/v1/text_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "eleven_v3",
              "promptText": "[whispers] The adventure begins at sunrise.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              },
              "stability": 0.5,
              "speed": 1
            }'
        - lang: Python
          label: eleven_v3
          source: |
            import os
            import requests

            payload = {   'model': 'eleven_v3',
                'promptText': '[whispers] The adventure begins at sunrise.',
                'voice': {'type': 'runway-preset', 'presetId': 'Maya'},
                'stability': 0.5,
                'speed': 1}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/text_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: eleven_v3
          source: |
            const payload = {
              "model": "eleven_v3",
              "promptText": "[whispers] The adventure begins at sunrise.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              },
              "stability": 0.5,
              "speed": 1
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/text_to_speech",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify(payload),
              },
            );
            if (!response.ok) throw new Error(await response.text());
            const task = await response.json();
            console.log(task.id);
        - lang: Shell
          label: eleven_v4
          source: |
            curl https://api.cometapi.com/runwayml/v1/text_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "eleven_v4",
              "promptText": "[pause] The museum opens at nine.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              },
              "stability": 0.5,
              "speed": 1,
              "languageCode": "en",
              "previousText": "The guide takes a breath.",
              "nextText": "Visitors enter through the west door."
            }'
        - lang: Python
          label: eleven_v4
          source: |
            import os
            import requests

            payload = {
                "model": "eleven_v4",
                "promptText": "[pause] The museum opens at nine.",
                "voice": {"type": "runway-preset", "presetId": "Maya"},
                "stability": 0.5,
                "speed": 1,
                "languageCode": "en",
                "previousText": "The guide takes a breath.",
                "nextText": "Visitors enter through the west door.",
            }

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/text_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: eleven_v4
          source: |
            const payload = {
              "model": "eleven_v4",
              "promptText": "[pause] The museum opens at nine.",
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              },
              "stability": 0.5,
              "speed": 1,
              "languageCode": "en",
              "previousText": "The guide takes a breath.",
              "nextText": "Visitors enter through the west door."
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/text_to_speech",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify(payload),
              },
            );
            if (!response.ok) throw new Error(await response.text());
            const task = await response.json();
            console.log(task.id);
        - lang: Shell
          label: seed_audio
          source: |
            curl https://api.cometapi.com/runwayml/v1/text_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "seed_audio",
              "promptText": "Welcome to our audio guide. Let us begin the tour.",
              "voice": {
                "type": "reference-audio",
                "audioUri": "https://your-audio-host/voice-reference.mp3"
              },
              "sampleRate": 44100,
              "outputFormat": "mp3"
            }'
        - lang: Python
          label: seed_audio
          source: |
            import os
            import requests

            payload = {   'model': 'seed_audio',
                'promptText': 'Welcome to our audio guide. Let us begin the tour.',
                'voice': {   'type': 'reference-audio',
                             'audioUri': 'https://your-audio-host/voice-reference.mp3'},
                'sampleRate': 44100,
                'outputFormat': 'mp3'}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/text_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: seed_audio
          source: |
            const payload = {
              "model": "seed_audio",
              "promptText": "Welcome to our audio guide. Let us begin the tour.",
              "voice": {
                "type": "reference-audio",
                "audioUri": "https://your-audio-host/voice-reference.mp3"
              },
              "sampleRate": 44100,
              "outputFormat": "mp3"
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/text_to_speech",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify(payload),
              },
            );
            if (!response.ok) throw new Error(await response.text());
            const task = await response.json();
            console.log(task.id);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use your CometAPI API key.

````

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