#include "chrome/services/speech/speech_recognition_service_impl.h"
#include <string>
#include "base/containers/flat_map.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/weak_ptr.h"
#include "chrome/services/speech/audio_source_fetcher_impl.h"
#include "chrome/services/speech/soda_speech_recognizer_impl.h"
#include "chrome/services/speech/speech_recognition_recognizer_impl.h"
#include "media/mojo/mojom/speech_recognition.mojom.h"
#include "media/mojo/mojom/speech_recognition_service.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace speech {
namespace {
constexpr char kInvalidSpeechRecogntionOptions[] = …;
}
SpeechRecognitionServiceImpl::SpeechRecognitionServiceImpl(
mojo::PendingReceiver<media::mojom::SpeechRecognitionService> receiver)
: … { … }
SpeechRecognitionServiceImpl::~SpeechRecognitionServiceImpl() = default;
void SpeechRecognitionServiceImpl::BindAudioSourceSpeechRecognitionContext(
mojo::PendingReceiver<media::mojom::AudioSourceSpeechRecognitionContext>
context) { … }
void SpeechRecognitionServiceImpl::BindSpeechRecognitionContext(
mojo::PendingReceiver<media::mojom::SpeechRecognitionContext> context) { … }
void SpeechRecognitionServiceImpl::SetSodaPaths(
const base::FilePath& binary_path,
const base::flat_map<std::string, base::FilePath>& config_paths,
const std::string& primary_language_name) { … }
void SpeechRecognitionServiceImpl::SetSodaParams(
const bool mask_offensive_words) { … }
void SpeechRecognitionServiceImpl::SetSodaConfigPaths(
const base::flat_map<std::string, base::FilePath>& config_paths) { … }
void SpeechRecognitionServiceImpl::BindRecognizer(
mojo::PendingReceiver<media::mojom::SpeechRecognitionRecognizer> receiver,
mojo::PendingRemote<media::mojom::SpeechRecognitionRecognizerClient> client,
media::mojom::SpeechRecognitionOptionsPtr options,
BindRecognizerCallback callback) { … }
void SpeechRecognitionServiceImpl::BindWebSpeechRecognizer(
mojo::PendingReceiver<media::mojom::SpeechRecognitionSession>
session_receiver,
mojo::PendingRemote<media::mojom::SpeechRecognitionSessionClient>
session_client,
mojo::PendingReceiver<media::mojom::SpeechRecognitionAudioForwarder>
audio_forwarder,
int channel_count,
int sample_rate,
media::mojom::SpeechRecognitionOptionsPtr options,
bool continuous) { … }
void SpeechRecognitionServiceImpl::BindAudioSourceFetcher(
mojo::PendingReceiver<media::mojom::AudioSourceFetcher> fetcher_receiver,
mojo::PendingRemote<media::mojom::SpeechRecognitionRecognizerClient> client,
media::mojom::SpeechRecognitionOptionsPtr options,
BindRecognizerCallback callback) { … }
void SpeechRecognitionServiceImpl::AddObserver(Observer* observer) { … }
void SpeechRecognitionServiceImpl::RemoveObserver(Observer* observer) { … }
bool SpeechRecognitionServiceImpl::FilePathsExist() { … }
bool SpeechRecognitionServiceImpl::CreateRecognizer(
mojo::PendingReceiver<media::mojom::SpeechRecognitionRecognizer> receiver,
mojo::PendingRemote<media::mojom::SpeechRecognitionRecognizerClient> client,
media::mojom::SpeechRecognitionOptionsPtr options) { … }
}