OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <math.h> | 5 #include <math.h> |
6 #include <sapi.h> | 6 #include <sapi.h> |
7 | 7 |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 suffix = L"</pitch>"; | 93 suffix = L"</pitch>"; |
94 } | 94 } |
95 | 95 |
96 if (params.volume >= 0.0) { | 96 if (params.volume >= 0.0) { |
97 // The TTS api allows a range of 0 to 100 for speech volume. | 97 // The TTS api allows a range of 0 to 100 for speech volume. |
98 speech_synthesizer_->SetVolume(static_cast<uint16>(params.volume * 100)); | 98 speech_synthesizer_->SetVolume(static_cast<uint16>(params.volume * 100)); |
99 } | 99 } |
100 | 100 |
101 // TODO(dmazzoni): convert SSML to SAPI xml. http://crbug.com/88072 | 101 // TODO(dmazzoni): convert SSML to SAPI xml. http://crbug.com/88072 |
102 | 102 |
103 utterance_ = UTF8ToWide(src_utterance); | 103 utterance_ = base::UTF8ToWide(src_utterance); |
104 utterance_id_ = utterance_id; | 104 utterance_id_ = utterance_id; |
105 char_position_ = 0; | 105 char_position_ = 0; |
106 std::wstring merged_utterance = prefix + utterance_ + suffix; | 106 std::wstring merged_utterance = prefix + utterance_ + suffix; |
107 prefix_len_ = prefix.size(); | 107 prefix_len_ = prefix.size(); |
108 | 108 |
109 HRESULT result = speech_synthesizer_->Speak( | 109 HRESULT result = speech_synthesizer_->Speak( |
110 merged_utterance.c_str(), | 110 merged_utterance.c_str(), |
111 SPF_ASYNC, | 111 SPF_ASYNC, |
112 &stream_number_); | 112 &stream_number_); |
113 return (result == S_OK); | 113 return (result == S_OK); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 TtsPlatformImplWin* TtsPlatformImplWin::GetInstance() { | 209 TtsPlatformImplWin* TtsPlatformImplWin::GetInstance() { |
210 return Singleton<TtsPlatformImplWin, | 210 return Singleton<TtsPlatformImplWin, |
211 LeakySingletonTraits<TtsPlatformImplWin> >::get(); | 211 LeakySingletonTraits<TtsPlatformImplWin> >::get(); |
212 } | 212 } |
213 | 213 |
214 // static | 214 // static |
215 void TtsPlatformImplWin::SpeechEventCallback( | 215 void TtsPlatformImplWin::SpeechEventCallback( |
216 WPARAM w_param, LPARAM l_param) { | 216 WPARAM w_param, LPARAM l_param) { |
217 GetInstance()->OnSpeechEvent(); | 217 GetInstance()->OnSpeechEvent(); |
218 } | 218 } |
OLD | NEW |