Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: chrome/browser/extensions/api/hotword_private/hotword_private_api.cc

Issue 686333002: Hotword Private API: Adds speech training functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests for Finalize Speaker Model Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/hotword_private/hotword_private_api.cc
diff --git a/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc b/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc
index 0413178365eb4c7812b3fabf6e7cd9b6d53b9c4b..d33f7ef8a418d6b35d993a81fe9faa5711812e09 100644
--- a/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc
+++ b/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc
@@ -64,7 +64,9 @@ const char* HotwordPrivateEventService::service_name() {
void HotwordPrivateEventService::OnEnabledChanged(
const std::string& pref_name) {
DCHECK(pref_name == std::string(prefs::kHotwordSearchEnabled) ||
- pref_name == std::string(prefs::kHotwordAlwaysOnSearchEnabled));
+ pref_name == std::string(prefs::kHotwordAlwaysOnSearchEnabled) ||
+ pref_name == std::string(
rpetterson 2014/10/30 19:48:36 Why is this a part of OnEnabledChanged? I would ex
kcarattini 2014/10/30 23:44:18 Changed the comment in hotword_private.idl, as dis
+ hotword_internal::kHotwordTrainingEnabled));
SignalEvent(OnEnabledChanged::kEventName);
}
@@ -76,6 +78,14 @@ void HotwordPrivateEventService::OnHotwordSessionStopped() {
SignalEvent(api::hotword_private::OnHotwordSessionStopped::kEventName);
}
+void HotwordPrivateEventService::OnFinalizeSpeakerModel() {
+ SignalEvent(api::hotword_private::OnFinalizeSpeakerModel::kEventName);
+}
+
+void HotwordPrivateEventService::OnHotwordTriggered() {
+ SignalEvent(api::hotword_private::OnHotwordTriggered::kEventName);
+}
+
void HotwordPrivateEventService::SignalEvent(const std::string& event_name) {
EventRouter* router = EventRouter::Get(profile_);
if (!router || !router->HasEventListener(event_name))
@@ -137,8 +147,10 @@ bool HotwordPrivateGetStatusFunction::RunSync() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
result.experimental_hotword_enabled = command_line->HasSwitch(
switches::kEnableExperimentalHotwording);
- if (hotword_service)
+ if (hotword_service) {
rpetterson 2014/10/30 19:48:35 Group this if statement with the one above.
kcarattini 2014/10/30 23:44:18 Done.
result.audio_logging_enabled = hotword_service->IsOptedIntoAudioLogging();
+ result.training_enabled = hotword_service->IsTraining();
+ }
SetResult(result.ToValue().release());
return true;
@@ -151,7 +163,9 @@ bool HotwordPrivateSetHotwordSessionStateFunction::RunSync() {
HotwordService* hotword_service =
HotwordServiceFactory::GetForProfile(GetProfile());
- if (hotword_service && hotword_service->client())
+ if (hotword_service &&
+ hotword_service->client() &&
+ !hotword_service->IsTraining())
hotword_service->client()->OnHotwordStateChanged(params->started);
return true;
}
@@ -160,7 +174,9 @@ bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() {
HotwordService* hotword_service =
HotwordServiceFactory::GetForProfile(GetProfile());
if (hotword_service) {
- if (hotword_service->client()) {
+ if (hotword_service->IsTraining()) {
+ hotword_service->NotifyHotwordTriggered();
+ } else if (hotword_service->client()) {
hotword_service->client()->OnHotwordRecognized();
} else if (HotwordService::IsExperimentalHotwordingEnabled() &&
hotword_service->IsAlwaysOnEnabled()) {
@@ -177,19 +193,53 @@ bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() {
}
bool HotwordPrivateGetLaunchStateFunction::RunSync() {
+ HotwordService* hotword_service =
+ HotwordServiceFactory::GetForProfile(GetProfile());
+ if (!hotword_service) {
+ error_ = hotword_private_constants::kHotwordServiceUnavailable;
+ return false;
+ }
+
api::hotword_private::LaunchState result;
+ result.launch_mode =
+ hotword_service->GetHotwordAudioVerificationLaunchMode();
+ SetResult(result.ToValue().release());
+ return true;
+}
+bool HotwordPrivateStartTrainingFunction::RunSync() {
HotwordService* hotword_service =
HotwordServiceFactory::GetForProfile(GetProfile());
if (!hotword_service) {
error_ = hotword_private_constants::kHotwordServiceUnavailable;
return false;
- } else {
- result.launch_mode =
- hotword_service->GetHotwordAudioVerificationLaunchMode();
}
- SetResult(result.ToValue().release());
+ hotword_service->StartTraining();
+ return true;
+}
+
+bool HotwordPrivateFinalizeSpeakerModelFunction::RunSync() {
+ HotwordService* hotword_service =
+ HotwordServiceFactory::GetForProfile(GetProfile());
+ if (!hotword_service) {
+ error_ = hotword_private_constants::kHotwordServiceUnavailable;
+ return false;
+ }
+
+ hotword_service->FinalizeSpeakerModel();
+ return true;
+}
+
+bool HotwordPrivateStopTrainingFunction::RunSync() {
+ HotwordService* hotword_service =
+ HotwordServiceFactory::GetForProfile(GetProfile());
+ if (!hotword_service) {
+ error_ = hotword_private_constants::kHotwordServiceUnavailable;
+ return false;
+ }
+
+ hotword_service->StopTraining();
return true;
}

Powered by Google App Engine
This is Rietveld 408576698