#include "chrome/services/speech/soda_speech_recognizer_impl.h"
#include <memory>
#include <vector>
#include "base/functional/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "components/speech/audio_buffer.h"
#include "components/speech/endpointer/endpointer.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/mojo/mojom/audio_data.mojom.h"
#include "media/mojo/mojom/audio_logging.mojom.h"
#include "media/mojo/mojom/speech_recognizer.mojom.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace speech {
SodaSpeechRecognizerImpl::SodaSpeechRecognizerImpl(
bool continuous,
int sample_rate,
mojo::PendingRemote<media::mojom::SpeechRecognitionRecognizer>
recognizer_remote,
mojo::PendingReceiver<media::mojom::SpeechRecognitionRecognizerClient>
recognizer_client_receiver,
mojo::PendingRemote<media::mojom::SpeechRecognitionSessionClient>
session_client,
mojo::PendingReceiver<media::mojom::SpeechRecognitionAudioForwarder>
audio_forwarder)
: … { … }
SodaSpeechRecognizerImpl::~SodaSpeechRecognizerImpl() { … }
void SodaSpeechRecognizerImpl::Abort() { … }
void SodaSpeechRecognizerImpl::StopCapture() { … }
void SodaSpeechRecognizerImpl::OnSpeechRecognitionRecognitionEvent(
const media::SpeechRecognitionResult& recognition_result,
OnSpeechRecognitionRecognitionEventCallback reply) { … }
void SodaSpeechRecognizerImpl::OnSpeechRecognitionError() { … }
void SodaSpeechRecognizerImpl::OnLanguageIdentificationEvent(
media::mojom::LanguageIdentificationEventPtr event) { … }
void SodaSpeechRecognizerImpl::OnSpeechRecognitionStopped() { … }
void SodaSpeechRecognizerImpl::AddAudioFromRenderer(
media::mojom::AudioDataS16Ptr buffer) { … }
void SodaSpeechRecognizerImpl::StartRecognition() { … }
void SodaSpeechRecognizerImpl::SendAudioToSpeechRecognitionService(
media::mojom::AudioDataS16Ptr audio_data) { … }
void SodaSpeechRecognizerImpl::DispatchEvent(const FSMEventArgs& event_args) { … }
void SodaSpeechRecognizerImpl::ProcessAudioPipeline(
const FSMEventArgs& event_args) { … }
SodaSpeechRecognizerImpl::FSMState SodaSpeechRecognizerImpl::PrepareRecognition(
const FSMEventArgs&) { … }
SodaSpeechRecognizerImpl::FSMState SodaSpeechRecognizerImpl::StartRecording(
const FSMEventArgs&) { … }
SodaSpeechRecognizerImpl::FSMState
SodaSpeechRecognizerImpl::StartRecognitionEngine(
const FSMEventArgs& event_args) { … }
SodaSpeechRecognizerImpl::FSMState
SodaSpeechRecognizerImpl::WaitEnvironmentEstimationCompletion(
const FSMEventArgs&) { … }
SodaSpeechRecognizerImpl::FSMState
SodaSpeechRecognizerImpl::DetectUserSpeechOrTimeout(const FSMEventArgs&) { … }
SodaSpeechRecognizerImpl::FSMState SodaSpeechRecognizerImpl::DetectEndOfSpeech(
const FSMEventArgs& event_args) { … }
SodaSpeechRecognizerImpl::FSMState
SodaSpeechRecognizerImpl::StopCaptureAndWaitForResult(const FSMEventArgs&) { … }
SodaSpeechRecognizerImpl::FSMState SodaSpeechRecognizerImpl::AbortSilently(
const FSMEventArgs& event_args) { … }
SodaSpeechRecognizerImpl::FSMState SodaSpeechRecognizerImpl::AbortWithError(
const FSMEventArgs& event_args) { … }
SodaSpeechRecognizerImpl::FSMState SodaSpeechRecognizerImpl::Abort(
const media::mojom::SpeechRecognitionError& error) { … }
SodaSpeechRecognizerImpl::FSMState
SodaSpeechRecognizerImpl::ProcessIntermediateResult(
const FSMEventArgs& event_args) { … }
SodaSpeechRecognizerImpl::FSMState SodaSpeechRecognizerImpl::ProcessFinalResult(
const FSMEventArgs& event_args) { … }
SodaSpeechRecognizerImpl::FSMState SodaSpeechRecognizerImpl::DoNothing(
const FSMEventArgs&) const { … }
SodaSpeechRecognizerImpl::FSMState SodaSpeechRecognizerImpl::NotFeasible(
const FSMEventArgs& event_args) { … }
base::TimeDelta SodaSpeechRecognizerImpl::GetElapsedTime() const { … }
}