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

say does not speak Chinese with the right pronunciation #99

Open
awei12986 opened this issue Apr 2, 2020 · 3 comments
Open

say does not speak Chinese with the right pronunciation #99

awei12986 opened this issue Apr 2, 2020 · 3 comments

Comments

@awei12986
Copy link

Hello, The Chinese words '你好' should be pronunced 'ni hao'. But when I try this on windows 10

const Say = require('say').Say;
const say = new Say('win32');
say.speak('你好');

It says something sounds like 'huan chai' to me.
Is that a problem or should I install some more plug-in? Thanks.

@carsonDB
Copy link

Actually, nodejs encode string as utf-8 as default, so as say.js. But it seems that platform like win32 decodes it as GBK.
To fix this problem, I forked this repository, and add setEncoding method for Say Class.
You can setEncode('gbk') before speak.
Here is an example.

@silence19
Copy link

Actually, nodejs encode string as utf-8 as default, so as say.js. But it seems that platform like win32 decodes it as GBK.
To fix this problem, I forked this repository, and add setEncoding method for Say Class.
You can setEncode('gbk') before speak.
Here is an example.

Thanks for your idea, although I failed to act in your way, as the code doesn't know the 'gbk' code.
However, I worked this out with the encoding package 'iconv-lite' with your guidance. A new solution could be found in my repository, which can be an optional way for the other guys.

@trungphan
Copy link

The fix can be as simple as setting the command = 'chcp 65001 >NUL & powershell' instead of 'powershell' in the file win32.js. See https://stackoverflow.com/questions/68988696/set-utf-8-input-and-get-utf-8-output-through-pipe-to-from-powershell-with-c-c for more info about setting stdin's encoding to be UTF-8.

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

No branches or pull requests

5 participants