我正在使用带有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>
);
}
}