dfvips / xunfeixinghuo

Implement AI intelligent dialogue with Iflytek Starfire cognitive model in Python for real-time questioning and answering. Python实现 讯飞星火API
MIT License
42 stars 10 forks source link

langdetect.lang_detect_exception.LangDetectException: No features in text. #3

Closed xxhg closed 1 year ago

xxhg commented 1 year ago

Traceback (most recent call last): File "/xunfeixinghuo/xunfei.py", line 147, in ask_question(ques, chat_id) File "/xunfeixinghuo/xunfei.py", line 104, in ask_question text2audio.done(response_text, question) File "/xunfeixinghuo/text2audio.py", line 174, in done choice = get_assist(text) ^^^^^^^^^^^^^^^^ File "/xunfeixinghuo/text2audio.py", line 23, in get_assist if (is_english(text)): ^^^^^^^^^^^^^^^^ File "/xunfeixinghuo/text2audio.py", line 32, in is_english language = detect(text) ^^^^^^^^^^^^ File "/python/lib/python3.11/site-packages/langdetect/detector_factory.py", line 130, in detect return detector.detect() ^^^^^^^^^^^^^^^^^ File "/python/lib/python3.11/site-packages/langdetect/detector.py", line 136, in detect probabilities = self.get_probabilities() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/python/lib/python3.11/site-packages/langdetect/detector.py", line 143, in get_probabilities self._detect_block() File "/python/lib/python3.11/site-packages/langdetect/detector.py", line 150, in _detect_block raise LangDetectException(ErrorCode.CantDetectError, 'No features in text.') langdetect.lang_detect_exception.LangDetectException: No features in text.

这个错误是什么问题啊?

dfvips commented 1 year ago

这个错误提示表明在执行程序时出现了一个异常,具体是由于"langdetect"模块检测文本语言时无法提取特征造成的。这个错误通常发生在文本中没有足够的特征来确定语言时。 根据错误信息,你可以把text2audio.py代码里面判断是否英语的地方注释掉,改成固定回复的语言模型,中文模型都支持英语朗读,只是没有英语朗读者那么口语流畅。

xxhg commented 1 year ago

这个错误提示表明在执行程序时出现了一个异常,具体是由于"langdetect"模块检测文本语言时无法提取特征造成的。这个错误通常发生在文本中没有足够的特征来确定语言时。 根据错误信息,你可以把text2audio.py代码里面判断是否英语的地方注释掉,改成固定回复的语言模型,中文模型都支持英语朗读,只是没有英语朗读者那么口语流畅。

好的,谢谢。