> 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**
>
> **操作指南** · 假设你已完成[语音转文本 快速入门](/docs/zh/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                     |

在批量转录中，每个关键术语最多还可包含 5 个词。

例如，如果公司名称不是常见短语，或拼写、发音独特，可使用关键术语确保模型正确转录。以下是一段音频：

<elevenlabs-audio-player audio-title="公司名称示例" 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="上下文示例" 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` 参数，可将关键术语提示集成到批量语音转文本 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);
```

## 实时流式传输

[实时语音转文本 WebSocket API](/docs/zh/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/zh/api-reference/speech-to-text)

完整的语音转文本 API 参考文档和参数说明。

#### [实体检测](/docs/zh/eleven-api/guides/how-to/speech-to-text/batch/entity-detection)

自动检测并标记转录文本中的姓名、日期和地点等实体。