
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
react-native-speech-iflytek
Advanced tools
react-native-speech-iflytek 是一个 React Native 下的科大讯飞语音库,可以进行语音识别与语音合成。
npm i react-native-speech-iflytek --save
react-native link
安装后使用 Android Studio 重新构建。还须进行下面两步:
语音识别与在线语音合成)Android_voice_xxxx_xxxxxxxx/libs 文件夹替换 YourProject/node_modules/react-native-speech-iflytek/android/libs 文件夹,这是因为讯飞语音的原生库与注册应用进行了绑定。(详见 Example)引入包:
import { Recognizer, Synthesizer } from "react-native-speech-iflytek";
语音识别:
Recognizer.init("57c7c5b0");
DeviceEventEmitter.addListener("onRecognizerResult", this.onRecognizerResult);
Recognizer.start();
处理识别结果:
onRecognizerResult(e) {
if (!e.isLast) {
return;
}
ToastAndroid.show(e.result, ToastAndroid.SHORT);
this.setState({ text: e.result });
}
Recognizer.init(String AppId)Recognizer.start()Recognizer.cancel()Recognizer.isListening()Promise,结果为 bool 类型,表示当前是否正在语音识别Recognizer.stop()Recognizer.setParameter(String parameter, String value)Recognizer.getParameter(String param)Promise,结果为 String 类型,表示语音识别设置值onRecognizerResult(JSON result)
语音识别结果,在语音识别时会不断触发该事件,result 为 JSON 类型,其值:
text:当次识别结果result:当前识别结果,最常使用isLast:是否是最后一次识别,调用 Recognizer.stop() 后,isLast 值为 true,否则一直为 falseduration:当前识别时间长度onRecognizerVolumeChanged(Int volume)
语音识别的音量大小,当识别的语音改变音量是会触发该事件
Synthesizer.init(String AppId)Synthesizer.start(String content)Synthesizer.stop()Synthesizer.isSpeaking()Promise,结果为 bool 类型,表示当前是否正在语音合成Synthesizer.pause()Synthesizer.setParameter(String parameter, String value)Synthesizer.getParameter(String param)Promise,结果为 String 类型,表示语音合成设置值onSynthesizerBufferCompletedEvent()onSynthesizerSpeakCompletedEvent()
语音合成播放完成时触发该事件FAQs
Speech module based on iflytekSpeech for react native
The npm package react-native-speech-iflytek receives a total of 17 weekly downloads. As such, react-native-speech-iflytek popularity was classified as not popular.
We found that react-native-speech-iflytek demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.