Replaced TTS with human voice playback in say() function. #3
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.
##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.