#include "content/browser/speech/soda_speech_recognition_engine_impl.h"
#include <string.h>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "content/browser/speech/speech_recognition_engine.h"
#include "content/browser/speech/speech_recognition_manager_impl.h"
#include "content/public/browser/speech_recognition_manager_delegate.h"
#include "content/public/browser/speech_recognition_session_config.h"
#include "media/mojo/mojom/audio_data.mojom.h"
#include "media/mojo/mojom/media_types.mojom.h"
#include "media/mojo/mojom/speech_recognition.mojom.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace content {
namespace {
constexpr int kAudioPacketIntervalMs = …;
constexpr float kSpeechRecognitionConfidence = …;
SpeechRecognitionManagerDelegate* speech_recognition_mgr_delegate_for_tests = …;
}
SodaSpeechRecognitionEngineImpl::SodaSpeechRecognitionEngineImpl(
const SpeechRecognitionSessionConfig& config)
: … { … }
SodaSpeechRecognitionEngineImpl::~SodaSpeechRecognitionEngineImpl() = default;
bool SodaSpeechRecognitionEngineImpl::Initialize() { … }
void SodaSpeechRecognitionEngineImpl::StartRecognition() { … }
void SodaSpeechRecognitionEngineImpl::EndRecognition() { … }
void SodaSpeechRecognitionEngineImpl::TakeAudioChunk(const AudioChunk& data) { … }
void SodaSpeechRecognitionEngineImpl::AudioChunksEnded() { … }
int SodaSpeechRecognitionEngineImpl::GetDesiredAudioChunkDurationMs() const { … }
void SodaSpeechRecognitionEngineImpl::OnSpeechRecognitionRecognitionEvent(
const media::SpeechRecognitionResult& recognition_result,
OnSpeechRecognitionRecognitionEventCallback reply) { … }
void SodaSpeechRecognitionEngineImpl::OnSpeechRecognitionError() { … }
void SodaSpeechRecognitionEngineImpl::OnLanguageIdentificationEvent(
media::mojom::LanguageIdentificationEventPtr event) { … }
void SodaSpeechRecognitionEngineImpl::OnSpeechRecognitionStopped() { … }
void SodaSpeechRecognitionEngineImpl::
SetSpeechRecognitionManagerDelegateForTesting(
SpeechRecognitionManagerDelegate* delegate) { … }
void SodaSpeechRecognitionEngineImpl::SetOnReadyCallback(
base::OnceCallback<void()> callback) { … }
void SodaSpeechRecognitionEngineImpl::OnRecognizerBound(
bool is_multichannel_supported) { … }
void SodaSpeechRecognitionEngineImpl::OnRecognizerDisconnected() { … }
void SodaSpeechRecognitionEngineImpl::SendAudioToSpeechRecognitionService(
media::mojom::AudioDataS16Ptr audio_data) { … }
void SodaSpeechRecognitionEngineImpl::MarkDone() { … }
void SodaSpeechRecognitionEngineImpl::Abort(
media::mojom::SpeechRecognitionErrorCode error_code) { … }
media::mojom::AudioDataS16Ptr
SodaSpeechRecognitionEngineImpl::ConvertToAudioDataS16(
const AudioChunk& audio_data) { … }
}