语音配置
概述
speech 对象允许您直接在 librechat.yaml 配置文件中配置文本转语音 (TTS) 和语音转文本 (STT) 提供商。这使得无需用户配置自己的 API 密钥即可启用服务器端语音服务。
speech 下的字段:
tts- Text-to-Speech 提供商配置stt- Speech-to-Text 提供商配置speechTab- 语音功能的默认 UI 设置
注意:
- 可以同时配置多个提供商
- 用户可以从可用选项中选择他们偏好的提供商
- 配置文件中的 API keys 应使用环境变量引用以确保安全
示例
speech:
tts:
openai:
apiKey: "${TTS_API_KEY}"
model: "tts-1"
voices: ["alloy", "echo", "fable", "onyx", "nova", "shimmer"]
elevenlabs:
apiKey: "${ELEVENLABS_API_KEY}"
model: "eleven_multilingual_v2"
voices: ["voice-id-1", "voice-id-2"]
stt:
openai:
apiKey: "${STT_API_KEY}"
model: "whisper-1"
speechTab:
conversationMode: true
advancedMode: false
speechToText: true
textToSpeech: truetts
tts 对象用于配置 Text-to-Speech 提供商。可以配置多个提供商,用户可以选择使用其中任意一个。
openai
使用 tts-1 或 tts-1-hd 等模型进行 OpenAI TTS 配置。
| Key | Type | Description | Example |
|---|---|---|---|
| url | String | 自定义 API URL(可选)。用于兼容 OpenAI 的 endpoint。 | |
| apiKey | String | OpenAI API 密钥。使用环境变量引用。 | Required |
| model | String | 要使用的 TTS 模型(例如 "tts-1", "tts-1-hd")。 | Required |
| voices | Array of Strings | 用户可选择的可用语音选项。 | Required |
示例:
tts:
openai:
apiKey: "${TTS_API_KEY}"
model: "tts-1"
voices: ["alloy", "echo", "fable", "onyx", "nova", "shimmer"]azureOpenAI
Azure OpenAI TTS 配置。
| Key | Type | Description | Example |
|---|---|---|---|
| instanceName | String | Azure OpenAI 实例名称。 | Required |
| apiKey | String | Azure OpenAI API 密钥。 | Required |
| deploymentName | String | TTS 模型的部署名称。 | Required |
| apiVersion | String | Azure OpenAI API 版本。 | Required |
| model | String | TTS 模型标识符。 | Required |
| voices | Array of Strings | 可用的语音选项。 | Required |
示例:
tts:
azureOpenAI:
instanceName: "my-azure-instance"
apiKey: "${AZURE_TTS_API_KEY}"
deploymentName: "tts-deployment"
apiVersion: "2024-02-15-preview"
model: "tts-1"
voices: ["alloy", "echo", "nova"]elevenlabs
用于高质量语音合成的 ElevenLabs TTS 配置。
| Key | Type | Description | Example |
|---|---|---|---|
| url | String | 自定义 API URL(可选)。 | |
| websocketUrl | String | 用于流式传输的 WebSocket URL(可选)。 | |
| apiKey | String | ElevenLabs API key | Required |
| model | String | ElevenLabs 模型(例如 "eleven_multilingual_v2")。 | Required |
| voices | Array of Strings | 可供选择的 Voice ID。 | Required |
| voice_settings | Object | 语音自定义设置(可选)。 | |
| pronunciation_dictionary_locators | Array of Strings | 发音词典 ID(可选)。 |
voice_settings 子键:
| Key | Type | Description | Example |
|---|---|---|---|
| similarity_boost | Number | 语音相似度增强 (0-1)。 | |
| stability | Number | 语音稳定性 (0-1)。 | |
| style | Number | 风格夸张程度 (0-1)。 | |
| use_speaker_boost | Boolean | 启用扬声器增强 |
示例:
tts:
elevenlabs:
apiKey: "${ELEVENLABS_API_KEY}"
model: "eleven_multilingual_v2"
voices: ["21m00Tcm4TlvDq8ikWAM", "AZnzlk1XvdvUeBnXmlld"]
voice_settings:
stability: 0.5
similarity_boost: 0.75
use_speaker_boost: truelocalai
用于自托管语音合成的 LocalAI TTS 配置。
| Key | Type | Description | Example |
|---|---|---|---|
| url | String | LocalAI 服务器 URL。 | Required |
| apiKey | String | 如果启用了身份验证,则为 API key(可选)。 | |
| voices | Array of Strings | 可用的语音模型。 | Required |
| backend | String | 要使用的 TTS 后端(例如 "piper")。 | Required |
示例:
tts:
localai:
url: "http://localhost:8080"
voices: ["en-us-amy-low", "en-us-danny-low"]
backend: "piper"stt
stt 对象用于配置语音转文字(Speech-to-Text)提供商。
openai
OpenAI Whisper STT 配置。
| Key | Type | Description | Example |
|---|---|---|---|
| url | String | 自定义 API URL(可选)。用于兼容 OpenAI 的 endpoint。 | |
| apiKey | String | OpenAI API 密钥。使用环境变量引用。 | Required |
| model | String | 要使用的 STT 模型(例如 "whisper-1")。 | Required |
示例:
stt:
openai:
apiKey: "${STT_API_KEY}"
model: "whisper-1"azureOpenAI
Azure OpenAI Whisper STT 配置。
| Key | Type | Description | Example |
|---|---|---|---|
| instanceName | String | Azure OpenAI 实例名称。 | Required |
| apiKey | String | Azure OpenAI API 密钥。 | Required |
| deploymentName | String | Whisper 模型的部署名称。 | Required |
| apiVersion | String | Azure OpenAI API 版本。 | Required |
示例:
stt:
azureOpenAI:
instanceName: "my-azure-instance"
apiKey: "${AZURE_STT_API_KEY}"
deploymentName: "whisper-deployment"
apiVersion: "2024-02-15-preview"speechTab
speechTab 对象用于配置语音功能的默认 UI 设置。这些设置控制用户在语音设置面板中默认看到的内容。
| Key | Type | Description | Example |
|---|---|---|---|
| conversationMode | Boolean | 默认启用对话模式。 | false |
| advancedMode | Boolean | 默认显示高级语音设置。 | false |
| speechToText | Boolean or Object | 默认启用 STT,或配置详细的 STT 设置。 | false |
| textToSpeech | Boolean or Object | 默认启用 TTS,或配置详细的 TTS 设置。 | false |
speechToText (Object format)
当使用对象而非布尔值时:
| Key | Type | Description | Example |
|---|---|---|---|
| engineSTT | String | 默认 STT 引擎。选项:`"openai"`,`"azureOpenAI"`。 | |
| languageSTT | String | STT 的默认语言。 | |
| autoTranscribeAudio | Boolean | 自动转录音频消息。 | |
| decibelValue | Number | 语音检测的分贝阈值。 | |
| autoSendText | Number | 自动发送转录文本前的延迟(毫秒,0 表示禁用)。 |
textToSpeech (对象格式)
当使用对象而非布尔值时:
| Key | Type | Description | Example |
|---|---|---|---|
| engineTTS | String | 默认 TTS 引擎。选项:`"openai"`、`"azureOpenAI"`、`"elevenlabs"`、`"localai"`。 | |
| voice | String | 默认语音选择。 | |
| languageTTS | String | TTS 的默认语言。 | |
| automaticPlayback | Boolean | 自动播放 TTS 响应。 | |
| playbackRate | Number | 默认播放速度(1.0 = 正常)。范围:0.25–4.0。 | |
| cacheTTS | Boolean | 缓存 TTS 音频以供重复播放。 |
示例:
speechTab:
conversationMode: false
advancedMode: false
speechToText:
engineSTT: "openai"
autoTranscribeAudio: true
decibelValue: -45
textToSpeech:
engineTTS: "openai"
voice: "nova"
automaticPlayback: false
playbackRate: 1.0
cacheTTS: true完整示例
version: 1.3.10
cache: true
speech:
tts:
openai:
apiKey: "${TTS_API_KEY}"
model: "tts-1-hd"
voices: ["alloy", "echo", "fable", "onyx", "nova", "shimmer"]
elevenlabs:
apiKey: "${ELEVENLABS_API_KEY}"
model: "eleven_multilingual_v2"
voices: ["21m00Tcm4TlvDq8ikWAM", "AZnzlk1XvdvUeBnXmlld"]
voice_settings:
stability: 0.5
similarity_boost: 0.75
stt:
openai:
apiKey: "${STT_API_KEY}"
model: "whisper-1"
speechTab:
conversationMode: false
advancedMode: false
speechToText: true
textToSpeech:
engineTTS: "openai"
voice: "nova"
automaticPlayback: false注意事项
- 在配置文件中,请始终使用环境变量引用(例如
${API_KEY})来设置 API 密钥。 - 可以配置多个 TTS 提供商;用户可以在 UI 中选择其首选选项。
speechTab设置定义了用户可以在其个人设置中覆盖的默认值- 有关详细的功能文档,请参阅 Speech to Text & Text to Speech
这篇指南怎么样?