React-native 世博会 SpeechOptions
React-native Expo SpeechOptions
我想使用这些 expo react 本机事件(onPause、onResume、onDone 等),这些事件可以在这里找到:https://docs.expo.dev/versions/v44.0.0/sdk/speech/#speecheventcallback 但我找不到任何正确的使用方法。任何人都可以帮我语法吗?我根本没有找到任何例子。
谢谢
一月
const [Playing,setPlaying] = useState(false);
const Text = 'Mom I missed you';
const play = () => {
Speech.speak(Text,{
rate:1,
onStart:() => setPlaying(true),
onPause:() => setPlaying(false),
onResume:() => setPlaying(true)
})
}
return (
<Button title = 'play' onPress = {play}/>
)
基本上在每个事件(开始、恢复、暂停)上都会调用相应的回调函数..
不知道 onBoundary 和 onMark。
基本上 SpeechSysthesisUtterance 有一个 boundary 事件(一个 api 用于网络浏览器的文本到语音)也许 onBoundary 与此有关。
//This is only for Web-Apps
let utt = new SpeechSynthesisUtterance('Hello everyone');
utt.addEventListener('boundary' ,(e) => {
console.log(e.charIndex)
});
speechSynthesis.speak(utt);
e.charIndex 是文本的索引。
https://www.youtube.com/watch?v=nx_k1XCaWWs
检查 13:30 分钟
我想使用这些 expo react 本机事件(onPause、onResume、onDone 等),这些事件可以在这里找到:https://docs.expo.dev/versions/v44.0.0/sdk/speech/#speecheventcallback 但我找不到任何正确的使用方法。任何人都可以帮我语法吗?我根本没有找到任何例子。 谢谢 一月
const [Playing,setPlaying] = useState(false);
const Text = 'Mom I missed you';
const play = () => {
Speech.speak(Text,{
rate:1,
onStart:() => setPlaying(true),
onPause:() => setPlaying(false),
onResume:() => setPlaying(true)
})
}
return (
<Button title = 'play' onPress = {play}/>
)
基本上在每个事件(开始、恢复、暂停)上都会调用相应的回调函数.. 不知道 onBoundary 和 onMark。 基本上 SpeechSysthesisUtterance 有一个 boundary 事件(一个 api 用于网络浏览器的文本到语音)也许 onBoundary 与此有关。
//This is only for Web-Apps
let utt = new SpeechSynthesisUtterance('Hello everyone');
utt.addEventListener('boundary' ,(e) => {
console.log(e.charIndex)
});
speechSynthesis.speak(utt);
e.charIndex 是文本的索引。 https://www.youtube.com/watch?v=nx_k1XCaWWs 检查 13:30 分钟