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 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 cvox.AbstractTts.prototype.increaseOrDecreaseProperty = | 136 cvox.AbstractTts.prototype.increaseOrDecreaseProperty = |
137 function(propertyName, increase) { | 137 function(propertyName, increase) { |
138 var min = this.propertyMin[propertyName]; | 138 var min = this.propertyMin[propertyName]; |
139 var max = this.propertyMax[propertyName]; | 139 var max = this.propertyMax[propertyName]; |
140 var step = this.propertyStep[propertyName]; | 140 var step = this.propertyStep[propertyName]; |
141 var current = this.ttsProperties[propertyName]; | 141 var current = this.ttsProperties[propertyName]; |
142 current = increase ? current + step : current - step; | 142 current = increase ? current + step : current - step; |
143 this.ttsProperties[propertyName] = Math.max(Math.min(current, max), min); | 143 this.ttsProperties[propertyName] = Math.max(Math.min(current, max), min); |
144 }; | 144 }; |
145 | 145 |
146 /** | |
147 * Converts an engine property value to a percentage from 0.00 to 1.00. | |
148 * @param {string} property The property to convert. | |
149 * @return {?number} The percentage of the property. | |
150 */ | |
151 cvox.AbstractTts.prototype.propertyToPercentage = function(property) { | |
152 return (this.ttsProperties[property] - this.propertyMin[property]) / | |
153 Math.abs(this.propertyMax[property] - this.propertyMin[property]); | |
154 }; | |
155 | 146 |
156 /** | 147 /** |
157 * Merges the given properties with the default ones. Always returns a | 148 * Merges the given properties with the default ones. Always returns a |
158 * new object, so that you can safely modify the result of mergeProperties | 149 * new object, so that you can safely modify the result of mergeProperties |
159 * without worrying that you're modifying an object used elsewhere. | 150 * without worrying that you're modifying an object used elsewhere. |
160 * @param {Object=} properties The properties to merge with the current ones. | 151 * @param {Object=} properties The properties to merge with the current ones. |
161 * @return {Object} The merged properties. | 152 * @return {Object} The merged properties. |
162 * @protected | 153 * @protected |
163 */ | 154 */ |
164 cvox.AbstractTts.prototype.mergeProperties = function(properties) { | 155 cvox.AbstractTts.prototype.mergeProperties = function(properties) { |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 .format({'COUNT': count}) + ' '; | 558 .format({'COUNT': count}) + ' '; |
568 }; | 559 }; |
569 | 560 |
570 | 561 |
571 /** | 562 /** |
572 * @override | 563 * @override |
573 */ | 564 */ |
574 cvox.AbstractTts.prototype.getDefaultProperty = function(property) { | 565 cvox.AbstractTts.prototype.getDefaultProperty = function(property) { |
575 return this.propertyDefault[property]; | 566 return this.propertyDefault[property]; |
576 }; | 567 }; |
OLD | NEW |