Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat

语音配置

概述

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: true

tts

tts 对象用于配置 Text-to-Speech 提供商。可以配置多个提供商,用户可以选择使用其中任意一个。

openai

使用 tts-1tts-1-hd 等模型进行 OpenAI TTS 配置。

KeyTypeDescriptionExample
urlString自定义 API URL(可选)。用于兼容 OpenAI 的 endpoint。
apiKeyStringOpenAI API 密钥。使用环境变量引用。Required
modelString要使用的 TTS 模型(例如 "tts-1", "tts-1-hd")。Required
voicesArray of Strings用户可选择的可用语音选项。Required

示例:

tts:
  openai:
    apiKey: "${TTS_API_KEY}"
    model: "tts-1"
    voices: ["alloy", "echo", "fable", "onyx", "nova", "shimmer"]

azureOpenAI

Azure OpenAI TTS 配置。

KeyTypeDescriptionExample
instanceNameStringAzure OpenAI 实例名称。Required
apiKeyStringAzure OpenAI API 密钥。Required
deploymentNameStringTTS 模型的部署名称。Required
apiVersionStringAzure OpenAI API 版本。Required
modelStringTTS 模型标识符。Required
voicesArray 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 配置。

KeyTypeDescriptionExample
urlString自定义 API URL(可选)。
websocketUrlString用于流式传输的 WebSocket URL(可选)。
apiKeyStringElevenLabs API keyRequired
modelStringElevenLabs 模型(例如 "eleven_multilingual_v2")。Required
voicesArray of Strings可供选择的 Voice ID。Required
voice_settingsObject语音自定义设置(可选)。
pronunciation_dictionary_locatorsArray of Strings发音词典 ID(可选)。

voice_settings 子键:

KeyTypeDescriptionExample
similarity_boostNumber语音相似度增强 (0-1)。
stabilityNumber语音稳定性 (0-1)。
styleNumber风格夸张程度 (0-1)。
use_speaker_boostBoolean启用扬声器增强

示例:

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: true

localai

用于自托管语音合成的 LocalAI TTS 配置。

KeyTypeDescriptionExample
urlStringLocalAI 服务器 URL。Required
apiKeyString如果启用了身份验证,则为 API key(可选)。
voicesArray of Strings可用的语音模型。Required
backendString要使用的 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 配置。

KeyTypeDescriptionExample
urlString自定义 API URL(可选)。用于兼容 OpenAI 的 endpoint。
apiKeyStringOpenAI API 密钥。使用环境变量引用。Required
modelString要使用的 STT 模型(例如 "whisper-1")。Required

示例:

stt:
  openai:
    apiKey: "${STT_API_KEY}"
    model: "whisper-1"

azureOpenAI

Azure OpenAI Whisper STT 配置。

KeyTypeDescriptionExample
instanceNameStringAzure OpenAI 实例名称。Required
apiKeyStringAzure OpenAI API 密钥。Required
deploymentNameStringWhisper 模型的部署名称。Required
apiVersionStringAzure 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 设置。这些设置控制用户在语音设置面板中默认看到的内容。

KeyTypeDescriptionExample
conversationModeBoolean默认启用对话模式。false
advancedModeBoolean默认显示高级语音设置。false
speechToTextBoolean or Object默认启用 STT,或配置详细的 STT 设置。false
textToSpeechBoolean or Object默认启用 TTS,或配置详细的 TTS 设置。false

speechToText (Object format)

当使用对象而非布尔值时:

KeyTypeDescriptionExample
engineSTTString默认 STT 引擎。选项:`"openai"`,`"azureOpenAI"`。
languageSTTStringSTT 的默认语言。
autoTranscribeAudioBoolean自动转录音频消息。
decibelValueNumber语音检测的分贝阈值。
autoSendTextNumber自动发送转录文本前的延迟(毫秒,0 表示禁用)。

textToSpeech (对象格式)

当使用对象而非布尔值时:

KeyTypeDescriptionExample
engineTTSString默认 TTS 引擎。选项:`"openai"`、`"azureOpenAI"`、`"elevenlabs"`、`"localai"`。
voiceString默认语音选择。
languageTTSStringTTS 的默认语言。
automaticPlaybackBoolean自动播放 TTS 响应。
playbackRateNumber默认播放速度(1.0 = 正常)。范围:0.25–4.0。
cacheTTSBoolean缓存 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

这篇指南怎么样?