Feature/spanish typing game enhancements#31
Open
wizard-waqas wants to merge 3 commits into
Open
Conversation
added 3 commits
June 25, 2025 12:19
✨ New Features: 1. Sound Effects - Soft ding sound plays when user gets correct answers - Uses existing success.mp3 audio file - Volume set to 30% for pleasant experience 2. AI Voice Reading - Text-to-speech for Spanish words and sentences - Auto-plays in Phase 1 (individual words) and Phase 2 (complete sentence) - Manual play buttons with volume icons - Spanish language (es-ES) with slower rate for learning - Graceful fallback if speech synthesis not supported 3. Custom Sentence Addition - New input section on homepage - Users can enter English sentences for translation - AI-powered translation using OpenAI API - Word-by-word breakdown generation - Sentences stored in localStorage - Integration with Spanish typing game - Real-time feedback and error handling 4. Hint System for Phase 3 - Shows first letter of Spanish word after 3 seconds of inactivity - Timer resets when user starts typing - Visual hint indicator with lightbulb emoji - Doesn't count as error when hint is shown 🔧 Technical Improvements: - Enhanced TypeScript interfaces and error handling - Responsive design maintained across all new features - localStorage integration for persistent custom sentences - New API endpoint: /api/openai/translate-sentence - Improved game state management - Better user experience with loading states and feedback 📁 Files Added/Modified: - pages/extras/spanish-typing-game.tsx (enhanced with all new features) - pages/index.js (added sentence input section) - components/homepage/SentenceInputSection.tsx (new component) - pages/api/openai/translate-sentence.ts (new API endpoint) All features tested and working correctly with proper error handling and user feedback.
- Add null checking for OpenAI response content - Prevent JSON.parse() from receiving null values - Ensure proper error handling for missing translation results - Build now passes successfully with no TypeScript errors
- Remove sentence input from homepage - Integrate sentence input directly into Spanish typing game menu - Delete standalone SentenceInputSection component - Improve UX by placing custom sentence functionality where it's used - Maintain all translation and localStorage functionality
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Spanish typing game by adding custom sentence support, audio features, and improved text-to-speech integration. Key changes include:
- Combining default and custom sentences, with custom sentences loaded from localStorage (note potential key inconsistency).
- Integrating text-to-speech for words and sentences with new icons and success audio feedback.
- Adding a custom sentences section with translation functionality via a new OpenAI API endpoint.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pages/extras/spanish-typing-game.tsx | Enhanced game logic with audio, hint system, and custom sentence handling |
| pages/api/openai/translate-sentence.ts | New API endpoint for translating and saving custom sentences |
| // Get custom sentences from localStorage | ||
| const customSentences = typeof window !== 'undefined' | ||
| ? JSON.parse(localStorage.getItem('customSentences') || '[]') | ||
| : []; |
There was a problem hiding this comment.
There is an inconsistency in the localStorage key usage: custom sentences are loaded from the key 'customSentences' but are saved under 'customSpanishSentences' in the translation handler. Consider standardizing the key to ensure custom sentences are correctly persisted and retrieved.
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.
No description provided.