mcpField
R
rw-integrate-audio

rw-integrate-audio

github.com/runwayml创意与媒体74216 次安装2 天前更新
代码仓库

关于 rw-integrate-audio

这项技能指导开发者使用 RunwayML SDK 将音频生成功能接入服务端代码,涵盖语音、音效、语音隔离、配音和语音转换。

主要功能

  1. 01文本转语音
  2. 02按文本描述生成音效
  3. 03从音频中隔离人声
  4. 04音频和视频配音
  5. 05语音到语音转换

适用场景

  1. 01为应用添加生成的旁白
  2. 02根据文本描述制作音效
  3. 03从嘈杂录音中提取人声
  4. 04为媒体配音或转换声音

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/runwayml/skills --skill rw-integrate-audio

安装后在 Claude Code 中输入/rw-integrate-audio确认已加载。

详细介绍

集成音频生成

前置条件: 请先运行 +rw-check-compatibility。集成前运行 +rw-fetch-api-reference,加载最新的 API 参考。需要使用 +rw-setup-api-key 配置 API 凭据。处理本地音频/视频文件需要使用 +rw-integrate-uploads。

帮助用户在服务端代码中添加 Runway 音频生成功能。

可用模型

模型端点用途费用
eleven_multilingual_v2POST /v1/text_to_speech文本转语音1 积分/50 个字符
eleven_text_to_sound_v2POST /v1/sound_effect音效生成1-2 积分
eleven_voice_isolationPOST /v1/voice_isolation从音频中分离人声1 积分/6 秒
eleven_voice_dubbingPOST /v1/voice_dubbing将音频配音成其他语言1 积分/2 秒
eleven_multilingual_sts_v2POST /v1/speech_to_speech语音转换1 积分/3 秒

文本转语音

使用 ElevenLabs 多语言模型根据文本生成语音。

Node.js SDK
import RunwayML from '@runwayml/sdk';

const client = new RunwayML();

const task = await client.textToSpeech.create({
  model: 'eleven_multilingual_v2',
  promptText: 'Hello, welcome to our application!',
  voice: { type: 'runway-preset', presetId: 'Maya' }
}).waitForTaskOutput();

const audioUrl = task.output[0];
Python SDK
from runwayml import RunwayML

client = RunwayML()

task = client.text_to_speech.create(
    model='eleven_multilingual_v2',
    prompt_text='Hello, welcome to our application!',
    voice={ 'type': 'runway-preset', 'presetId': 'Maya' }
).wait_for_task_output()

audio_url = task.output[0]

音效

根据文本描述生成音效。

const task = await client.soundEffect.create({
  model: 'eleven_text_to_sound_v2',
  promptText: 'Thunder rolling across a stormy sky'
}).waitForTaskOutput();
task = client.sound_effect.create(
    model='eleven_text_to_sound_v2',
    prompt_text='Thunder rolling across a stormy sky'
).wait_for_task_output()

人声分离

从带有背景噪声的音频中提取人声。

// If using a local file, upload first
const upload = await client.uploads.createEphemeral(
  fs.createReadStream('/path/to/noisy-audio.mp3')
);

const task = await client.voiceIsolation.create({
  model: 'eleven_voice_isolation',
  audioUri: upload.runwayUri
}).waitForTaskOutput();

配音

将音频/视频配成其他语言。

const task = await client.voiceDubbing.create({
  model: 'eleven_voice_dubbing',
  audioUri: 'https://example.com/speech.mp3',
  targetLang: 'es'  // Spanish
}).waitForTaskOutput();

语音转语音

将一种声音转换为另一种声音。

const task = await client.speechToSpeech.create({
  model: 'eleven_multilingual_sts_v2',
  media: { type: 'audio', uri: 'https://example.com/original-speech.mp3' },
  voice: { type: 'runway-preset', presetId: 'Noah' }
}).waitForTaskOutput();

集成模式

Express.js — 文本转语音端点
import RunwayML from '@runwayml/sdk';
import express from 'express';

const client = new RunwayML();
const app = express();
app.use(express.json());

app.post('/api/text-to-speech', async (req, res) => {
  try {
    const { text, voiceId } = req.body;

    const task = await client.textToSpeech.create({
      model: 'eleven_multilingual_v2',
      promptText: text,
      voice: { type: 'runway-preset', presetId: voiceId || 'Maya' }
    }).waitForTaskOutput();

    res.json({ audioUrl: task.output[0] });
  } catch (error) {
    console.error('TTS failed:', error);
    res.status(500).json({ error: error.message });
  }
});
FastAPI — 音效
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from runwayml import RunwayML

app = FastAPI()
client = RunwayML()

class SoundRequest(BaseModel):
    prompt: str

@app.post("/api/sound-effect")
async def generate_sound(req: SoundRequest):
    try:
        task = client.sound_effect.create(
            model='eleven_text_to_sound_v2',
            prompt_text=req.prompt
        ).wait_for_task_output()
        return {"audio_url": task.output[0]}
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))

提示

  • **输出 URL 会在 24-48 小时后过期。**请将音频文件下载到自己的存储空间。
  • 对于本地音频文件(人声分离、配音、语音转语音),请先通过 +rw-integrate-uploads 上传。
  • 语音 ID 可通过 voices 端点列出,详情请参阅 +rw-api-reference。
  • 文本转语音费用随文本长度增加:每 50 个字符消耗 1 积分。

评论

支持 Markdown