fal-audio について
fal-audioは、fal.aiの音声認識・音声合成モデルを利用するためのリファレンススキルです。開発者向けに、エンドポイントやパラメーター、文字起こし、翻訳、字幕、ボイスクローニングの例をまとめています。
主な機能
- 01音声認識モデルとエンドポイントの案内
- 02音声合成モデルとエンドポイントの案内
- 03文字起こし・翻訳パラメーター
- 04タイムスタンプ付き分割出力
- 05ボイスクローニングの例
活用シーン
- 01音声や動画をテキストに文字起こし
- 02タイムスタンプ付き字幕の作成
- 03音声を英語に翻訳
- 04テキストからの音声生成や声の複製
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ josiahsiegel/ claude-plugin-marketplace --skill fal-audioインストール後、Claude Code で/fal-audioを入力して読み込まれたか確認します。
詳細
クイックリファレンス
| STT モデル | エンドポイント | 速度 | 精度 |
|---|---|---|---|
| Whisper | fal-ai/whisper | 中速 | 最高 |
| Whisper Turbo | fal-ai/whisper-turbo | 高速 | 高 |
| Whisper Large v3 | fal-ai/whisper-large-v3 | 低速 | 最高 |
| TTS モデル | エンドポイント | 音声クローン | 品質 |
|---|---|---|---|
| F5-TTS | fal-ai/f5-tts | あり | 高 |
| ElevenLabs | fal-ai/elevenlabs/tts | API 経由 | 最高 |
| Kokoro | fal-ai/kokoro/american-english | なし | 良好 |
| XTTS | fal-ai/xtts | あり | 良好 |
| Whisper タスク | 用途 |
|---|---|
transcribe | 同じ言語のテキスト |
translate | 英語以外 → 英語 |
| Whisper パラメーター | 値 |
|---|---|
chunk_level | タイムスタンプには "segment" |
language | ISO コード(例:"en") |
このスキルを使用する場面
音声処理には、以下の用途で使用します。
- 音声/動画をテキストに文字起こしする
- タイムスタンプ付きの字幕を生成する
- 音声を英語に翻訳する
- 参照音声から声をクローンする
- テキストから自然な音声を生成する
関連スキル:
- 音声付き動画については、
fal-text-to-videoを参照してください - API 統合については、
fal-api-referenceを参照してください - モデルの比較については、
fal-model-guideを参照してください
fal.ai 音声モデル
fal.ai の音声テキスト変換(STT)およびテキスト音声変換(TTS)モデルの完全なリファレンスです。
音声テキスト変換モデル
Whisper(OpenAI)
エンドポイント: fal-ai/whisper
最適な用途: 高精度な文字起こしと翻訳
99 以上の言語に対応した、業界標準の音声認識モデルです。
import { fal } from "@fal-ai/client";
const result = await fal.subscribe("fal-ai/whisper", {
input: {
audio_url: "https://example.com/speech.mp3",
task: "transcribe",
language: "en",
chunk_level: "segment"
}
});
console.log(result.text);
console.log(result.chunks); // With timestamps
import fal_client
result = fal_client.subscribe(
"fal-ai/whisper",
arguments={
"audio_url": "https://example.com/speech.mp3",
"task": "transcribe",
"language": "en",
"chunk_level": "segment"
}
)
print(result["text"])
for chunk in result["chunks"]:
print(f"[{chunk['timestamp'][0]:.2f}-{chunk['timestamp'][1]:.2f}] {chunk['text']}")
Whisper のパラメーター:
| パラメーター | 型 | 値 | 説明 |
|---|---|---|---|
audio_url | string | - | 音声ファイルの URL |
task | string | "transcribe", "translate" | 文字起こし、または英語への翻訳 |
language | string | ISO code | ソース言語(省略可、自動検出) |
chunk_level | string | "segment" | タイムスタンプを返す |
version | string | "3" | Whisper のバージョン |
レスポンス構造:
interface WhisperOutput {
text: string; // Full transcription
chunks?: Array<{
text: string;
timestamp: [number, number]; // [start, end] in seconds
}>;
}
Whisper Turbo
エンドポイント: fal-ai/whisper-turbo
最適な用途: 高速な文字起こし
const result = await fal.subscribe("fal-ai/whisper-turbo", {
input: {
audio_url: "https://example.com/podcast.mp3",
task: "transcribe"
}
});
Whisper Large v3
エンドポイント: fal-ai/whisper-large-v3
最適な用途: 最高精度
const result = await fal.subscribe("fal-ai/whisper-large-v3", {
input: {
audio_url: "https://example.com/meeting.mp3",
task: "transcribe",
language: "en"
}
});
Whisper の使用例
タイムスタンプ付きの文字起こし:
const result = await fal.subscribe("fal-ai/whisper", {
input: {
audio_url: audioUrl,
task: "transcribe",
chunk_level: "segment"
}
});
// Format as SRT subtitles
result.chunks.forEach((chunk, i) => {
const start = formatTime(chunk.timestamp[0]);
const end = formatTime(chunk.timestamp[1]);
console.log(`${i + 1}\n${start} --> ${end}\n${chunk.text}\n`);
});
function formatTime(seconds: number): string {
const h = Math.floor(seconds / 3600);
const m = Math.floor((seconds % 3600) / 60);
const s = Math.floor(seconds % 60);
const ms = Math.floor((seconds % 1) * 1000);
return `${h.toString().padStart(2, '0')}:${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')},${ms.toString().padStart(3, '0')}`;
}
翻訳(英語以外から英語へ):
const result = await fal.subscribe("fal-ai/whisper", {
input: {
audio_url: "https://example.com/french-speech.mp3",
task: "translate", // Translates to English
language: "fr"
}
});
console.log(result.text); // English translation
多言語検出:
// Whisper auto-detects language if not specified
const result = await fal.subscribe("fal-ai/whisper", {
input: {
audio_url: "https://example.com/unknown-language.mp3",
task: "transcribe"
// language omitted - auto-detect
}
});
テキスト音声変換モデル
F5-TTS
エンドポイント: fal-ai/f5-tts
最適な用途: 参照音声からの声のクローン
const result = await fal.subscribe("fal-ai/f5-tts", {
input: {
gen_text: "Hello! Welcome to our product demonstration. We're excited to show you what we've built.",
ref_audio_url: "https://example.com/voice-sample.wav",
ref_text: "This is a sample of my voice for cloning purposes.",
model_type: "F5-TTS"
}
});
console.log(result.audio_url);
result = fal_client.subscribe(
"fal-ai/f5-tts",
arguments={
"gen_text": "Hello! Welcome to our product.",
"ref_audio_url": "https://example.com/voice-sample.wav",
"ref_text": "This is a sample of my voice."
}
)
print(result["audio_url"])
F5-TTS のパラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
gen_text | string | 合成するテキスト |
ref_audio_url | string | 参照音声の URL |
ref_text | string | 参照音声の文字起こし |
model_type | string | "F5-TTS" または "E2-TTS" |
remove_silence | boolean | 出力から無音を除去する |
ElevenLabs TTS
エンドポイント: fal-ai/elevenlabs/tts
最適な用途: プレミアムな音声品質
const result = await fal.subscribe("fal-ai/elevenlabs/tts", {
input: {
text: "Welcome to fal.ai! Let me tell you about our amazing AI models.",
voice_id: "21m00Tcm4TlvDq8ikWAM", // ElevenLabs voice ID
model_id: "eleven_multilingual_v2"
}
});
console.log(result.audio.url);
ElevenLabs のパラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
text | string | 合成するテキスト |
voice_id | string | ElevenLabs の音声 ID |
model_id | string | TTS モデルのバージョン |
stability | number | 音声の安定性(0~1) |
similarity_boost | number | 音声の類似度(0~1) |
ElevenLabs の音声 ID(例):
21m00Tcm4TlvDq8ikWAM- Rachel(女性)AZnzlk1XvdvUeBnXmlld- Domi(女性)EXAVITQu4vr4xnSDxMaL- Bella(女性)ErXwobaYiN019PkySvjV- Antoni(男性)VR6AewLTigWG4xSOukaG- Arnold(男性)
Kokoro TTS
エンドポイント: fal-ai/kokoro/american-english
最適な用途: 多言語対応、自然な音声
const result = await fal.subscribe("fal-ai/kokoro/american-english", {
input: {
text: "This is a test of the Kokoro text-to-speech system.",
voice: "af_bella" // Voice style
}
});
console.log(result.audio.url);
Kokoro のバリエーション:
fal-ai/kokoro/american-english- アメリカ英語fal-ai/kokoro/british-english- イギリス英語fal-ai/kokoro/japanese- 日本語fal-ai/kokoro/mandarin- 中国語(標準語)
Kokoro のパラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
text | string | 音声合成するテキスト |
voice | string | 音声スタイルの識別子 |
speed | number | 話速の倍率 |
XTTS(Coqui)
エンドポイント: fal-ai/xtts
最適な用途: オープンソースの音声クローン
const result = await fal.subscribe("fal-ai/xtts", {
input: {
text: "Hello, this is a cloned voice speaking.",
audio_url: "https://example.com/voice-reference.wav",
language: "en"
}
});
XTTS のパラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
text | string | 音声合成するテキスト |
audio_url | string | クローン作成に使用する参照音声 |
language | string | 対象言語 |
モデルの比較
音声テキスト変換
| モデル | 速度 | 精度 | 対応言語数 | 最適な用途 |
|---|---|---|---|---|
| Whisper | 中 | 最高 | 99+ | 精度を最優先する場合 |
| Whisper Turbo | 高速 | 高 | 99+ | 速度が必要な場合 |
| Whisper Large v3 | 低速 | 最高 | 99+ | 最高品質 |
テキスト音声変換
| モデル | 品質 | 音声クローン | 対応言語 | 最適な用途 |
|---|---|---|---|---|
| F5-TTS | 高 | はい | 複数 | 音声クローン |
| ElevenLabs | 最高 | API 経由 | 多数 | プレミアム品質 |
| Kokoro | 良好 | いいえ | 複数 | 多言語対応 |
| XTTS | 良好 | はい | 16 | オープンソース |
ワークフローの例
文字起こしと翻訳のパイプライン
async function processAudio(audioUrl: string, targetLanguage: string = 'en') {
// 1. Transcribe
const transcription = await fal.subscribe("fal-ai/whisper", {
input: {
audio_url: audioUrl,
task: "transcribe",
chunk_level: "segment"
}
});
// 2. If not English, translate
let translation = null;
if (targetLanguage === 'en') {
translation = await fal.subscribe("fal-ai/whisper", {
input: {
audio_url: audioUrl,
task: "translate"
}
});
}
return {
original: transcription.text,
translated: translation?.text,
chunks: transcription.chunks
};
}
音声クローンのパイプライン
async function cloneVoiceAndSpeak(
referenceAudioUrl: string,
referenceText: string,
textToSpeak: string
) {
// Use F5-TTS for voice cloning
const result = await fal.subscribe("fal-ai/f5-tts", {
input: {
gen_text: textToSpeak,
ref_audio_url: referenceAudioUrl,
ref_text: referenceText,
remove_silence: true
}
});
return result.audio_url;
}
字幕の生成
async function generateSubtitles(videoUrl: string): Promise<string> {
// Extract audio and transcribe
const result = await fal.subscribe("fal-ai/whisper", {
input: {
audio_url: videoUrl, // Works with video URLs too
task: "transcribe",
chunk_level: "segment"
}
});
// Generate SRT format
let srt = '';
result.chunks.forEach((chunk, i) => {
srt += `${i + 1}\n`;
srt += `${formatSrtTime(chunk.timestamp[0])} --> ${formatSrtTime(chunk.timestamp[1])}\n`;
srt += `${chunk.text}\n\n`;
});
return srt;
}
function formatSrtTime(seconds: number): string {
const date = new Date(seconds * 1000);
return date.toISOString().substr(11, 12).replace('.', ',');
}
オーディオブックの生成
async function generateAudioBook(chapters: string[], voiceId: string) {
const audioUrls = [];
for (const chapter of chapters) {
// Split into manageable chunks
const chunks = splitText(chapter, 5000);
for (const chunk of chunks) {
const result = await fal.subscribe("fal-ai/elevenlabs/tts", {
input: {
text: chunk,
voice_id: voiceId,
model_id: "eleven_multilingual_v2"
}
});
audioUrls.push(result.audio.url);
}
}
return audioUrls;
}
function splitText(text: string, maxLength: number): string[] {
const chunks = [];
let current = '';
text.split('. ').forEach(sentence => {
if ((current + sentence).length < maxLength) {
current += sentence + '. ';
} else {
chunks.push(current.trim());
current = sentence + '. ';
}
});
if (current) chunks.push(current.trim());
return chunks;
}
パラメーターリファレンス
音声テキスト変換の入力
interface STTInput {
audio_url: string;
task?: "transcribe" | "translate";
language?: string; // ISO 639-1 code
chunk_level?: "segment";
version?: string;
}
テキスト音声変換の入力
interface TTSInput {
// Common
text?: string;
gen_text?: string;
// Voice cloning
ref_audio_url?: string;
ref_text?: string;
audio_url?: string; // XTTS
// Voice selection
voice_id?: string; // ElevenLabs
voice?: string; // Kokoro
model_type?: string; // F5-TTS
// Control
speed?: number;
stability?: number;
similarity_boost?: number;
language?: string;
remove_silence?: boolean;
}
ベストプラクティス
音声テキスト変換
- 音声品質:クリアな音声ほど、文字起こしの精度が高くなります
- 言語の指定:言語がわかっている場合は、言語ヒントを指定してください
- タイムスタンプの使用:字幕には
chunk_level: "segment"をリクエストしてください - 長い音声への対応:Whisper は長いファイルを自動的に処理します
- 翻訳:英語以外の言語から英語に翻訳するには、
task: "translate"を使用してください
テキスト音声変換
- 参照音声の品質:音声クローンには、10~30 秒の明瞭なサンプルを使用してください
- 参照用文字起こし:正確な文字起こしにより、クローンの品質が向上します
- テキストの長さ:非常に長いテキストは分割してください
- 句読点:適切な句読点により、韻律が改善されます
- 感情のヒント:句読点(!、?)を使って感情を伝えてください
主な対応言語
| 言語 | コード | STT | TTS |
|---|---|---|---|
| 英語 | en | はい | はい |
| スペイン語 | es | はい | はい |
| フランス語 | fr | はい | はい |
| ドイツ語 | de | はい | はい |
| イタリア語 | it | はい | はい |
| ポルトガル語 | pt | はい | はい |
| 日本語 | ja | はい | はい |
| 中国語 | zh | はい | はい |
| 韓国語 | ko | はい | はい |
| ロシア語 | ru | はい | 限定的 |
ファイル形式の対応
入力形式(STT)
| 形式 | 拡張子 | 対応状況 |
|---|---|---|
| MP3 | .mp3 | はい |
| WAV | .wav | はい |
| M4A | .m4a | はい |
| FLAC | .flac | はい |
| OGG | .ogg | はい |
| WebM | .webm | はい |
| 動画 | .mp4 | はい(音声を抽出) |
出力形式(TTS)
| モデル | 出力形式 |
|---|---|
| F5-TTS | WAV |
| ElevenLabs | MP3 |
| Kokoro | WAV |
| XTTS | WAV |
エラー処理
try {
const result = await fal.subscribe("fal-ai/whisper", {
input: { audio_url: audioUrl, task: "transcribe" }
});
} catch (error) {
if (error.status === 400) {
console.error("Invalid audio file or URL");
} else if (error.status === 413) {
console.error("Audio file too large");
} else {
console.error("Transcription failed:", error.message);
}
}