OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 6 * @fileoverview |
7 * This is a component extension that implements a text-to-speech (TTS) | 7 * This is a component extension that implements a text-to-speech (TTS) |
8 * engine powered by Google's speech synthesis API. | 8 * engine powered by Google's speech synthesis API. |
9 * | 9 * |
10 * This is an "event page", so it's not loaded when the API isn't being used, | 10 * This is an "event page", so it's not loaded when the API isn't being used, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Look up the specific voice name for this language and gender. | 142 // Look up the specific voice name for this language and gender. |
143 // If it's not in the map, it doesn't matter - the language will | 143 // If it's not in the map, it doesn't matter - the language will |
144 // be used directly. This is only used for languages where more | 144 // be used directly. This is only used for languages where more |
145 // than one gender is actually available. | 145 // than one gender is actually available. |
146 var key = lang.toLowerCase() + '-' + gender; | 146 var key = lang.toLowerCase() + '-' + gender; |
147 var voiceName = this.LANG_AND_GENDER_TO_VOICE_NAME_[key]; | 147 var voiceName = this.LANG_AND_GENDER_TO_VOICE_NAME_[key]; |
148 | 148 |
149 var url = this.SPEECH_SERVER_URL_; | 149 var url = this.SPEECH_SERVER_URL_; |
150 chrome.systemPrivate.getApiKey((function(key) { | 150 chrome.systemPrivate.getApiKey((function(key) { |
151 url += '&key=' + key; | 151 url += '&key=' + key; |
152 url += '&text=' + escape(utterance); | 152 url += '&text=' + encodeURIComponent(utterance); |
153 url += '&lang=' + lang.toLowerCase(); | 153 url += '&lang=' + lang.toLowerCase(); |
154 | 154 |
155 if (voiceName) | 155 if (voiceName) |
156 url += '&name=' + voiceName; | 156 url += '&name=' + voiceName; |
157 | 157 |
158 if (options.rate) { | 158 if (options.rate) { |
159 // Input rate is between 0.1 and 10.0 with a default of 1.0. | 159 // Input rate is between 0.1 and 10.0 with a default of 1.0. |
160 // Output speed is between 0.0 and 1.0 with a default of 0.5. | 160 // Output speed is between 0.0 and 1.0 with a default of 0.5. |
161 url += '&speed=' + (options.rate / 2.0); | 161 url += '&speed=' + (options.rate / 2.0); |
162 } | 162 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 */ | 245 */ |
246 onResume_: function() { | 246 onResume_: function() { |
247 if (this.currentUtterance_) { | 247 if (this.currentUtterance_) { |
248 this.audioElement_.play(); | 248 this.audioElement_.play(); |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 }; | 252 }; |
253 | 253 |
254 (new TtsExtension()).init(); | 254 (new TtsExtension()).init(); |
OLD | NEW |