Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced TTS with human voice playback in say() function. #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

menacingly-coded
Copy link

##This PR replaces the Text-To-Speech (TTS) engine with pre-recorded human voice audio for speech output in the Maths Tutor application. Instead of synthesizing speech dynamically, the system now plays corresponding human voice recordings from the sounds/ directory.

##Changes Implemented
✅ Modified say() function in speech.py
-Instead of using speechd (TTS engine), the function now plays pre-recorded .ogg files stored in the sounds/ folder.
-The system maps specific phrases to corresponding human-voice audio files.

✅ Added Audio Playback Logic
-Integrated the pygame.mixer module to handle audio playback.
-Implemented error handling for missing sound files.

✅ Updated Speech Handling Flow
-The function now first checks for an available human voice file before falling back to the TTS engine (if necessary).

##Implementation Details
-A dictionary maps common phrases (e.g., "excellent", "good", "wrong answer") to their respective .ogg files.
-If a match is found, the function plays the audio using pygame.mixer.
-If no matching audio is found, the system defaults to TTS (if enabled).

##How to Test the Changes
-Run the application and perform an action that triggers speech output.
-Check if human voice playback occurs instead of TTS-generated speech.
-If the audio doesn't play, verify that .ogg files exist in the sounds/ directory.
-If a file is missing, the function should handle it gracefully and log an error.

##Why This Change?
🔹 Improves user experience by using natural human voice instead of robotic TTS.
🔹 Eliminates dependency on external TTS engines, making the app more efficient.
🔹 Provides a consistent and engaging audio experience for users, especially young learners.

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.

1 participant