mcpField
F
fal-audio

fal-audio

github.com/josiahsiegelクリエイティブ・メディア5973 回インストール19 週間前に更新
リポジトリ

fal-audio について

fal-audioは、fal.aiの音声認識・音声合成モデルを利用するためのリファレンススキルです。開発者向けに、エンドポイントやパラメーター、文字起こし、翻訳、字幕、ボイスクローニングの例をまとめています。

主な機能

  1. 01音声認識モデルとエンドポイントの案内
  2. 02音声合成モデルとエンドポイントの案内
  3. 03文字起こし・翻訳パラメーター
  4. 04タイムスタンプ付き分割出力
  5. 05ボイスクローニングの例

活用シーン

  1. 01音声や動画をテキストに文字起こし
  2. 02タイムスタンプ付き字幕の作成
  3. 03音声を英語に翻訳
  4. 04テキストからの音声生成や声の複製

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill fal-audio

インストール後、Claude Code で/fal-audioを入力して読み込まれたか確認します。

詳細

クイックリファレンス

STT モデルエンドポイント速度精度
Whisperfal-ai/whisper中速最高
Whisper Turbofal-ai/whisper-turbo高速高
Whisper Large v3fal-ai/whisper-large-v3低速最高
TTS モデルエンドポイント音声クローン品質
F5-TTSfal-ai/f5-ttsあり高
ElevenLabsfal-ai/elevenlabs/ttsAPI 経由最高
Kokorofal-ai/kokoro/american-englishなし良好
XTTSfal-ai/xttsあり良好
Whisper タスク用途
transcribe同じ言語のテキスト
translate英語以外 → 英語
Whisper パラメーター値
chunk_levelタイムスタンプには "segment"
languageISO コード(例:"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_urlstring-音声ファイルの URL
taskstring"transcribe", "translate"文字起こし、または英語への翻訳
languagestringISO codeソース言語(省略可、自動検出)
chunk_levelstring"segment"タイムスタンプを返す
versionstring"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_textstring合成するテキスト
ref_audio_urlstring参照音声の URL
ref_textstring参照音声の文字起こし
model_typestring"F5-TTS" または "E2-TTS"
remove_silenceboolean出力から無音を除去する
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 のパラメーター:

パラメーター型説明
textstring合成するテキスト
voice_idstringElevenLabs の音声 ID
model_idstringTTS モデルのバージョン
stabilitynumber音声の安定性(0~1)
similarity_boostnumber音声の類似度(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 のパラメーター:

パラメーター型説明
textstring音声合成するテキスト
voicestring音声スタイルの識別子
speednumber話速の倍率
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 のパラメーター:

パラメーター型説明
textstring音声合成するテキスト
audio_urlstringクローン作成に使用する参照音声
languagestring対象言語

モデルの比較

音声テキスト変換
モデル速度精度対応言語数最適な用途
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;
}

ベストプラクティス

音声テキスト変換
  1. 音声品質:クリアな音声ほど、文字起こしの精度が高くなります
  2. 言語の指定:言語がわかっている場合は、言語ヒントを指定してください
  3. タイムスタンプの使用:字幕には chunk_level: "segment" をリクエストしてください
  4. 長い音声への対応:Whisper は長いファイルを自動的に処理します
  5. 翻訳:英語以外の言語から英語に翻訳するには、task: "translate" を使用してください
テキスト音声変換
  1. 参照音声の品質:音声クローンには、10~30 秒の明瞭なサンプルを使用してください
  2. 参照用文字起こし:正確な文字起こしにより、クローンの品質が向上します
  3. テキストの長さ:非常に長いテキストは分割してください
  4. 句読点:適切な句読点により、韻律が改善されます
  5. 感情のヒント:句読点(!、?)を使って感情を伝えてください
主な対応言語
言語コードSTTTTS
英語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-TTSWAV
ElevenLabsMP3
KokoroWAV
XTTSWAV

エラー処理

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);
  }
}

コメント