Some strings cause an infinite loop
Closed this issue · 3 comments
When certain strings are inputted an infinite loop happens where nothing will be spoken, the window will hang, and the developer console will spam output. Tested on the most current version of both Firefox and Chrome.
Steps to replicate:
- Go to https://discordier.github.io/sam/
- Type
SoftwareSoftwareSoftwareSoftwarein the text box - Press "Say" button
Other strings that produce same results:
dhaaaxaxaxaxaxaxaxaxaxaxaxaxax
CurrentlyCurrentlyCurrentlyCurrently
It seems to have to do with the repetition of characters with no spaces. If you add spaces in between the words it works fine. (ex: Currently Currently Currently Currently)
My sam text to speech is not working
@maxpereira this was an intentional limitation in the C64 SAM, faithfully inherited by the JS port.
The manual says:
S.A.M. is capable of speaking only 2.5 seconds of speech without a break (this is the size of his "breath"). If the string to be spoken exceeds this, S.A.M. will insert short breaks every 2.5 seconds. [...] S.A.M. uses the spaces between words to makes his sentence-breaking decisions. If a single word requires more than 2.5 seconds to say, S.A.M. will not be able to insert his own breaks and will therefore be unable to say the word.
@discordier you may want to re-tag it as a feature request -- it's entirely valid and sensible, but it's not a bug :)
I have a downstream fix which will require some work to shape it into a PR...
You are right @tyomitch. I reflagged it but think we should alter this behaviour.
IMO this was only introduced to keep the buffer size of original sam small.
In the end, we should at least break if we encounter such a condition instead of freezing the browser.
