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

Unified Diff: chrome/browser/resources/app_list/speech_manager.js

Issue 229323003: Modifies handling of hotword NaCl module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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/resources/app_list/speech_manager.js
diff --git a/chrome/browser/resources/app_list/speech_manager.js b/chrome/browser/resources/app_list/speech_manager.js
index 450fbba3e6c5e99a05ddfb8a56a32efa68930a3e..1579efaa7f0d64c06be0509eafec0ac6bc21213d 100644
--- a/chrome/browser/resources/app_list/speech_manager.js
+++ b/chrome/browser/resources/app_list/speech_manager.js
@@ -27,6 +27,22 @@ cr.define('speech', function() {
};
/**
+ * Checks the prefix for the hotword module based on the language. This is
+ * fragile if the file structure has changed.
+ */
+ function getHotwordPrefix() {
+ var prefix = navigator.language.toLowerCase();
+ if (prefix == 'en-gb')
+ return prefix;
+ var hyphen = prefix.indexOf('-');
+ if (hyphen >= 0)
+ prefix = prefix.substr(0, hyphen);
+ if (prefix == 'en')
+ prefix = '';
+ return prefix;
+ }
+
+ /**
* @constructor
*/
function SpeechManager() {
@@ -78,7 +94,6 @@ cr.define('speech', function() {
this.pluginManager_.startRecognizer();
this.audioManager_.start();
this.setState_(SpeechState.HOTWORD_RECOGNIZING);
- chrome.send('setHotwordRecognizerState', [true]);
};
/**
@@ -163,11 +178,17 @@ cr.define('speech', function() {
if (enabled) {
if (recognizer)
return;
+ if (!this.naclArch)
+ return;
+
+ var prefix = getHotwordPrefix();
var pluginManager = new speech.PluginManager(
+ prefix,
this.onHotwordRecognizerReady_.bind(this),
this.onHotwordRecognized_.bind(this));
- pluginManager.scheduleInitialize(
- this.audioManager_.sampleRate, 'chrome://app-list/hotword.data');
+ var modelUrl = 'chrome://app-list/_platform_specific/' + this.naclArch +
+ '_' + prefix + '/hotword.data';
+ pluginManager.scheduleInitialize(this.audioManager_.sampleRate, modelUrl);
} else {
if (!recognizer)
return;
@@ -181,6 +202,15 @@ cr.define('speech', function() {
};
/**
+ * Sets the NaCl architecture for the hotword module.
+ *
+ * @param {string} arch The architecture.
+ */
+ SpeechManager.prototype.setNaclArch = function(arch) {
+ this.naclArch = arch;
+ };
+
+ /**
* Called when the app-list bubble is shown.
*
* @param {boolean} hotwordEnabled Whether the hotword is enabled or not.
« no previous file with comments | « chrome/browser/resources/app_list/plugin_manager.js ('k') | chrome/browser/resources/app_list/start_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698