Pulled ALL skills from 15 source repositories: - anthropics/skills: 16 (docs, design, MCP, testing) - obra/superpowers: 14 (TDD, debugging, agents, planning) - coreyhaines31/marketingskills: 25 (marketing, CRO, SEO, growth) - better-auth/skills: 5 (auth patterns) - vercel-labs/agent-skills: 5 (React, design, Vercel) - antfu/skills: 16 (Vue, Vite, Vitest, pnpm, Turborepo) - Plus 13 individual skills from various repos Mosaic Stack is not limited to coding — the Orchestrator and subagents serve coding, business, design, marketing, writing, logistics, analysis, and more. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
106 lines
2.5 KiB
Markdown
106 lines
2.5 KiB
Markdown
---
|
|
category: Sensors
|
|
---
|
|
|
|
# useSpeechSynthesis
|
|
|
|
Reactive [SpeechSynthesis](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis).
|
|
|
|
> [Can I use?](https://caniuse.com/mdn-api_speechsynthesis)
|
|
|
|
## Usage
|
|
|
|
```ts
|
|
import { useSpeechSynthesis } from '@vueuse/core'
|
|
|
|
const {
|
|
isSupported,
|
|
isPlaying,
|
|
status,
|
|
voiceInfo,
|
|
utterance,
|
|
error,
|
|
stop,
|
|
toggle,
|
|
speak,
|
|
} = useSpeechSynthesis()
|
|
```
|
|
|
|
### Options
|
|
|
|
The following shows the default values of the options, they will be directly passed to [SpeechSynthesis API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis).
|
|
|
|
```ts
|
|
import { useSpeechSynthesis } from '@vueuse/core'
|
|
// ---cut---
|
|
useSpeechSynthesis({
|
|
lang: 'en-US',
|
|
pitch: 1,
|
|
rate: 1,
|
|
volume: 1,
|
|
})
|
|
```
|
|
|
|
## Type Declarations
|
|
|
|
```ts
|
|
export type UseSpeechSynthesisStatus = "init" | "play" | "pause" | "end"
|
|
export interface UseSpeechSynthesisOptions extends ConfigurableWindow {
|
|
/**
|
|
* Language for SpeechSynthesis
|
|
*
|
|
* @default 'en-US'
|
|
*/
|
|
lang?: MaybeRefOrGetter<string>
|
|
/**
|
|
* Gets and sets the pitch at which the utterance will be spoken at.
|
|
*
|
|
* @default 1
|
|
*/
|
|
pitch?: MaybeRefOrGetter<SpeechSynthesisUtterance["pitch"]>
|
|
/**
|
|
* Gets and sets the speed at which the utterance will be spoken at.
|
|
*
|
|
* @default 1
|
|
*/
|
|
rate?: MaybeRefOrGetter<SpeechSynthesisUtterance["rate"]>
|
|
/**
|
|
* Gets and sets the voice that will be used to speak the utterance.
|
|
*/
|
|
voice?: MaybeRef<SpeechSynthesisVoice>
|
|
/**
|
|
* Gets and sets the volume that the utterance will be spoken at.
|
|
*
|
|
* @default 1
|
|
*/
|
|
volume?: MaybeRefOrGetter<SpeechSynthesisUtterance["volume"]>
|
|
/**
|
|
* Callback function that is called when the boundary event is triggered.
|
|
*/
|
|
onBoundary?: (event: SpeechSynthesisEvent) => void
|
|
}
|
|
/**
|
|
* Reactive SpeechSynthesis.
|
|
*
|
|
* @see https://vueuse.org/useSpeechSynthesis
|
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis SpeechSynthesis
|
|
*/
|
|
export declare function useSpeechSynthesis(
|
|
text: MaybeRefOrGetter<string>,
|
|
options?: UseSpeechSynthesisOptions,
|
|
): {
|
|
isSupported: ComputedRef<boolean>
|
|
isPlaying: ShallowRef<boolean, boolean>
|
|
status: ShallowRef<UseSpeechSynthesisStatus, UseSpeechSynthesisStatus>
|
|
utterance: ComputedRef<SpeechSynthesisUtterance>
|
|
error: ShallowRef<
|
|
SpeechSynthesisErrorEvent | undefined,
|
|
SpeechSynthesisErrorEvent | undefined
|
|
>
|
|
stop: () => void
|
|
toggle: (value?: boolean) => void
|
|
speak: () => void
|
|
}
|
|
export type UseSpeechSynthesisReturn = ReturnType<typeof useSpeechSynthesis>
|
|
```
|