| OLD | NEW |
| 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 Base class for Text-to-Speech engines that actually transform | 6 * @fileoverview Base class for Text-to-Speech engines that actually transform |
| 7 * text to speech. | 7 * text to speech. |
| 8 * | 8 * |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 goog.provide('cvox.AbstractTts'); | 11 goog.provide('cvox.AbstractTts'); |
| 12 | 12 |
| 13 goog.require('Msgs'); |
| 13 goog.require('cvox.TtsInterface'); | 14 goog.require('cvox.TtsInterface'); |
| 14 goog.require('goog.i18n.MessageFormat'); | 15 goog.require('goog.i18n.MessageFormat'); |
| 15 | 16 |
| 16 /** | 17 /** |
| 17 * Creates a new instance. | 18 * Creates a new instance. |
| 18 * @constructor | 19 * @constructor |
| 19 * @implements {cvox.TtsInterface} | 20 * @implements {cvox.TtsInterface} |
| 20 */ | 21 */ |
| 21 cvox.AbstractTts = function() { | 22 cvox.AbstractTts = function() { |
| 22 this.ttsProperties = new Object(); | 23 this.ttsProperties = new Object(); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // simultaneously. | 232 // simultaneously. |
| 232 text = text.replace( | 233 text = text.replace( |
| 233 cvox.AbstractTts.substitutionDictionaryRegexp_, | 234 cvox.AbstractTts.substitutionDictionaryRegexp_, |
| 234 function(symbol) { | 235 function(symbol) { |
| 235 return ' ' + cvox.AbstractTts.SUBSTITUTION_DICTIONARY[symbol] + ' '; | 236 return ' ' + cvox.AbstractTts.SUBSTITUTION_DICTIONARY[symbol] + ' '; |
| 236 }); | 237 }); |
| 237 | 238 |
| 238 // Handle single characters that we want to make sure we pronounce. | 239 // Handle single characters that we want to make sure we pronounce. |
| 239 if (text.length == 1) { | 240 if (text.length == 1) { |
| 240 return cvox.AbstractTts.CHARACTER_DICTIONARY[text] ? | 241 return cvox.AbstractTts.CHARACTER_DICTIONARY[text] ? |
| 241 (new goog.i18n.MessageFormat(cvox.ChromeVox.msgs.getMsg( | 242 (new goog.i18n.MessageFormat(Msgs.getMsg( |
| 242 cvox.AbstractTts.CHARACTER_DICTIONARY[text]))) | 243 cvox.AbstractTts.CHARACTER_DICTIONARY[text]))) |
| 243 .format({'COUNT': 1}) : | 244 .format({'COUNT': 1}) : |
| 244 text.toUpperCase(); | 245 text.toUpperCase(); |
| 245 } | 246 } |
| 246 | 247 |
| 247 // Substitute all words in the pronunciation dictionary. This is pretty | 248 // Substitute all words in the pronunciation dictionary. This is pretty |
| 248 // efficient because we use a single regexp that matches all words | 249 // efficient because we use a single regexp that matches all words |
| 249 // simultaneously, and it calls a function with each match, which we can | 250 // simultaneously, and it calls a function with each match, which we can |
| 250 // use to look up the replacement in our dictionary. | 251 // use to look up the replacement in our dictionary. |
| 251 text = text.replace( | 252 text = text.replace( |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 546 |
| 546 /** | 547 /** |
| 547 * Constructs a description of a repeated character. Use as a param to | 548 * Constructs a description of a repeated character. Use as a param to |
| 548 * string.replace. | 549 * string.replace. |
| 549 * @param {string} match The matching string. | 550 * @param {string} match The matching string. |
| 550 * @return {string} The description. | 551 * @return {string} The description. |
| 551 * @private | 552 * @private |
| 552 */ | 553 */ |
| 553 cvox.AbstractTts.repetitionReplace_ = function(match) { | 554 cvox.AbstractTts.repetitionReplace_ = function(match) { |
| 554 var count = match.length; | 555 var count = match.length; |
| 555 return ' ' + (new goog.i18n.MessageFormat(cvox.ChromeVox.msgs.getMsg( | 556 return ' ' + (new goog.i18n.MessageFormat(Msgs.getMsg( |
| 556 cvox.AbstractTts.CHARACTER_DICTIONARY[match[0]]))) | 557 cvox.AbstractTts.CHARACTER_DICTIONARY[match[0]]))) |
| 557 .format({'COUNT': count}) + ' '; | 558 .format({'COUNT': count}) + ' '; |
| 558 }; | 559 }; |
| 559 | 560 |
| 560 | 561 |
| 561 /** | 562 /** |
| 562 * @override | 563 * @override |
| 563 */ | 564 */ |
| 564 cvox.AbstractTts.prototype.getDefaultProperty = function(property) { | 565 cvox.AbstractTts.prototype.getDefaultProperty = function(property) { |
| 565 return this.propertyDefault[property]; | 566 return this.propertyDefault[property]; |
| 566 }; | 567 }; |
| OLD | NEW |