#5168 AttributeError: 'list' object has no attribute 'strip'

2401:e180* Posted at: 2 hours ago

程序内部错误:'list' object has no attribute 'strip':
Traceback (most recent call last):
File "videotrans\util\TestSTT.py", line 18, in run
File "videotrans\recognition\__init__.py", line 190, in run
File "videotrans\recognition\_base.py", line 94, in run
File "videotrans\recognition\_recognapi.py", line 88, in _exec
File "videotrans\util\help_srt.py", line 212, in get_subtitle_from_srt
AttributeError: 'list' object has no attribute 'strip'


=
system:Windows-10-10.0.26200-SP0
version:v4.02
frozen:True
language:zh
root_dir:C:/Users/stanl/Desktop/win-pyvideotrans-v4.02-0612

1 Replies

这是一个明确的 list object has no attribute 'strip' 错误,发生在 自定义语音识别 API(_recognapi.py 渠道的响应处理过程中。
原因:您的自定义 ASR API 返回的数据格式并不是预期的 SRT 字符串,而是被解析成了 Python list 列表,导致后续处理时无法调用 .strip()

解决方案:

  1. 检查自定义 API 的返回格式:确保接口返回的是一个完整且符合 SRT 标准格式的纯文本字符串,而不是 JSON 数组或列表。例如:

    1
    00:00:01,000 --> 00:00:04,000
    示例文本
  2. 若无需自定义 API,请切换为其他内置 ASR 渠道(如 faster-whisper(本地)OpenAI语音识别API),可立即避开此错误。
  3. 若必须使用自定义 API,请根据 自定义语音识别API 文档调整返回结构,确保返回格式严格符合软件要求。

请查阅相关文档:

Post Your Reply
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: ko-fi.com/jianchang512

Related resource