OLD | NEW |
1 // Copyright (c) 2010 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 "content/browser/speech/endpointer/endpointer.h" | 5 #include "content/browser/speech/endpointer/endpointer.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace { | 8 namespace { |
9 const int kFrameRate = 50; // 20 ms long frames for AMR encoding. | 9 const int kFrameRate = 50; // 20 ms long frames for AMR encoding. |
10 const int kSampleRate = 8000; // 8 k samples per second for AMR encoding. | 10 const int kSampleRate = 8000; // 8 k samples per second for AMR encoding. |
11 | 11 |
12 // At 8 sample per second a 20 ms frame is 160 samples, which corrsponds | 12 // At 8 sample per second a 20 ms frame is 160 samples, which corrsponds |
13 // to the AMR codec. | 13 // to the AMR codec. |
14 const int kFrameSize = kSampleRate / kFrameRate; // 160 samples. | 14 const int kFrameSize = kSampleRate / kFrameRate; // 160 samples. |
15 COMPILE_ASSERT(kFrameSize == 160, invalid_frame_size); | 15 COMPILE_ASSERT(kFrameSize == 160, invalid_frame_size); |
16 } | 16 } |
17 | 17 |
18 namespace speech_input { | 18 namespace speech { |
19 | 19 |
20 class FrameProcessor { | 20 class FrameProcessor { |
21 public: | 21 public: |
22 // Process a single frame of test audio samples. | 22 // Process a single frame of test audio samples. |
23 virtual EpStatus ProcessFrame(int64 time, int16* samples, int frame_size) = 0; | 23 virtual EpStatus ProcessFrame(int64 time, int16* samples, int frame_size) = 0; |
24 }; | 24 }; |
25 | 25 |
26 void RunEndpointerEventsTest(FrameProcessor* processor) { | 26 void RunEndpointerEventsTest(FrameProcessor* processor) { |
27 int16 samples[kFrameSize]; | 27 int16 samples[kFrameSize]; |
28 | 28 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 const int64 long_timeout = 500 * kMillisecondsPerMicrosecond; | 135 const int64 long_timeout = 500 * kMillisecondsPerMicrosecond; |
136 endpointer.set_speech_input_complete_silence_length(long_timeout); | 136 endpointer.set_speech_input_complete_silence_length(long_timeout); |
137 endpointer.StartSession(); | 137 endpointer.StartSession(); |
138 | 138 |
139 EndpointerFrameProcessor frame_processor(&endpointer); | 139 EndpointerFrameProcessor frame_processor(&endpointer); |
140 RunEndpointerEventsTest(&frame_processor); | 140 RunEndpointerEventsTest(&frame_processor); |
141 | 141 |
142 endpointer.EndSession(); | 142 endpointer.EndSession(); |
143 } | 143 } |
144 | 144 |
145 } // namespace speech_input | 145 } // namespace speech |
OLD | NEW |