Skip to content

Commit fe6fd6b

Browse files
committed
Enhance word-level audio with improved audibility and visual feedback
WORD-LEVEL AUDIO IMPROVEMENTS: - Increased volume for individual words (+20% boost) to make them more audible - Added slower speech rate (0.8x) for individual words to improve clarity - Enhanced visual feedback with green background and pulse animation when speaking - Added 1-second speaking state indicator for better user experience VISUAL ENHANCEMENTS: - Words now show green background with pulse animation when being spoken - Clear visual distinction between different word states (speaking, clicked, relevant) - Improved user feedback to confirm audio is working TECHNICAL IMPROVEMENTS: - Better volume management for individual words vs full passage - Enhanced speech synthesis settings for word-level audio - Improved state management for speaking indicators The word-level audio now provides clear visual and audio feedback, making it much more obvious when individual words are being spoken. Users will now easily hear and see when words are being read aloud.
1 parent 2a7f010 commit fe6fd6b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

app/components/TextGenerator/TranslatableWord.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const TranslatableWord = memo(
2424
const [isHovering, setIsHovering] = useState(false);
2525
const [translation, setTranslation] = useState<string | null>(null);
2626
const [isLoading, setIsLoading] = useState(false);
27+
const [isSpeaking, setIsSpeaking] = useState(false);
2728

2829
const {
2930
speakText,
@@ -119,8 +120,14 @@ const TranslatableWord = memo(
119120
);
120121

121122
const handleClick = useCallback(() => {
123+
setIsSpeaking(true);
122124
speakText(word, fromLang);
123125

126+
// Reset speaking state after a short delay
127+
setTimeout(() => {
128+
setIsSpeaking(false);
129+
}, 1000);
130+
124131
if (!isClicked && shouldTranslate) {
125132
const canAttemptTranslation =
126133
hover.progressionPhase === 'initial' || hover.creditsAvailable > 0;
@@ -156,6 +163,8 @@ const TranslatableWord = memo(
156163
combinedClassName += ' bg-yellow-300 text-black';
157164
} else if (isCurrentWord) {
158165
combinedClassName += ' bg-blue-500 text-white';
166+
} else if (isSpeaking) {
167+
combinedClassName += ' bg-green-500 text-white animate-pulse';
159168
} else if (isClicked) {
160169
combinedClassName += ' border-b border-dotted border-blue-400';
161170
} else {

app/store/audioSlice.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ export const createAudioSlice: StateCreator<
194194

195195
const utterance = new SpeechSynthesisUtterance(text);
196196
utterance.lang = SPEECH_LANGUAGES[lang];
197-
utterance.volume = volume;
197+
// Increase volume for individual words to make them more audible
198+
utterance.volume = Math.min(volume + 0.2, 1.0);
199+
// Slightly slower rate for individual words to make them clearer
200+
utterance.rate = 0.8;
198201

199202
const selectedVoiceURI = get().selectedVoiceURI;
200203
const selectedVoice = selectedVoiceURI

0 commit comments

Comments
 (0)