deadpixelsociety / gdsam-plugin

Godot Plugin for SAM (Software Automatic Mouth)
MIT License
41 stars 1 forks source link

speak() freezes given the text "amgjgjjkldgjlkdgjklgfdjklfdgjklfdgjkl" #15

Closed jitspoe closed 1 year ago

jitspoe commented 1 year ago

Actually, it might just be the number of consecutive characters, as "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" also seems to break it. Completely freezes up on the call to var buffer = _synth.speak(phrase) as PackedByteArray

Looks like 29 characters is the maximum before it freezes.

deadpixelsociety commented 1 year ago

It's an issue with the base implementation of SAM that this plugin uses. It does have issues parsing long consecutive text which is why I made some effort to split sentences up into phrases and parse them in smaller chunks.

I can look over the original source and see if there's anything I can do for this specific case, but it's a rough bit of C code to follow.

Are you just wanting to make yelling/screaming sounds using the voice, or just limit testing it?

deadpixelsociety commented 1 year ago

Good news, that was easier to fix than I thought!

Updates coming soon.

jitspoe commented 1 year ago

Nice! I was just using it for a twitch chat bot tts redeem, and within the first few minutes somebody froze my bot with that string 😆

I ended up just truncating words to 29 characters and that seemed to fix it.

deadpixelsociety commented 1 year ago

@jitspoe Alright you should be good to go here. I'll submit these fixes to the Asset Library or you can just grab the updates from here. There's still a buffer cap so you can't spam a single long string of vowels and get infinite audio out of it, but it will no longer freeze when attempting to do so.

You can however space your infinite strings of vowels into separate words, just don't tell your chat that.

deadpixelsociety commented 1 year ago

Also, another change comes along with this, realizing I had my phonetic usage switched. You'll want to use phonetic as false now for default text to speech.

jitspoe commented 1 year ago

Thanks for the quick fix! Also noticed it would break on even short "uuuuuuu" sequences, but it looks like your patch fixed that as well.