Skip to content

非公式本サイトは非公式の日本語ドキュメントであり、Cloudflare 公式サイトではありません。最新情報はdevelopers.cloudflare.comをご確認ください。

xAI のロゴ

Grok STT

音声認識 • xAI

Markdown で表示Agent セットアップ
  • サードパーティ
  • ゼロデータ保持

xAI の Grok 音声認識モデルです。25 言語の音声ファイルをテキストに文字起こしし、単語レベルのタイムスタンプ、マルチチャネル文字起こし、話者分離、キーワードバイアスに対応します。

モデル情報
利用規約とライセンスリンク
詳細情報リンク
ゼロデータ保持はい
料金Cloudflare ダッシュボードで料金を見る

使い方

const response = await env.AI.run(
  'xai/grok-stt',
  { url: 'https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.mp3' },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "xai/grok-stt",
  "input": {
    "url": "https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.mp3"
  }
}'
How old is the Brooklyn Bridge?
{
  "state": "Completed",
  "result": {
    "text": "How old is the Brooklyn Bridge?",
    "language": "English",
    "duration": 1.85,
    "words": [
      {
        "text": "How",
        "start": 0.14,
        "end": 0.28
      },
      {
        "text": "old",
        "start": 0.4,
        "end": 0.6
      },
      {
        "text": "is",
        "start": 0.65,
        "end": 0.75
      },
      {
        "text": "the",
        "start": 0.81,
        "end": 0.89
      },
      {
        "text": "Brooklyn",
        "start": 0.95,
        "end": 1.29
      },
      {
        "text": "Bridge?",
        "start": 1.35,
        "end": 1.69
      }
    ]
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

言語と書式あり — Inverse Text Normalization を有効にし、読み上げられた数字を桁にします
const response = await env.AI.run(
  'xai/grok-stt',
  {
    url: 'https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.mp3',
    language: 'en',
    format: true,
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "xai/grok-stt",
  "input": {
    "url": "https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.mp3",
    "language": "en",
    "format": true
  }
}'
How old is the Brooklyn Bridge?
{
  "state": "Completed",
  "result": {
    "text": "How old is the Brooklyn Bridge?",
    "language": "English",
    "duration": 1.85,
    "words": [
      {
        "text": "How",
        "start": 0.14,
        "end": 0.28
      },
      {
        "text": "old",
        "start": 0.4,
        "end": 0.6
      },
      {
        "text": "is",
        "start": 0.65,
        "end": 0.75
      },
      {
        "text": "the",
        "start": 0.81,
        "end": 0.89
      },
      {
        "text": "Brooklyn",
        "start": 0.95,
        "end": 1.29
      },
      {
        "text": "Bridge?",
        "start": 1.35,
        "end": 1.69
      }
    ]
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}
キーワード付き話者分離 — 話者を識別し、固有名詞寄りに文字起こしします
const response = await env.AI.run(
  'xai/grok-stt',
  {
    url: 'https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.mp3',
    language: 'en',
    diarize: true,
    keyterm: ['Brooklyn', 'Manhattan'],
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "xai/grok-stt",
  "input": {
    "url": "https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.mp3",
    "language": "en",
    "diarize": true,
    "keyterm": [
      "Brooklyn",
      "Manhattan"
    ]
  }
}'
How old is the Brooklyn Bridge?
{
  "state": "Completed",
  "result": {
    "text": "How old is the Brooklyn Bridge?",
    "language": "English",
    "duration": 1.85,
    "words": [
      {
        "text": "How",
        "start": 0.14,
        "end": 0.28,
        "speaker": 0
      },
      {
        "text": "old",
        "start": 0.4,
        "end": 0.6,
        "speaker": 0
      },
      {
        "text": "is",
        "start": 0.65,
        "end": 0.75,
        "speaker": 0
      },
      {
        "text": "the",
        "start": 0.81,
        "end": 0.89,
        "speaker": 0
      },
      {
        "text": "Brooklyn",
        "start": 0.95,
        "end": 1.29,
        "speaker": 0
      },
      {
        "text": "Bridge?",
        "start": 1.35,
        "end": 1.69,
        "speaker": 0
      }
    ]
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}
フィラーを残す — フィラー(uh、um、er)を削除せず、文字起こしに残します
const response = await env.AI.run(
  'xai/grok-stt',
  {
    url: 'https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.mp3',
    language: 'en',
    filler_words: true,
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "xai/grok-stt",
  "input": {
    "url": "https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.mp3",
    "language": "en",
    "filler_words": true
  }
}'
How old is the Brooklyn Bridge?
{
  "state": "Completed",
  "result": {
    "text": "How old is the Brooklyn Bridge?",
    "language": "English",
    "duration": 1.85,
    "words": [
      {
        "text": "How",
        "start": 0.14,
        "end": 0.28
      },
      {
        "text": "old",
        "start": 0.4,
        "end": 0.6
      },
      {
        "text": "is",
        "start": 0.65,
        "end": 0.75
      },
      {
        "text": "the",
        "start": 0.81,
        "end": 0.89
      },
      {
        "text": "Brooklyn",
        "start": 0.95,
        "end": 1.29
      },
      {
        "text": "Bridge?",
        "start": 1.35,
        "end": 1.69
      }
    ]
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}
Data URI アップロード — 音声ファイルを base64 の data URI として直接渡します(`url` とは排他です)
const response = await env.AI.run(
  'xai/grok-stt',
  { file: 'data:audio/wav;base64,<...>' },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "xai/grok-stt",
  "input": {
    "file": "data:audio/wav;base64,<...>"
  }
}'
{
  "state": "Completed",
  "result": {
    "text": "",
    "language": "",
    "duration": 1
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

パラメーター

file
string音声ファイルです。data URI(`data:audio/...;base64,...`)、または gateway が取得してアップロードする HTTPS URL です。対応コンテナ: flac、mp3、mp4、m4a、mkv、ogg、opus、wav、aac。生形式(pcm、mulaw、alaw)も受け付けます。その場合は `audio_format` と `sample_rate` を指定します。gateway 側のサイズ上限は 25 MB です。`url` とは同時に使えません。
url
stringformat: urixAI がサーバー側で取得する音声ファイルの HTTPS URL です。`file` および `websocket` とは同時に使えません。gateway 側のサイズ上限はありません。
websocket
boolean音声からテキスト向けの WebSocket ストリーミングを有効にします。`true` の場合、リアルタイム書き起こし用の双方向 WebSocket を確立します。`file` および `url` とは同時に使えません。
audio_format
stringenum: pcm, mulaw, alawヘッダーなしの生音声向けの形式ヒントです。pcm、mulaw、alaw では必須です。mp3 や wav などのコンテナ形式では省略します。xAI が自動検出します。
sample_rate
integerminimum: -9007199254740991maximum: 9007199254740991サンプルレート(Hz)です。`audio_format` を指定したときは必須です。
language
string言語コードです(例: `en`、`fr`、`de`)。`format=true` と組み合わせて Inverse Text Normalization を有効にします。xAI は言語に関係なく書き起こします。指定すると、書き起こし内の数字や通貨の書式が有効になります。
format
boolean`true` の場合、Inverse Text Normalization を有効にします。話し言葉の数字や通貨を書き言葉に変換します(例: `one hundred dollars` → `$100`)。`language` の指定が必要です。
diarize
boolean`true` の場合、スピーカーダイアライゼーションを有効にします。応答の各単語に、検出した話者を示す整数の `speaker` が付きます。
filler_words
boolean`true` の場合、フィラー語(uh、um、er)を書き起こしに含めます。デフォルトは false で、フィラー語は除かれます。
multichannel
boolean`true` の場合、各音声チャンネルを独立して書き起こします。結果は `channels` 配列で返ります。チャンネル数は 2 以上が必要です。
channels
integerminimum: 2maximum: 8音声チャンネル数です(2〜8)。マルチチャンネルの生音声でのみ必須です。コンテナ形式では自動検出します。
text
string書き起こし全文です。
language
string検出した言語名です(例: `English`、`French`)。
duration
number音声の長さ(秒、小数点以下 2 桁)です。

API スキーマ(Raw)

Input
Output

役に立ちましたか?