Skip to content

Commit

Permalink
feat(useSpeechSynthesis): add stop function (#2774)
Browse files Browse the repository at this point in the history
  • Loading branch information
zwkkwz1 committed Feb 17, 2023
1 parent 4e64349 commit 820e28e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/useSpeechSynthesis/demo.vue
Expand Up @@ -39,7 +39,7 @@ const pause = () => {
}
const stop = () => {
window.speechSynthesis.cancel()
speech.stop()
}
</script>

Expand Down
1 change: 1 addition & 0 deletions packages/core/useSpeechSynthesis/index.md
Expand Up @@ -20,6 +20,7 @@ const {
voiceInfo,
utterance,
error,
stop,

toggle,
speak,
Expand Down
6 changes: 6 additions & 0 deletions packages/core/useSpeechSynthesis/index.ts
Expand Up @@ -113,6 +113,11 @@ export function useSpeechSynthesis(text: MaybeComputedRef<string>, options: UseS
utterance && synth!.speak(utterance.value)
}

const stop = () => {
synth!.cancel()
isPlaying.value = false
}

if (isSupported.value) {
bindEventsForUtterance(utterance.value)

Expand Down Expand Up @@ -146,6 +151,7 @@ export function useSpeechSynthesis(text: MaybeComputedRef<string>, options: UseS
utterance,
error,

stop,
toggle,
speak,
}
Expand Down

0 comments on commit 820e28e

Please sign in to comment.