| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/memory/singleton.h" | 5 #include "base/memory/singleton.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" | 10 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 if (!lang.empty()) { | 81 if (!lang.empty()) { |
| 82 AppendSpeakOption( | 82 AppendSpeakOption( |
| 83 chromeos::SpeechSynthesisLibrary::kSpeechPropertyLocale, | 83 chromeos::SpeechSynthesisLibrary::kSpeechPropertyLocale, |
| 84 lang, | 84 lang, |
| 85 &options); | 85 &options); |
| 86 } | 86 } |
| 87 | 87 |
| 88 if (params.rate >= 0.0) { | 88 if (params.rate >= 0.0) { |
| 89 AppendSpeakOption( | 89 AppendSpeakOption( |
| 90 chromeos::SpeechSynthesisLibrary::kSpeechPropertyRate, | 90 chromeos::SpeechSynthesisLibrary::kSpeechPropertyRate, |
| 91 DoubleToString(1.5 + params.rate * 2.5), | 91 DoubleToString(params.rate), |
| 92 &options); | 92 &options); |
| 93 } | 93 } |
| 94 | 94 |
| 95 if (params.pitch >= 0.0) { | 95 if (params.pitch >= 0.0) { |
| 96 // The TTS service allows a range of 0 to 2 for speech pitch. | 96 // The TTS service allows a range of 0 to 2 for speech pitch. |
| 97 AppendSpeakOption( | 97 AppendSpeakOption( |
| 98 chromeos::SpeechSynthesisLibrary::kSpeechPropertyPitch, | 98 chromeos::SpeechSynthesisLibrary::kSpeechPropertyPitch, |
| 99 DoubleToString(params.pitch), | 99 DoubleToString(params.pitch), |
| 100 &options); | 100 &options); |
| 101 } | 101 } |
| 102 | 102 |
| 103 if (params.volume >= 0.0) { | 103 if (params.volume >= 0.0) { |
| 104 // The TTS service allows a range of 0 to 5 for speech volume. | 104 // The Chrome OS TTS service allows a range of 0 to 5 for speech volume, |
| 105 // but 5 clips, so map to a range of 0...4. |
| 105 AppendSpeakOption( | 106 AppendSpeakOption( |
| 106 chromeos::SpeechSynthesisLibrary::kSpeechPropertyVolume, | 107 chromeos::SpeechSynthesisLibrary::kSpeechPropertyVolume, |
| 107 DoubleToString(params.volume * 5), | 108 DoubleToString(params.volume * 4), |
| 108 &options); | 109 &options); |
| 109 } | 110 } |
| 110 | 111 |
| 111 if (!options.empty()) { | 112 if (!options.empty()) { |
| 112 cros_library->GetSpeechSynthesisLibrary()->SetSpeakProperties( | 113 cros_library->GetSpeechSynthesisLibrary()->SetSpeakProperties( |
| 113 options.c_str()); | 114 options.c_str()); |
| 114 } | 115 } |
| 115 | 116 |
| 116 bool result = | 117 bool result = |
| 117 cros_library->GetSpeechSynthesisLibrary()->Speak(utterance.c_str()); | 118 cros_library->GetSpeechSynthesisLibrary()->Speak(utterance.c_str()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 chromeos::SpeechSynthesisLibrary::kSpeechPropertyEquals + | 180 chromeos::SpeechSynthesisLibrary::kSpeechPropertyEquals + |
| 180 value + | 181 value + |
| 181 chromeos::SpeechSynthesisLibrary::kSpeechPropertyDelimiter; | 182 chromeos::SpeechSynthesisLibrary::kSpeechPropertyDelimiter; |
| 182 } | 183 } |
| 183 | 184 |
| 184 // static | 185 // static |
| 185 ExtensionTtsPlatformImplChromeOs* | 186 ExtensionTtsPlatformImplChromeOs* |
| 186 ExtensionTtsPlatformImplChromeOs::GetInstance() { | 187 ExtensionTtsPlatformImplChromeOs::GetInstance() { |
| 187 return Singleton<ExtensionTtsPlatformImplChromeOs>::get(); | 188 return Singleton<ExtensionTtsPlatformImplChromeOs>::get(); |
| 188 } | 189 } |
| OLD | NEW |