chromium/chrome/services/speech/soda_speech_recognizer_impl.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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() {}

// -------  Methods that trigger Finite State Machine (FSM) events ------------

// NOTE: all the external events and requests should be enqueued (PostTask) in
// order to preserve the relationship of causality between events and avoid
// interleaved event processing due to synchronous callbacks.

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) {}

// ----------- Contract for all the FSM evolution functions below -------------
//  - Are guaranteed to be not reentrant (themselves and each other);
//  - event_args members are guaranteed to be stable during the call;
//  - The class won't be freed in the meanwhile due to callbacks;
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 {}

}  // namespace speech