
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_voice_xxxx_xxxxxxxx/libs 文件夹替换 YourProject/node_modules/react-native-speech-iflytek/android/libs 文件夹,这是因为讯飞语音的原生库与注册应用进行了绑定。(详见 Example)引入包:
import { Recognizer, Synthesizer, SpeechConstant } 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)
语音识别的音量大小,当识别的语音改变音量时会触发该事件
onRecognizerError(JSON error)
语音识别出现错误,错误信息与讯飞文档保持一致,其值:
errorCode: 获取错误码errorDescription: 获取错误描述,不包含错误码的描述信息plainDescription: 获取错误描述,包含错误码的描述信息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()
语音合成播放完成时触发该事件本模块包含讯飞接口的所有常量,如设置发言人、发言速度等,详见讯飞文档,使用示例:
Synthesizer.setParameter(SpeechConstant.VOICE_NAME, "xiaoyu");
期待提出有关建议,欢迎做出贡献,感谢 star。
Github: https://github.com/zphhhhh/react-native-speech-iflytek
FAQs
Speech module based on iflytekSpeech for react native
The npm package react-native-speech-iflytek receives a total of 42 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.