Closed stereonom closed 7 months ago
Hi @stereonom thanks for reporting. I assume you used Chrome? Which OS did you use?
Usually there has been a fix for that already: https://github.com/jankapunkt/easy-speech/blob/master/src/EasySpeech.js#L695 This is indeed an issue of it's own and not covered yet.
Let me investigate this
@jankapunkt yeah, I'm using Chrome – on MacOS. It's not a bug that only happens in the current versions. I'm seeing this since I started using easy-speech. (~July 2023)
I tested some other text and the maximum seems to vary a bit. My other test text worked with 4005 characters but failed with 4006. 🤷🏼♂️
@stereonom can you please paste/analyze the other texts with the code below? I have a strong assumption that the text exceeds 4096
bytes, which is what I get when analyzing the text above:
const text = '...' // the text from above
console.debug((new TextEncoder().encode(text)).length) // 4097
In JavaScript not every character is the same size: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#utf-16_characters_unicode_code_points_and_grapheme_clusters
I therefore assume, that all Google Voices have an upper limit of 4096
bytes of length. Please confirm this with your other texts.
If this is the case we can at least throw an error message if
4096
bytes of lengthI would like to avoid for now to automatically split the text and read the chunks as this will lead to multiple start/end events being fired. I'd rather leave this to the user as they might know much better where to split, how long the pause between the chunks etc. is best.
What do you think?
Yeah, u are right. My other text is 4.097 bytes long. 🤪
I understand that you will not include the auto-splitting because of the events. Perhaps it could be an option that is not enabled by default. So if it exceeds the limit, the error message could say it's to long and the developer should consider turning auto-splitting on with a link to some FAQ this problem with the events is descriibed. If not, an example would be great how to implement such feature. I think finding the rough point where to split. Then find the last dot or exclamation/question mark and do the split.
@stereonom would you mind reviewing (using the GitHub review functionality) this pull request: https://github.com/jankapunkt/easy-speech/pull/229
I recognized that (even in your demo), that the Google Voices (e.g. Google UK English Male) can't read very long text.
When I truncate my text to 4053 charactes it works. With 4054 it doesn't.
Here's the text: (4054 characters long. To make it work, just remove one character)
Is this a known thing? It there any variable I can check to get this max length?