Commit 120bb61b authored by dtseng's avatar dtseng Committed by Commit bot

Improve the speech panel's performance

Currently, ChromeVox sends all queued speech output to the speech panel.

This unfortunately causes performance issues.

For example, in Gmail, if ChromeVox sends ~500 utterances, which can happen if we have a large block of text (since we split on sentences), ChromeVox stops responding to key commands.

ChromeVox should stay responsive in any situation especially if a user taps on the control key repeatedly.

This change makes it so we only show the currently spoken text which gets around the potentially expensive calls to send text to the panel background page (which blocks).

BUG=672955
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2570593002
Cr-Commit-Position: refs/heads/master@{#438083}
parent 350d83a2
......@@ -303,19 +303,6 @@ cvox.TtsBackground.prototype.speakUsingQueue_ = function(utterance, queueMode) {
// Next, add the new utterance to the queue.
this.utteranceQueue_.push(utterance);
// Update the caption panel.
if (utterance.properties &&
utterance.properties['pitch'] &&
utterance.properties['pitch'] < this.ttsProperties['pitch']) {
(new PanelCommand(
PanelCommandType.ADD_ANNOTATION_SPEECH,
utterance.textString)).send();
} else {
(new PanelCommand(
PanelCommandType.ADD_NORMAL_SPEECH,
utterance.textString)).send();
}
// Now start speaking the next item in the queue.
this.startSpeakingNextItemInQueue_();
};
......@@ -342,9 +329,10 @@ cvox.TtsBackground.prototype.startSpeakingNextItemInQueue_ = function() {
}
this.currentUtterance_ = this.utteranceQueue_.shift();
var utteranceId = this.currentUtterance_.id;
var utterance = this.currentUtterance_;
var utteranceId = utterance.id;
this.currentUtterance_.properties['onEvent'] = goog.bind(function(event) {
utterance.properties['onEvent'] = goog.bind(function(event) {
this.onTtsEvent_(event, utteranceId);
},
this);
......@@ -352,13 +340,25 @@ cvox.TtsBackground.prototype.startSpeakingNextItemInQueue_ = function() {
var validatedProperties = {};
for (var i = 0; i < cvox.TtsBackground.ALLOWED_PROPERTIES_.length; i++) {
var p = cvox.TtsBackground.ALLOWED_PROPERTIES_[i];
if (this.currentUtterance_.properties[p]) {
validatedProperties[p] = this.currentUtterance_.properties[p];
if (utterance.properties[p]) {
validatedProperties[p] = utterance.properties[p];
}
}
chrome.tts.speak(this.currentUtterance_.textString,
validatedProperties);
// Update the caption panel.
if (utterance.properties &&
utterance.properties['pitch'] &&
utterance.properties['pitch'] < this.ttsProperties['pitch']) {
(new PanelCommand(
PanelCommandType.ADD_ANNOTATION_SPEECH,
utterance.textString)).send();
} else {
(new PanelCommand(
PanelCommandType.ADD_NORMAL_SPEECH,
utterance.textString)).send();
}
chrome.tts.speak(utterance.textString, validatedProperties);
};
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment