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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js

Issue 1762843002: Fix logic handling empty strings in tts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Sends Text-To-Speech commands to Chrome's native TTS 6 * @fileoverview Sends Text-To-Speech commands to Chrome's native TTS
7 * extension API. 7 * extension API.
8 * 8 *
9 */ 9 */
10 10
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 textString = this.preprocess(textString, properties); 250 textString = this.preprocess(textString, properties);
251 251
252 // TODO(dtseng): Google TTS has bad performance when speaking numbers. This 252 // TODO(dtseng): Google TTS has bad performance when speaking numbers. This
253 // pattern causes ChromeVox to read numbers as digits rather than words. 253 // pattern causes ChromeVox to read numbers as digits rather than words.
254 textString = this.getNumberAsDigits_(textString); 254 textString = this.getNumberAsDigits_(textString);
255 255
256 // TODO(plundblad): Google TTS doesn't handle strings that don't produce 256 // TODO(plundblad): Google TTS doesn't handle strings that don't produce
257 // any speech very well. Handle empty and whitespace only strings (including 257 // any speech very well. Handle empty and whitespace only strings (including
258 // non-breaking space) here to mitigate the issue somewhat. 258 // non-breaking space) here to mitigate the issue somewhat.
259 if (/^[\s\u00a0]*$/.test(textString)) { 259 if (/^[\s\u00a0]*$/.test(textString)) {
260 queueMode = cvox.QueueMode.FLUSH;
261
260 // We still want to callback for listeners in our content script. 262 // We still want to callback for listeners in our content script.
261 if (properties['startCallback']) { 263 if (properties['startCallback']) {
262 try { 264 try {
263 properties['startCallback'](); 265 properties['startCallback']();
264 } catch (e) { 266 } catch (e) {
265 } 267 }
266 } 268 }
267 if (properties['endCallback']) { 269 if (properties['endCallback']) {
268 try { 270 try {
269 properties['endCallback'](); 271 properties['endCallback']();
270 } catch (e) { 272 } catch (e) {
271 } 273 }
272 } 274 }
273 if (queueMode === cvox.QueueMode.FLUSH) {
274 this.stop();
275 }
276 return this; 275 return this;
277 } 276 }
278 277
279 var mergedProperties = this.mergeProperties(properties); 278 var mergedProperties = this.mergeProperties(properties);
280 279
281 if (this.currentVoice) { 280 if (this.currentVoice) {
282 mergedProperties['voiceName'] = this.currentVoice; 281 mergedProperties['voiceName'] = this.currentVoice;
283 } 282 }
284 283
285 if (queueMode == cvox.QueueMode.CATEGORY_FLUSH && 284 if (queueMode == cvox.QueueMode.CATEGORY_FLUSH &&
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 voices.find(function(v) { return v.lang === currentLocale; }) || 716 voices.find(function(v) { return v.lang === currentLocale; }) ||
718 voices.find(function(v) { return currentLocale.startsWith(v.lang); }) || 717 voices.find(function(v) { return currentLocale.startsWith(v.lang); }) ||
719 voices[0]; 718 voices[0];
720 719
721 if (newVoice) { 720 if (newVoice) {
722 this.currentVoice = newVoice.voiceName; 721 this.currentVoice = newVoice.voiceName;
723 this.startSpeakingNextItemInQueue_(); 722 this.startSpeakingNextItemInQueue_();
724 } 723 }
725 }, this)); 724 }, this));
726 }; 725 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698