mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +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
|
||||
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
|
||||
audio.onerror = () => {
|
||||
console.warn(`Failed to load audio: ${audioPath}`);
|
||||
useBrowserTTS(text);
|
||||
if (!fallbackUsed) {
|
||||
fallbackUsed = true;
|
||||
useBrowserTTS(text);
|
||||
}
|
||||
};
|
||||
|
||||
// Play the audio
|
||||
audio.play().catch(e => {
|
||||
console.warn(`Error playing audio: ${e.message}`);
|
||||
// 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