Commit e2db68ee authored by dmazzoni's avatar dmazzoni Committed by Commit bot

Fix rate, pitch, and volume from web speech synthesis API to extensions.

The web speech synthesis API was correctly passing through an utterance's
rate, pitch, and volume to native TTS, but not to extension-based speech.
This fixes the bug, and I filed another bug to clean up the redundancy that
led to this bug being there.

BUG=376280

Review URL: https://codereview.chromium.org/969913002

Cr-Commit-Position: refs/heads/master@{#320946}
parent 36da2435
...@@ -163,6 +163,22 @@ void TtsExtensionEngine::Speak(Utterance* utterance, ...@@ -163,6 +163,22 @@ void TtsExtensionEngine::Speak(Utterance* utterance,
if (options->HasKey(constants::kOnEventKey)) if (options->HasKey(constants::kOnEventKey))
options->Remove(constants::kOnEventKey, NULL); 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 // 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 // already there, since they might have been picked by the TTS controller
// rather than directly by the client that requested the speech. // rather than directly by the client that requested the speech.
...@@ -174,6 +190,9 @@ void TtsExtensionEngine::Speak(Utterance* utterance, ...@@ -174,6 +190,9 @@ void TtsExtensionEngine::Speak(Utterance* utterance,
args->Append(options.release()); args->Append(options.release());
args->AppendInteger(utterance->id()); args->AppendInteger(utterance->id());
std::string json;
base::JSONWriter::Write(args.get(), &json);
scoped_ptr<extensions::Event> event(new extensions::Event( scoped_ptr<extensions::Event> event(new extensions::Event(
tts_engine_events::kOnSpeak, args.Pass())); tts_engine_events::kOnSpeak, args.Pass()));
Profile* profile = Profile::FromBrowserContext(utterance->browser_context()); Profile* profile = Profile::FromBrowserContext(utterance->browser_context());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment