-
Notifications
You must be signed in to change notification settings - Fork 4
🚸 Pause TTS on 3 errors #657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -61,6 +61,8 @@ export function useTextToSpeech(options: TTSOptions = {}) { | |||||||
| const shouldResumeWhenOnline = ref(false) | ||||||||
| const currentBufferIndex = ref<0 | 1>(0) | ||||||||
| const idleBufferIndex = computed<0 | 1>(() => (currentBufferIndex.value === 0 ? 1 : 0)) | ||||||||
| const consecutiveAudioErrors = ref(0) | ||||||||
| const MAX_CONSECUTIVE_ERRORS = 3 | ||||||||
| const currentTTSSegmentIndex = ref(0) | ||||||||
| const ttsSegments = ref<TTSSegment[]>([]) | ||||||||
| const currentTTSSegment = computed(() => { | ||||||||
|
|
@@ -210,6 +212,7 @@ export function useTextToSpeech(options: TTSOptions = {}) { | |||||||
|
|
||||||||
| audio.onended = () => { | ||||||||
| isTextToSpeechPlaying.value = false | ||||||||
| consecutiveAudioErrors.value = 0 | ||||||||
| playNextElement() | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -243,6 +246,12 @@ export function useTextToSpeech(options: TTSOptions = {}) { | |||||||
| } | ||||||||
|
|
||||||||
| options.onError?.(error) | ||||||||
| consecutiveAudioErrors.value += 1 | ||||||||
|
||||||||
| consecutiveAudioErrors.value += 1 | |
| consecutiveAudioErrors.value += 1 | |
| console.warn(`Audio error (${consecutiveAudioErrors.value}/${MAX_CONSECUTIVE_ERRORS})`) |
Copilot
AI
Feb 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consecutive error counter should also be reset when the user manually intervenes (e.g., when calling startTextToSpeech with an index, skipForward, skipBackward, or stopTextToSpeech). Currently, if a user experiences 2 errors, then manually skips to the next segment, they would only need 1 more error before TTS pauses, even though their manual action suggests they want to continue playing. Consider resetting the counter in user-initiated actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consecutive error counter should be reset when users manually skip to a different segment (via skipForward, skipBackward, or skipToIndex). Currently, if there are 2 consecutive errors and the user skips forward, the next error would immediately pause playback, even though the user is trying a different segment. Consider resetting the counter when playCurrentElement() is called from user actions, or add a reset in the skip functions themselves.