RunwayML - 텍스트 음성 변환

RunwayML - 텍스트 음성 변환 (Text-to-Speech)

RunwayML의 텍스트-음성 변환 기능을 LiteLLM에서 사용하는 방법을 알아봐요. 자연스러운 목소리로 텍스트에서 오디오를 생성할 수 있어요.

출처: 문서

본문

개요

속성 내용
설명 RunwayML은 자연스러운 목소리로 고품질 AI 텍스트-음성 변환을 제공해요
LiteLLM 라우트 runwayml/
지원 연산 /audio/speech
공식 문서 RunwayML API ↗

LiteLLM은 자동 태스크 폴링 기능과 함께 RunwayML의 텍스트-음성 변환 API를 지원해서, 텍스트에서 자연스러운 오디오를 생성할 수 있어요.

빠른 시작

from litellm import speech
import os

os.environ["RUNWAYML_API_KEY"] = "your-api-key"

response = speech(
    model="runwayml/eleven_multilingual_v2",
    input="Step right up, ladies and gentlemen! Have you ever wished for a toaster that's not just a toaster but a marvel of modern ingenuity?",
    voice="alloy"
)

# Save the audio
with open("output.mp3", "wb") as f:
    f.write(response.content)

인증

RunwayML API 키를 설정해요:

import os

os.environ["RUNWAYML_API_KEY"] = "your-api-key"

지원 파라미터

파라미터 타입 필수 설명
model string 사용할 모델 (예: runwayml/eleven_multilingual_v2)
input string 음성으로 변환할 텍스트
voice string 또는 dict 사용할 목소리 (OpenAI 이름, RunwayML 프리셋, 음성 구성)

음성 옵션

OpenAI 음성 이름 사용

OpenAI 음성 이름은 적절한 RunwayML 음성으로 자동 매핑돼요:

from litellm import speech

# These OpenAI voice names work automatically
response = speech(
    model="runwayml/eleven_multilingual_v2",
    input="Hello, world!",
    voice="alloy"  # Maya - neutral, balanced female voice
)

음성 매핑:

  • alloy → Maya (중립적이고 균형 잡힌 여성 음성)
  • echo → James (남성 음성)
  • fable → Bernard (따뜻한 스토리텔링 음성)
  • onyx → Vincent (깊은 남성 음성)
  • nova → Serene (따뜻하고 표현력 있는 여성 음성)
  • shimmer → Ella (맑고 친근한 여성 음성)

RunwayML 프리셋 음성 사용

문자열로 프리셋 이름을 전달해 어떤 RunwayML 프리셋 음성이든 직접 지정할 수 있어요:

from litellm import speech

# Pass the RunwayML voice name as a string
response = speech(
    model="runwayml/eleven_multilingual_v2",
    input="Hello, world!",
    voice="Maya"  # LiteLLM automatically formats this for RunwayML
)

# Try different RunwayML voices
response = speech(
    model="runwayml/eleven_multilingual_v2",
    input="Step right up, ladies and gentlemen!",
    voice="Bernard"  # Great for storytelling
)

사용 가능한 RunwayML 음성:

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

: 음성 이름을 문자열로 전달하기만 하면 LiteLLM이 내부 RunwayML API 형식 변환을 자동으로 처리해요.

비동기 사용법

from litellm import aspeech
import os
import asyncio

os.environ["RUNWAYML_API_KEY"] = "your-api-key"

async def generate_speech():
    response = await aspeech(
        model="runwayml/eleven_multilingual_v2",
        input="This is an asynchronous text-to-speech request.",
        voice="nova"
    )

    with open("output.mp3", "wb") as f:
        f.write(response.content)

    print("Audio generated successfully!")

asyncio.run(generate_speech())

LiteLLM Proxy 사용법

config.yaml:

model_list:
  - model_name: runway-tts
    litellm_params:
      model: runwayml/eleven_multilingual_v2
      api_key: os.environ/RUNWAYML_API_KEY

Proxy 시작:

litellm --config /path/to/config.yaml

Proxy를 통해 음성 생성:

curl --location 'http://localhost:4000/v1/audio/speech' \
--header 'Content-Type: application/json' \
--header 'x-litellm-api-key: *** ' \
--data '{
    "model": "runwayml/eleven_multilingual_v2",
    "input": "Hello from the LiteLLM proxy!",
    "voice": "alloy"
}'

RunwayML 전용 음성 사용:

curl --location 'http://localhost:4000/v1/audio/speech' \
--header 'Content-Type: application/json' \
--header 'x-litellm-api-key: *** ' \
--data '{
    "model": "runwayml/eleven_multilingual_v2",
    "input": "Hello with a custom RunwayML voice!",
    "voice": "Bernard"
}'

지원 모델

모델 설명
runwayml/eleven_multilingual_v2 고품질 다국어 텍스트-음성 변환

비용 추적

LiteLLM은 RunwayML 텍스트-음성 변환 비용을 자동으로 추적해요:

from litellm import speech, completion_cost

response = speech(
    model="runwayml/eleven_multilingual_v2",
    input="Hello, world!",
    voice="alloy"
)

cost = completion_cost(completion_response=response)
print(f"Text-to-speech cost: ${cost}")

지원 기능

기능 지원
Text-to-Speech
Cost Tracking
Logging
Fallbacks
Load Balancing
50+ Voice Presets

동작 원리

RunwayML은 비동기 태스크 기반 API 패턴을 사용해요. LiteLLM이 폴링과 응답 변환을 자동으로 처리해요.

더 알아보기 (Learn more)

  • RunwayML API 공식 문서
  • LiteLLM TTS API