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

# Convert Runway speech

> Convert recorded dialogue into a selected voice with the Runway API.

Use `POST /runwayml/v1/speech_to_speech` to convert recorded dialogue into a
preset voice. Use the model ID `eleven_multilingual_sts_v2`.
Send your CometAPI API key with Bearer authentication and a JSON request body.

## Provide dialogue and a voice

| Field            | Required value                                                       |
| ---------------- | -------------------------------------------------------------------- |
| `model`          | `eleven_multilingual_sts_v2`                                         |
| `media.type`     | `audio` for an audio file or `video` for a video containing dialogue |
| `media.uri`      | Accessible HTTPS URL of the source file                              |
| `voice.type`     | `runway-preset`                                                      |
| `voice.presetId` | A preset voice from the request schema, such as `Maya`               |

Replace the example media URL with your source file. If you use a video,
change `media.type` to `video` and supply its video URL in `media.uri`.

Set `removeBackgroundNoise: true` to remove background noise from the generated
speech. Omit this field to use the model default.

## Retrieve the result

Save the returned `id`, then use [Get a Runway task](./runway-to-get-task-details)
to retrieve task status. When `status` is `SUCCEEDED`, download the resulting
media from the URLs in `output`. If the task fails, inspect `failure` and
`failureCode`.


## OpenAPI

````yaml api/openapi/video/runway/official-format/post-convert-speech.openapi.json POST /runwayml/v1/speech_to_speech
openapi: 3.1.0
info:
  title: Convert Runway speech API
  version: 1.0.0
  description: Convert recorded dialogue into a selected voice with the Runway API.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /runwayml/v1/speech_to_speech:
    post:
      summary: Convert Runway speech
      description: >-
        Convert recorded dialogue into a selected voice with the Runway API.
        Save the returned id and retrieve the task to obtain its output.
      operationId: runway_speech_to_speech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              title: eleven_multilingual_sts_v2
              type: object
              properties:
                model:
                  type: string
                  const: eleven_multilingual_sts_v2
                  enum:
                    - eleven_multilingual_sts_v2
                  description: Model ID for this request.
                removeBackgroundNoise:
                  description: >-
                    Set true to remove background noise from the generated
                    speech. Omit or use false for the model default.
                  type: boolean
                media:
                  oneOf:
                    - title: SpeechToSpeechAudio
                      description: An audio file containing dialogue to be processed.
                      type: object
                      properties:
                        type:
                          type: string
                          const: audio
                          enum:
                            - audio
                          description: Input type. Use audio.
                        uri:
                          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
                        - uri
                      additionalProperties: false
                    - title: SpeechToSpeechVideo
                      description: A video file containing dialogue to be processed.
                      type: object
                      properties:
                        type:
                          type: string
                          const: video
                          enum:
                            - video
                          description: Input type. Use video.
                        uri:
                          description: >-
                            Video input as an accessible HTTPS URL or base64
                            data URI.
                          anyOf:
                            - description: Accessible HTTPS URL of the video file.
                              type: string
                              minLength: 13
                              maxLength: 2048
                              pattern: ^https:\/\/.*
                            - description: Base64 video data URI, up to 5 MB.
                              type: string
                              minLength: 13
                              maxLength: 5242880
                              pattern: ^data:video\/.*
                      required:
                        - type
                        - uri
                      additionalProperties: false
                  discriminator:
                    propertyName: type
                  description: Audio or video file containing the dialogue to convert.
                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:
                - media
                - voice
                - model
              additionalProperties: false
              description: Request settings for eleven_multilingual_sts_v2.
              default:
                model: eleven_multilingual_sts_v2
                media:
                  type: audio
                  uri: https://your-audio-host/source-speech.mp3
                voice:
                  type: runway-preset
                  presetId: Maya
            examples:
              eleven_multilingual_sts_v2:
                summary: eleven_multilingual_sts_v2
                value:
                  model: eleven_multilingual_sts_v2
                  media:
                    type: audio
                    uri: https://your-audio-host/source-speech.mp3
                  voice:
                    type: runway-preset
                    presetId: Maya
              video_dialogue:
                summary: Dialogue from a video
                value:
                  model: eleven_multilingual_sts_v2
                  media:
                    type: video
                    uri: https://your-video-host/source-dialogue.mp4
                  voice:
                    type: runway-preset
                    presetId: Maya
      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_sts_v2
          source: |
            curl https://api.cometapi.com/runwayml/v1/speech_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "eleven_multilingual_sts_v2",
              "media": {
                "type": "audio",
                "uri": "https://your-audio-host/source-speech.mp3"
              },
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              }
            }'
        - lang: Python
          label: eleven_multilingual_sts_v2
          source: |
            import os
            import requests

            payload = {   'model': 'eleven_multilingual_sts_v2',
                'media': {   'type': 'audio',
                             'uri': 'https://your-audio-host/source-speech.mp3'},
                'voice': {'type': 'runway-preset', 'presetId': 'Maya'}}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/speech_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: eleven_multilingual_sts_v2
          source: |
            const payload = {
              "model": "eleven_multilingual_sts_v2",
              "media": {
                "type": "audio",
                "uri": "https://your-audio-host/source-speech.mp3"
              },
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              }
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/speech_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: video_dialogue
          source: |
            curl https://api.cometapi.com/runwayml/v1/speech_to_speech \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "eleven_multilingual_sts_v2",
              "media": {
                "type": "video",
                "uri": "https://your-video-host/source-dialogue.mp4"
              },
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              }
            }'
        - lang: Python
          label: video_dialogue
          source: |
            import os
            import requests

            payload = {   'model': 'eleven_multilingual_sts_v2',
                'media': {   'type': 'video',
                             'uri': 'https://your-video-host/source-dialogue.mp4'},
                'voice': {'type': 'runway-preset', 'presetId': 'Maya'}}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/speech_to_speech",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: video_dialogue
          source: |
            const payload = {
              "model": "eleven_multilingual_sts_v2",
              "media": {
                "type": "video",
                "uri": "https://your-video-host/source-dialogue.mp4"
              },
              "voice": {
                "type": "runway-preset",
                "presetId": "Maya"
              }
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/speech_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.

````