
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
安装、链接后还须进行下面两步(以 Example 工程为例):
语音听写与在线语音合成),分别下载 Android 与 iOS 平台 SDK。Android_voice_xxxx_xxxxxxxx/libs 文件夹替换 Example/node_modules/react-native-speech-iflytek/android/libs 文件夹;iOS_voice_xxxx_xxxxxxxx/libs 文件夹替换 Example/node_modules/react-native-speech-iflytek/ios/libs 文件夹。Example/ios/YourProject.xcodeproj;Example/node_modules/react-native-speech-iflytek/ios/libs/iflyMSC.framework 拖入 Project navigator 的 Frameworks 下,注意选择 Copy items if needed;(详见 Example)引入包:
import { Recognizer, Synthesizer, SpeechConstant } from "react-native-speech-iflytek";
语音识别:
Recognizer.init("57c7c5b0");
this.recognizerEventEmitter = new NativeEventEmitter(Recognizer);
this.recognizerEventEmitter.addListener('onRecognizerResult', this.onRecognizerResult);
Recognizer.start();
处理识别结果:
onRecognizerResult(e) {
if (!e.isLast) {
return;
}
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: 获取错误码,关于错误码请见官方文档 MSC错误码 :errorType: (仅 iOS)获取错误码类型errorDesc: (仅 iOS)获取错误描述errorDescription: (仅 Android)获取错误描述,不包含错误码的描述信息plainDescription: (仅 Android)获取错误描述,包含错误码的描述信息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");
iflytek.framework not found ? (见 issue 15)iflytek.framework 拖入时注意选择 Copy items if needed。如忘记选择,最好的方式是在工程中删除讯飞框架,将讯飞框架移至其他文件夹,并重新拖入工程,选择 Copy items if needed。(Xcode 的缓存会记住上次选择,若第一次没有Copy items if needed,在同一位置下重新拖入不会再次出现选择框。)react-native [command] 命令失效?yarn 命令解决依赖。期待提出有关建议,欢迎做出贡献,感谢 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 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.