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

Unified Diff: chrome/browser/speech/extension_api/tts_engine_extension_api.cc

Issue 969913002: Fix rate, pitch, and volume from web speech synthesis API to extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove logging Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/speech/extension_api/tts_engine_extension_api.cc
diff --git a/chrome/browser/speech/extension_api/tts_engine_extension_api.cc b/chrome/browser/speech/extension_api/tts_engine_extension_api.cc
index 6db90bedc4683c36d480facef4f72789e479b3bc..bc050e17c84965f2e3315e854f37de1b5edbd2c3 100644
--- a/chrome/browser/speech/extension_api/tts_engine_extension_api.cc
+++ b/chrome/browser/speech/extension_api/tts_engine_extension_api.cc
@@ -163,6 +163,22 @@ void TtsExtensionEngine::Speak(Utterance* utterance,
if (options->HasKey(constants::kOnEventKey))
options->Remove(constants::kOnEventKey, NULL);
+ // Get the volume, pitch, and rate, but only if they weren't already in
+ // the options. TODO(dmazzoni): these shouldn't be redundant.
+ // http://crbug.com/463264
+ if (!options->HasKey(constants::kRateKey)) {
+ options->SetDouble(constants::kRateKey,
+ utterance->continuous_parameters().rate);
+ }
+ if (!options->HasKey(constants::kPitchKey)) {
+ options->SetDouble(constants::kPitchKey,
+ utterance->continuous_parameters().pitch);
+ }
+ if (!options->HasKey(constants::kVolumeKey)) {
+ options->SetDouble(constants::kVolumeKey,
+ utterance->continuous_parameters().volume);
+ }
+
// Add the voice name and language to the options if they're not
// already there, since they might have been picked by the TTS controller
// rather than directly by the client that requested the speech.
@@ -174,6 +190,9 @@ void TtsExtensionEngine::Speak(Utterance* utterance,
args->Append(options.release());
args->AppendInteger(utterance->id());
+ std::string json;
+ base::JSONWriter::Write(args.get(), &json);
+
scoped_ptr<extensions::Event> event(new extensions::Event(
tts_engine_events::kOnSpeak, args.Pass()));
Profile* profile = Profile::FromBrowserContext(utterance->browser_context());
« 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