#8944 自定义TTS API: {"error":{"message":"API key required. Pass it as \"Authorization: Bearer \", \"X-API-Key: \&

67.21**6 Posted at: 44 minutes ago

自定义TTS API: {"error":{"message":"API key required. Pass it as \"Authorization: Bearer \", \"X-API-Key: \", or — from Vapi, whose config cannot set either — the assistant's server.secret, which arrives as \"X-VAPI-SECRET\".","type":"authentication_error","param":null,"code":null}}
{'text': '你好啊,我亲爱的朋友,希望你的每一天都是美好愉快的!', 'role': 'Kim Chi', 'filename': 'F:/创业/win-pyvideotrans-v4.19/tmp/1904/1795529391.0135634-ttsapi.wav', 'tts_type': 36}
Traceback (most recent call last):
File "videotrans\util\ListenVoice.py", line 23, in run
File "videotrans\tts\__init__.py", line 154, in run
File "videotrans\tts\_base.py", line 98, in run
File "videotrans\tts\_base.py", line 201, in _exec
File "videotrans\tts\_base.py", line 161, in _local_mul_thread
File "videotrans\tts\_base.py", line 216, in _item_task
File "tenacity\__init__.py", line 338, in wrapped_f
File "tenacity\__init__.py", line 477, in call
File "tenacity\__init__.py", line 378, in iter
File "tenacity\__init__.py", line 400, in
File "concurrent\futures\_base.py", line 451, in result
File "concurrent\futures\_base.py", line 403, in __get_result
File "tenacity\__init__.py", line 480, in call
File "videotrans\tts\_ttsapi.py", line 77, in _run
videotrans.configure.excepts.StopTask: {"error":{"message":"API key required. Pass it as \"Authorization: Bearer \", \"X-API-Key: \", or — from Vapi, whose config cannot set either — the assistant's server.secret, which arrives as \"X-VAPI-SECRET\".","type":"authentication_error","param":null,"code":null}}


=
system:Windows-10-10.0.19044-SP0
version:v4.19
frozen:True
language:zh_CN
root_dir:F:/创业/win-pyvideotrans-v4.19

1 Replies

#1 DeepSeek reply at 44 minutes ago

这是因为自定义 TTS API 服务端未收到有效的认证请求头。错误响应明确指出需要三选一:Authorization: Bearer 、X-API-Key: 或 X-VAPI-SECRET,当前请求三者均未携带。

原因说明:软件的自定义 TTS API 渠道会按内置约定发送请求(含 api_key 字段),但你填写的这个接口本身并非软件要求的数据格式,而大概率是某个第三方或 Vapi 风格的服务端点,其认证方式、请求体字段与软件内置约定不匹配,因此被拒绝。

处理步骤:

  1. 先确认接口性质:错误信息提到 from Vapi, whose config cannot set either — the assistant's server.secret,说明该地址属于 Vapi 生态,认证依赖其平台侧配置,不能通过普通 Bearer 头简单调用。此类现成接口不建议直接填入自定义 TTS API 渠道。
  2. 若确为自建服务:确保你的服务接受 Authorization: Bearer ,并在软件 菜单 → 翻译设置 → 自定义 TTS API(或对应设置窗口)中正确填写 api_key 与接口地址,保存后重试。
  3. 若服务只认 X-API-Key 或 X-VAPI-SECRET:需要在你的服务端增加兼容逻辑,或将认证头改为标准的 Authorization: Bearer,因为软件内置请求只发送标准形式。
  4. 正确做法:自定义 TTS API 必须由你按软件约定的请求体与返回格式编写(如接收文本、角色、语速等字段,返回音频),而不是直接把第三方接口 URL 粘进去。若第三方兼容 OpenAI 接口格式,应改用对应的 OpenAI 兼容渠道而非自定义渠道。

另外:role 显示为 Kim Chi,请确认该角色名与你服务端支持的音色标识一致,避免认证通过后又出现角色不存在的错误。

请查阅相关文档:

Thinking...
Post Your Reply
If you have more than 50 messages, you will no longer receive an automatic reply. Please ask a new question!
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Dondate via ko-fi.com

Related resource