如何将语音转文本添加到在React Native上编写的聊天应用程序中

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

我和我的朋友们正在一个聊天应用程序项目中,它将实现Google的语音转文本,文本转语音和翻译API。聊天应用程序上的资优聊天和Firebase。聊天应用程序在Firebase上运行良好。我们在上面添加了TTS,并且效果也不错,但是我们无法添加STT。我们的目标是用户可以使用麦克风,并且该应用可以将语音转换为文本。该文本将自动出现在用户的文本框中。我们认为必须将STT手动添加到“资优聊天”模块中,但是我们不知道该怎么做。互联网上也没有关于此的消息来源。如果有人可以帮助我们,我们将非常高兴。谢谢!

javascript react-native speech-to-text google-speech-api react-native-gifted-chat
1个回答
0
投票

您可以使用react-native-voice

这是示例用法:

import Voice from '@react-native-community/voice';
import React, {Component} from 'react';

class VoiceTest extends Component {
  constructor(props) {
    Voice.onSpeechStart = this.onSpeechStartHandler.bind(this);
    Voice.onSpeechEnd = this.onSpeechEndHandler.bind(this);
    Voice.onSpeechResults = this.onSpeechResultsHandler.bind(this);
  }
  onStartButtonPress(e){
    Voice.start('en-US');
  }
  ...
}
© www.soinside.com 2019 - 2024. All rights reserved.