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

Side by Side Diff: chrome/browser/resources/network_speech_synthesis/tts_extension.js

Issue 172863003: Fix encoding of UTF-8 characters sent to Google speech server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« 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 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
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
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();
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