rw-integrate-audio について
RunwayML SDK を使い、Runway の音声生成機能をサーバーサイドのコードに組み込むためのスキルです。音声合成、効果音、声の分離、吹き替え、音声変換を扱います。
主な機能
- 01テキスト読み上げ生成
- 02テキストから効果音を生成
- 03音声から声を分離
- 04音声・動画の吹き替え
- 05音声から音声への変換
活用シーン
- 01アプリに生成ナレーションを追加
- 02テキスト描写から効果音を作成
- 03ノイズのある録音から声を抽出
- 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 リファレンスを読み込んでください。API 認証情報には+rw-setup-api-keyが必要です。ローカルの音声/動画ファイルには+rw-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',
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 は音声エンドポイントから一覧表示できます。詳細は
+rw-api-referenceを参照してください。 - テキスト読み上げのコストはテキストの長さに応じて増加します。50 文字あたり 1 クレジットです。
コメント
Markdown 対応