Skip to content

feat: add spelling correction layer for child users in TTS#147

Open
shivprasad08 wants to merge 1 commit into
sugarlabs:mainfrom
shivprasad08:feat/spelling-correction-child-users
Open

feat: add spelling correction layer for child users in TTS#147
shivprasad08 wants to merge 1 commit into
sugarlabs:mainfrom
shivprasad08:feat/spelling-correction-child-users

Conversation

@shivprasad08
Copy link
Copy Markdown

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 #50

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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-based correct_spelling() helper in speech.py.
  • Applies spelling correction in Speech.speak() before generating audio.
  • Adds pyspellchecker to requirements.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 thread speech.py
Comment on lines +45 to +49
words = text.split()
corrected = []
for word in words:
correction = spell.correction(word)
if correction and correction != word:
Comment thread speech.py
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 thread speech.py
Comment on lines +54 to +55
except Exception:
return text
Comment thread speech.py
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants