This commit is contained in:
2025-04-22 18:31:25 +02:00
parent 4205af4da6
commit cd40d8fe47
4 changed files with 95 additions and 22 deletions

View File

@@ -76,15 +76,21 @@ export class AccessibilityManager extends EventEmitter {
* Speak text using text-to-speech
*/
public speak(text: string): void {
console.log('AccessibilityManager.speak() called with text:', text.substring(0, 50) + (text.length > 50 ? '...' : ''));
// Skip if speech is disabled
if (!this.isSpeechEnabled || !this.speechSynthesis) {
// console.log('Speech is disabled, not speaking');
console.log('Speech is disabled or speechSynthesis is null:', {
isSpeechEnabled: this.isSpeechEnabled,
speechSynthesis: !!this.speechSynthesis
});
return;
}
try {
// Clean and truncate text to prevent issues with large blocks
const cleanText = this.cleanTextForSpeech(text);
console.log('Cleaned text for speech:', cleanText.substring(0, 50) + (cleanText.length > 50 ? '...' : ''));
// Only speak if there's meaningful text after cleaning
if (cleanText && cleanText.trim().length > 0) {
@@ -117,10 +123,12 @@ export class AccessibilityManager extends EventEmitter {
utterance.voice = this.speechOptions.voice;
}
// Speak the text
console.log('Calling speechSynthesis.speak()');
this.speechSynthesis.speak(utterance);
console.log('speechSynthesis.speak() called successfully');
} else {
console.log('Not speaking - cleaned text is empty');
}
} catch (error) {
console.error('Error in speak:', error);