Closed adcb101 closed 10 months ago
谢谢你的建议!针对ValueError 的问题,应该是因为index不是int导致的,我在 https://github.com/Ifan24/GPT_subtitles/blob/0dcf8a60aaf5618225318f75f50bcc41ec29c6d3/translate_gpt.py#L107-L109 加上了检查index应该能解决这个error
关于'translation' 属性缺失的问题我有时也遇到过,这里加上了建议的方法 https://github.com/Ifan24/GPT_subtitles/blob/0dcf8a60aaf5618225318f75f50bcc41ec29c6d3/translate_gpt.py#L409-L418
并且如果真的报错了会在translator.log文件里显示并print出来,之后可以去看是具体是那一行错了,方便手动修改 https://github.com/Ifan24/GPT_subtitles/blob/e9d4cb66403f0b0a5c4a750c43f16793a8c0274e/translate_gpt.py#L655-L657
[ ...... { 'index': 136, 'original_text': 'right?' }, ...... ]
大佬,经过我大量翻译的经验有时会出现json 缺失translation属性的情况,这时候会报一个ValueError: invalid literal for int() with base 10: '{' 的错误,想到一种临时处理的办法,这种情况很少出现,一两个单词这样也没啥影响原文理解。 for obj in data["current_batch_subtitles_translation"]: if 'translation' not in obj: obj['translation'] = obj['original_text']