webos/speech
Provides utility functions and higher-order components for working with webOS speech APIs.
Members
Section titled “Members ”VoiceControlDecorator Higher-Order Component
Section titled “VoiceControlDecorator   Higher-Order Component ”VoiceControlDecorator is a higher-order component that adds a callback for voice event to its wrapped component.
By default, onVoice handler will be added to the node where data-webos-voice-intent attribute is declared.
In addition, if you need to specify a target node, data-webos-voice-event-target attribute can be used.
Usage:
import {Component} from 'react';
import Item from '@enact/moonstone/Item';
import {VoiceControlDecorator} from '@enact/webos/speech';
const VoiceDiv = VoiceControlDecorator('div');
const VoiceItem = VoiceControlDecorator(Item);
class Sample extends Component {
handlePlayListControl = (e) => {
const {intent, control} = e.detail;
// Change the app status refer to the `control` value.
}
handlePlayContent = (e) => {
const {intent, value} = e.detail;
// Play content
}
render () {
return(
<div>
<VoiceDiv
data-webos-voice-intent='PlayListControl'
onVoice={this.handlePlayListControl}
/>
<VoiceItem
data-webos-voice-intent='Select PlayContent'
onVoice={this.handlePlayContent}
>
The Dark Knight
</VoiceItem>
</div>
);
}
}
Properties added to wrapped component
Required Property • onVoice
Section titled “Required Property • onVoice”Callback to be executed when a wrapped element's data-webos-voice-intent is activated.
readAlert Function
Section titled “readAlert   Function ”readAlert( string, clear ) → undefinedRead alert text when accessibility audio guidance is enabled.
2 Params
- string String
String to voice readout
- clear Booleandefault: true
Clear option for TTS. If true, it will cut off previous reading.
Returns
- undefined