Commit 40005a60 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Re-introduce workaround for strings that do not produce callbacks

Bug: 859052
Change-Id: Ic1113d8e4200f46bb3f49e1a2c72cbedaba1eef5
Reviewed-on: https://chromium-review.googlesource.com/1178890
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583879}
parent dccf844a
......@@ -267,6 +267,29 @@ cvox.TtsBackground.prototype.speak = function(
// pattern causes ChromeVox to read numbers as digits rather than words.
textString = this.getNumberAsDigits_(textString);
// TODO(dtseng): some TTS engines don't handle strings that don't produce any
// speech very well. Handle empty and whitespace only strings (including
// non-breaking space) here to mitigate the issue somewhat.
if (cvox.TtsBackground.SKIP_WHITESPACE_.test(textString)) {
// Explicitly call start and end callbacks before skipping this text.
if (properties['startCallback']) {
try {
properties['startCallback']();
} catch (e) {
}
}
if (properties['endCallback']) {
try {
properties['endCallback']();
} catch (e) {
}
}
if (queueMode === cvox.QueueMode.FLUSH) {
this.stop();
}
return this;
}
var mergedProperties = this.mergeProperties(properties);
if (this.currentVoice && this.currentVoice !== constants.SYSTEM_VOICE) {
......@@ -759,3 +782,6 @@ cvox.TtsBackground.prototype.updateFromPrefs_ = function(announce, prefs) {
cvox.AbstractTts.PERSONALITY_ANNOTATION);
});
};
/** @private {RegExp} */
cvox.TtsBackground.SKIP_WHITESPACE_ = /^[\s\u00a0]*$/;
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