SpeechSynthesis
This service is rc and may change in the future.
A speech synthesizer
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
Commands
speak
Adds an utterance to the utterance queue; it will be spoken when any other utterances queued before it have been spoken.
speechSynthesis.speak(text: string): Promise<void>
cancel
Cancels current utterance and all utterances from the utterance queue.
speechSynthesis.cancel(): Promise<void>
Registers
enabled
Determines if the speech engine is in a non-paused state.
type:
Register<boolean>
(packing formatu8
)read and write
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
const value = await speechSynthesis.enabled.read()
await speechSynthesis.enabled.write(value)
- track incoming values
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
speechSynthesis.enabled.subscribe(async (value) => {
...
})
write
and read
will block until a server is bound to the client.
lang
Language used for utterances as defined in https://www.ietf.org/rfc/bcp/bcp47.txt.
type:
Register<string>
(packing formats
)optional: this register may not be implemented
read and write
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
const value = await speechSynthesis.lang.read()
await speechSynthesis.lang.write(value)
- track incoming values
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
speechSynthesis.lang.subscribe(async (value) => {
...
})
write
and read
will block until a server is bound to the client.
volume
Volume for utterances.
type:
Register<number>
(packing formatu0.8
)optional: this register may not be implemented
read and write
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
const value = await speechSynthesis.volume.read()
await speechSynthesis.volume.write(value)
- track incoming values
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
speechSynthesis.volume.subscribe(async (value) => {
...
})
write
and read
will block until a server is bound to the client.
pitch
Pitch for utterances
type:
Register<number>
(packing formatu16.16
)optional: this register may not be implemented
read and write
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
const value = await speechSynthesis.pitch.read()
await speechSynthesis.pitch.write(value)
- track incoming values
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
speechSynthesis.pitch.subscribe(async (value) => {
...
})
write
and read
will block until a server is bound to the client.
rate
Rate for utterances
type:
Register<number>
(packing formatu16.16
)optional: this register may not be implemented
read and write
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
const value = await speechSynthesis.rate.read()
await speechSynthesis.rate.write(value)
- track incoming values
import { SpeechSynthesis } from "@devicescript/core"
const speechSynthesis = new SpeechSynthesis()
// ...
speechSynthesis.rate.subscribe(async (value) => {
...
})
write
and read
will block until a server is bound to the client.