Fix TTS
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user