locked
Text to speech with Chinese characters RRS feed

  • Question

  • Hi,

    I am having a hard time getting text to speech working in Chinese. Everything works well when using English, even trying to speech a text such as "1234" works in Chinese works fine (the voice outputs "yi er san si" as expected), but inputing Chinese characters does not work at all. In fact, the API return error 400 without any details.

    I trying several things, from forcing the request encoding to UTF-8 to encoding my Chinese string into raw Unicode like "\u597D\u7684\uFF01\u0020\u8BA9\u6211\u4EEC\u5F00\u59CB\u8BF4". Nothing is working...

    Does anyone knows how to properly encode Chinese characters to succeed in text to speech in Chinese?

    Thanks in advance!

    Wednesday, December 14, 2016 6:49 AM

Answers

  • Alright, finally found the solution. Unicode, OK, but it was not the right format. Using below convert function works:

    function convert(s) {
        return s.split('').map(function(c) {
            return '&#' + c.charCodeAt(0) + ';';
        }).join('');
    }

    Should be notified in the doc though.

    • Marked as answer by Morphet81 Wednesday, December 14, 2016 7:56 AM
    Wednesday, December 14, 2016 7:56 AM