react-native - Amazon Lex 无法识别语音
问题描述
我正在使用带有 react-native 的 aws-amplify ( https://aws-amplify.github.io/docs/js/interactions#using-with-react ) 库来开发语音聊天机器人,它在文本聊天中运行良好,但是当我向机器人发送语音输入时它不起作用。每次我收到回复“对着麦克风说话”和错误“5/客户端错误”。
我已经安装了文档中描述的语音交互所需的所有对等依赖项,但我仍然没有得到正确的回复。
Amplify.configure({
Auth: {
identityPoolId: 'us-east-1:e058a291-xxx-xxxx-xxxx-xxxxxxxx',
region: 'us-east-1'
},
Interactions: {
bots: {
"OrderFlowers": {
"name": "OrderFlowers",
"alias": "$LATEST",
"region": "us-east-1",
"userId": "0f1a42ce-xxxx-xxxx-xxxx-xxxxxxxxx",
},
}
}
});
export default class Home extends Component {
state = {
botName: 'OrderFlowers',
welcomeMessage: 'Welcome, what would you like to do today?',
};
constructor(props) {
super(props);
this.handleComplete = this.handleComplete.bind(this);
}
static navigationOptions = ({ navigation }) => ({
header:null
});
handleComplete(err, confirmation) {
if (err) {
Alert.alert('Error', 'Bot conversation failed', [{ text: 'OK' }]);
return;
}
Alert.alert('Done', JSON.stringify(confirmation, null, 2), [{ text: 'OK' }]);
this.setState({
botName: 'OrderFlowers',
});
return 'Flower Ordered Successfully..!! THANK YOU';
}
render() {
const { botName, showChatBot, welcomeMessage } = this.state;
return (
<SafeAreaView style={styles.container}>
<ChatBot
botName={botName}
welcomeMessage={welcomeMessage}
onComplete={this.handleComplete}
clearOnComplete={true}
styles={StyleSheet.create({
itemMe: {
color: 'red'
}
})}
voiceEnabled={true}
voiceLibs={voiceLibs}
conversationModeOn={true}
/>
</SafeAreaView>
);
}
}
解决方案
推荐阅读
- python - 在 python 中为 Hadoop Map Reduce 创建自定义可写键/值类型?
- if-statement - Google Sheet:如果输入的数字低于原始 Cell-B,如何将 Cell-A 替换为 Cell-B 中的数字?
- c++ - 清除或替换控制台输出
- php - php - 字符串连接给出了奇怪的结果
- jekyll - 根据 Jekyll 数组中的第一个参数过滤内容
- c# - 如何将 LinkLabel 插入 DataGridViewCell C#
- python - Django resolve() 无法解析有效路径
- c++ - 在指针场景中使用 std::shared_ptr
- php - 借助 Regex 进行字符串验证 - PHP
- java - Java 更改一个类实例的属性也会更改另一个实例