feat: add spelling correction layer for child users in TTS#147
Open
shivprasad08 wants to merge 1 commit into
Open
feat: add spelling correction layer for child users in TTS#147shivprasad08 wants to merge 1 commit into
shivprasad08 wants to merge 1 commit into
Conversation
Young children often spell phonetically (e.g. 'skool' for 'school'). Adds a lightweight correction layer using pyspellchecker before passing text to Kokoro TTS. - Internal correction only - does not change what the child typed - Gracefully falls back if pyspellchecker is not installed - Logs corrections for debugging Relates to sugarlabs#50
There was a problem hiding this comment.
Pull request overview
Adds an “invented spelling” correction step before TTS so phonetic spellings from child users are more likely to be pronounced correctly.
Changes:
- Introduces an optional
pyspellchecker-basedcorrect_spelling()helper inspeech.py. - Applies spelling correction in
Speech.speak()before generating audio. - Adds
pyspellcheckertorequirements.txt.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| speech.py | Adds spellchecker import + correct_spelling() and applies it in speak() prior to TTS. |
| requirements.txt | Adds pyspellchecker dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+45
to
+49
| words = text.split() | ||
| corrected = [] | ||
| for word in words: | ||
| correction = spell.correction(word) | ||
| if correction and correction != word: |
Comment on lines
+38
to
+44
|
|
||
| def correct_spelling(text, lang='en'): | ||
| """Correct invented spellings for child users before TTS processing.""" | ||
| if not SPELLCHECKER_AVAILABLE: | ||
| return text | ||
| try: | ||
| spell = SpellChecker(language=lang) |
Comment on lines
+54
to
+55
| except Exception: | ||
| return text |
Comment on lines
392
to
396
| def speak(self, status, text): | ||
| self.make_pipeline() | ||
| # Correct invented spellings for child users before TTS | ||
| text = correct_spelling(text) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Young children often spell phonetically (e.g. 'skool' for 'school'). Adds a lightweight correction layer using pyspellchecker before passing text to Kokoro TTS.
Relates to #50