关于 integrate-audio
integrate-audio 是一项用于在服务端应用中接入 Runway 音频生成的技能,涵盖语音、音效、语音处理和配音,并提供 SDK 集成示例。
主要功能
- 01文本转语音生成
- 02生成音效
- 03语音隔离
- 04音频配音
- 05语音到语音转换
适用场景
- 01为应用添加语音旁白
- 02根据文字描述生成音效
- 03去除录音中的背景噪声
- 04将音频或视频配成其他语言
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ runwayml/ skills --skill integrate-audio安装后在 Claude Code 中输入/integrate-audio确认已加载。
详细介绍
集成音频生成
前置条件: 请先运行
+check-compatibility。集成前运行+fetch-api-reference,以加载最新 API 参考。需要+setup-api-key来设置 API 凭据。本地音频/视频文件需要+integrate-uploads。
帮助用户在服务器端代码中添加 Runway 音频生成功能。
可用模型
| 模型 | 端点 | 用途 | 费用 |
|---|---|---|---|
eleven_multilingual_v2 | POST /v1/text_to_speech | 文本转语音 | 每 50 个字符 1 点数 |
eleven_text_to_sound_v2 | POST /v1/sound_effect | 音效生成 | 1-2 点数 |
eleven_voice_isolation | POST /v1/voice_isolation | 从音频中分离人声 | 每 6 秒 1 点数 |
eleven_voice_dubbing | POST /v1/voice_dubbing | 将音频配音为其他语言 | 每 2 秒 1 点数 |
eleven_multilingual_sts_v2 | POST /v1/speech_to_speech | 语音转换 | 每 3 秒 1 点数 |
文本转语音
使用 ElevenLabs 多语言模型将文本生成为语音。
Node.js SDK
import RunwayML from '@runwayml/sdk';
const client = new RunwayML();
const task = await client.textToSpeech.create({
model: 'eleven_multilingual_v2',
text: 'Hello, welcome to our application!',
voiceId: 'voice_id_here' // See voice listing endpoint
}).waitForTaskOutput();
const audioUrl = task.output[0];
Python SDK
from runwayml import RunwayML
client = RunwayML()
task = client.text_to_speech.create(
model='eleven_multilingual_v2',
text='Hello, welcome to our application!',
voice_id='voice_id_here'
).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',
audio: upload.runwayUri
}).waitForTaskOutput();
语音配音
将音频/视频配音为其他语言。
const task = await client.voiceDubbing.create({
model: 'eleven_voice_dubbing',
audio: 'https://example.com/speech.mp3',
targetLanguage: 'es' // Spanish
}).waitForTaskOutput();
语音转语音
将一种声音转换为另一种声音。
const task = await client.speechToSpeech.create({
model: 'eleven_multilingual_sts_v2',
audio: 'https://example.com/original-speech.mp3',
voiceId: 'target_voice_id'
}).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',
text,
voiceId
}).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 小时后过期。 请将音频文件下载到自己的存储空间。
- 对于本地音频文件(人声分离、配音、语音转语音),请先通过
+integrate-uploads上传。 - 语音 ID 可通过 voices 端点列出——详情请参阅
+api-reference。 - 文本转语音的费用随文本长度增加:每 50 个字符 1 点数。
评论
支持 Markdown