在android中使用expo-speech无法正常工作并抛出异常

问题描述 投票:0回答:1

我正在尝试在我的react-native应用程序中使用expo-speech,并且在Android上收到以下错误:

[Unhandled promise rejection: Error: Encountered an exception while calling native method: Exception occurred while executing exported method speak on module ExponentSpeech: null]
- node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:155:41 in createErrorFromErrorData
- node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:104:55 in <unknown>
- ... 5 more stack frames from framework internals

代码如下:

speak = async text => {
  Speech.speak(convertHTMLstring(text), {
    language: 'he',
    pitch: '1',
    rate: '0.9',
  })
}

本机:0.59.8

依赖关系如下:

"expo": "^35.0.0",
"expo-speech": "~7.0.0",
"react": "16.8.3",
...

相同的代码在ios中有效。

我试图寻找答案,但找不到任何东西,根据expo docs,它应该支持Android:https://docs.expo.io/versions/latest/sdk/speech/

请帮助。谢谢。

android react-native expo text-to-speech
1个回答
0
投票
听起来这是一个纯粹的原生项目,而不是托管博览会项目,对吗?如果是这样,请确保首先在您的项目中设置react-native-unimodules:https://github.com/unimodules/react-native-unimodules
© www.soinside.com 2019 - 2024. All rights reserved.