> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# キータームプロンプティング

> **Note**
>
> **ハウツーガイド** · [スピーチtoテキストのクイックスタート](/docs/ja/eleven-api/guides/cookbooks/speech-to-text)を完了していることを前提としています。

## 概要

> **Warning**
>
> キータームプロンプティングはScribe v2、Scribe v2 Medical（バッチ）、Scribe v2 Realtimeで利用でき、追加料金がかかります。詳しい料金については、[API料金ページ](https://elevenlabs.io/pricing?price.section=speech_to_text\&price.sections=speech_to_text,speech_to_text#pricing-table)
> をご覧ください。

キータームプロンプティングは、単語やフレーズを指定して、モデルがそれらを文字起こししやすくする機能です。プロダクト名、人名、その他の固有用語など、オーディオ内であまり一般的ではない特定の単語や文を文字起こしする際に役立ちます。キータームは、他のモデルで提供されるバイアス付きキーワードやカスタム語彙よりも強力です。コンテキストに基づいて、その用語を文字起こしすべきかどうかを判断するためです。

|                | バッチ（Scribe v2／Scribe v2 Medical） | リアルタイム（Scribe v2 Realtime） |
| -------------- | -------------------------------- | -------------------------- |
| キータームの最大数      | 1000                             | 50                         |
| キータームあたりの最大文字数 | 50                               | 20                         |

たとえば、会社名が一般的なフレーズではない場合や、独自のスペルや発音がある場合は、キータームを使用してモデルが正しく文字起こしできるようにします。次のオーディオを例にします。

<elevenlabs-audio-player audio-title="Company name example" audio-src="https://storage.googleapis.com/eleven-public-cdn/documentation_assets/audio/stt-keyterm-prompting.mp3" />

キータームプロンプティングを使用しない場合、モデルは上記を次のように文字起こしする可能性があります。

```
I work at eleven labs.
```

この表記では会社名のスタイルが誤っています。キータームプロンプティングを使用すると、モデルが正しいスペルとスタイルで文字起こしするようにできます。

```
I work at ElevenLabs.
```

### コンテキスト

モデルはコンテキストを利用して、用語を文字起こしすべきかどうかを判断できます。キータームとして「ElevenLabs」を指定すると、上記のオーディオは想定どおりに文字起こしされます。一方で、モデルはコンテキストに基づき、次の内容も正しく文字起こしできます。

<elevenlabs-audio-player audio-title="Context example" audio-src="https://storage.googleapis.com/eleven-public-cdn/documentation_assets/audio/stt-keyterm-prompting-context.mp3" />

出力される文字起こしは次のとおりです。

```
I've worked at many labs. In fact I've worked at eleven labs.
```

## バッチ文字起こし

キータームプロンプティングは、`convert`メソッドに`keyterms`パラメータを渡すことで、バッチのスピーチtoテキストAPIに統合できます。

```python maxLines=0 {22-24}
import os
from dotenv import load_dotenv
from io import BytesIO
import requests
from elevenlabs.client import ElevenLabs

load_dotenv()

elevenlabs = ElevenLabs(
    api_key=os.getenv("ELEVENLABS_API_KEY"),
)

audio_url = (
    "https://storage.googleapis.com/eleven-public-cdn/documentation_assets/audio/stt-keyterm-prompting.mp3"
)
response = requests.get(audio_url)
audio_data = BytesIO(response.content)

transcription = elevenlabs.speech_to_text.convert(
    file=audio_data,
    model_id="scribe_v2", # Model to use
    # Keyterms to prompt the model with.
    # Up to 1000 keyterms can be provided, with a maximum length of 50 characters each
    keyterms=["ElevenLabs"],
)

print(transcription)
```

```typescript maxLines=0 {16-18}
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
import "dotenv/config";

const elevenlabs = new ElevenLabsClient({
  apiKey: process.env.ELEVENLABS_API_KEY,
});

const response = await fetch(
  "https://storage.googleapis.com/eleven-public-cdn/documentation_assets/audio/stt-keyterm-prompting.mp3"
);
const audioBlob = new Blob([await response.arrayBuffer()], { type: "audio/mp3" });

const transcription = await elevenlabs.speechToText.convert({
  file: audioBlob,
  modelId: "scribe_v2", // Model to use
  // Keyterms to prompt the model with.
  // Up to 1000 keyterms can be provided, with a maximum length of 50 characters each
  keyterms: ["ElevenLabs"],
});

console.log(transcription);
```

## リアルタイムストリーミング

キータームプロンプティングは、[リアルタイムスピーチtoテキストWebSocket API](/docs/ja/eleven-api/guides/how-to/speech-to-text/realtime/client-side-streaming)でも利用できます。接続時に`keyterms`パラメータを渡してください。

```python
connection = await elevenlabs.speech_to_text.realtime.connect(RealtimeUrlOptions(
    model_id="scribe_v2_realtime",
    keyterms=["ElevenLabs"],
))
```

```typescript
const connection = await elevenlabs.speechToText.realtime.connect({
  modelId: "scribe_v2_realtime",
  keyterms: ["ElevenLabs"],
});
```

WebSocket APIを直接使用する場合は、キータームをクエリパラメータとして渡します。

```
wss://api.elevenlabs.io/v1/speech-to-text/realtime?model_id=scribe_v2_realtime&keyterms=ElevenLabs&keyterms=AnotherTerm
```

## 次のステップ

#### [APIリファレンス](/docs/ja/api-reference/speech-to-text)

スピーチtoテキストAPIの完全なリファレンスとパラメータ。

#### [エンティティ検出](/docs/ja/eleven-api/guides/how-to/speech-to-text/batch/entity-detection)

文字起こし内の名前、日付、場所などのエンティティを自動的に検出してラベル付けします。