mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00
fix: prevent duplicate speech synthesis fallback in recording.js
This commit is contained in:
parent
b86d8099f1
commit
7cee3aa1f1
1 changed files with 11 additions and 2 deletions
|
@ -211,17 +211,26 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Create and play audio
|
// Create and play audio
|
||||||
const audio = new Audio(audioPath);
|
const audio = new Audio(audioPath);
|
||||||
|
|
||||||
|
// Flag to track if we've already used the TTS fallback
|
||||||
|
let fallbackUsed = false;
|
||||||
|
|
||||||
// Error handling with fallback to browser TTS
|
// Error handling with fallback to browser TTS
|
||||||
audio.onerror = () => {
|
audio.onerror = () => {
|
||||||
console.warn(`Failed to load audio: ${audioPath}`);
|
console.warn(`Failed to load audio: ${audioPath}`);
|
||||||
useBrowserTTS(text);
|
if (!fallbackUsed) {
|
||||||
|
fallbackUsed = true;
|
||||||
|
useBrowserTTS(text);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Play the audio
|
// Play the audio
|
||||||
audio.play().catch(e => {
|
audio.play().catch(e => {
|
||||||
console.warn(`Error playing audio: ${e.message}`);
|
console.warn(`Error playing audio: ${e.message}`);
|
||||||
// Also fall back to browser TTS if play() fails
|
// Also fall back to browser TTS if play() fails
|
||||||
useBrowserTTS(text);
|
if (!fallbackUsed) {
|
||||||
|
fallbackUsed = true;
|
||||||
|
useBrowserTTS(text);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue