Weilbyte / tiktok-tts

Generate TikTok Text-to-Speech voices in your browser
https://weilbyte.github.io/tiktok-tts/
MIT License
393 stars 85 forks source link

Removed 300 character limit #28

Closed DevTest69 closed 1 year ago

DevTest69 commented 1 year ago

I created a function that splits the text into strings of 300 characters and adds them to an array. Then, for each string, I generate the audio content. After that, the audio bytes are joined together to generate the final audio file.

Weilbyte commented 1 year ago

Thank you, however, please correct me if I am wrong but this appears to be doing the splitting based on character count/length, which is wrong because it does not account for multi-byte UTF-8 characters (for example, 'abc' is 3 characters, and 3 bytes, but a Chinese character will be seen as 1 character, while it by itself is 3 bytes; because TikTok's API works with byte count, and not character count, it will not work).

Also, during testing, it does not appear to work (1st request is sent without any text, 2nd has the entirety of the text, causing API error).

DevTest69 commented 1 year ago

You are right, my function will not work with special characters. So this time, I made a new function that splits the text into 300-byte strings. I tried it with a few texts that contain special characters like emoji and Chinese letters, and it's working. Thank you for telling me about this problem!