ElishaAz / Sayboard

An open-source on-device voice IME (keyboard) for Android using the Vosk library.
GNU General Public License v3.0
348 stars 23 forks source link

Fix Chinese & Japanese space issue #33

Closed moonbeamcelery closed 11 months ago

moonbeamcelery commented 11 months ago

Trying to close #16 myself. Passing locale to filter out whitespaces in languages where they are irrelevant.

ElishaAz commented 11 months ago

Thanks for the contribution!

A few things:

  1. Is there a chance that someone will want the spaces?
  2. The line text = text.replace("\\s".toRegex(), "") should be called inside VoskLocal (and VoskServer) as it's specific to that source (it shouldn't have placed the spaces in the first place)
  3. In shouldAddSpace, it's better to return before val cs = ic.getTextBeforeCursor(1, 0), as it's an expensive call

I can make the changes myself if you prefer

moonbeamcelery commented 11 months ago

I can make those changes!

  1. I can't say for sure for Japanese, but for Chinese there's no use case that needs those spaces between words. I don't understand why vosk adds them.
moonbeamcelery commented 11 months ago

Made required changes.

moonbeamcelery commented 11 months ago

While I have your attention. I'm thinking of implementing 29, but with trigger words to switch between them, like when you say "spelling mode" and pause, the app instead of committing the text, it calls this thing. What do you think?

There could be a list of phrases and the corresponding punctuation and character. I can hard-code it first and see where you want to put it.