Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用poetry运行emotext报错 #3

Closed
0x0129 opened this issue Mar 8, 2023 · 4 comments
Closed

使用poetry运行emotext报错 #3

0x0129 opened this issue Mar 8, 2023 · 4 comments

Comments

@0x0129
Copy link

0x0129 commented Mar 8, 2023

D:\AI Vtuber\emotext>poetry run python emotext/httpapi.py --port 9003
[emotext] pkl file unavailable, loading words from D:\AI Vtuber\emotext\emotext\data\dict.csv...
Traceback (most recent call last):
File "D:\AI Vtuber\emotext\emotext\httpapi.py", line 61, in
server = EmotextServer(host=args.host, port=args.port)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\AI Vtuber\emotext\emotext\httpapi.py", line 25, in init
self.emotext = Emotions()
^^^^^^^^^^
File "D:\AI Vtuber\emotext\emotext\emotext.py", line 160, in init
self._words_from_dict()
File "D:\AI Vtuber\emotext\emotext\emotext.py", line 168, in _words_from_dict
self._read_dict(f)
File "D:\AI Vtuber\emotext\emotext\emotext.py", line 172, in _read_dict
reader.next() # skip header
^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 4: illegal multibyte sequence

D:\AI Vtuber\emotext>

@0x0129
Copy link
Author

0x0129 commented Mar 8, 2023

编码问题?

@cdfmlr
Copy link
Owner

cdfmlr commented Mar 8, 2023

编码问题?

是的。Windwos 的机器应该在打开的时候可能要额外加一个编码参数,强制用 utf-8:

https://github.com/cdfmlr/emotext/blob/54a10dbb48060075846f466f92eda30d5cafff0f/emotext/emotext.py#L167

如果需要你可以先改一下,直接 pr 给我。或者我之后再改。

p.s. 我不假设该项目的任何代码能在 Windows 系统正确运行。尤其是 TTS 模块现在完全依赖于 macOS
,而且和 muvtuberdriver 耦合在一起,之后会重构分离出来,然后再用平台无关的方式重新实现。(如果一定要现在在 Windows 运行的话, Windows 似乎也有一个类似 macOS say 的命令,好多年没用我记不清了,至少系统中是肯定有 tts 支持的,应该也容易临时上胶合层兼容)

@0x0129
Copy link
Author

0x0129 commented Mar 8, 2023

似乎要加一个encoding='utf-8'

@0x0129 0x0129 closed this as completed Mar 8, 2023
@0x0129
Copy link
Author

0x0129 commented Mar 8, 2023

https://github.com/cdfmlr/emotext/blob/54a10dbb48060075846f466f92eda30d5cafff0f/emotext/emotext.py#L167
改成with open(self.dict_path,encoding='utf-8') as f:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants