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

Side by Side Diff: content/browser/speech/speech_recognizer_impl_unittest.cc

Issue 549373003: Binding media stream audio track to speech recognition [browser] Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wait with no timeout Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « content/browser/speech/speech_recognizer_impl.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <vector> 5 #include <vector>
6 6
7 #include "content/browser/browser_thread_impl.h" 7 #include "content/browser/browser_thread_impl.h"
8 #include "content/browser/speech/google_one_shot_remote_engine.h" 8 #include "content/browser/speech/google_one_shot_remote_engine.h"
9 #include "content/browser/speech/speech_recognizer_impl.h" 9 #include "content/browser/speech/speech_recognizer_impl.h"
10 #include "content/public/browser/speech_recognition_event_listener.h" 10 #include "content/public/browser/speech_recognition_event_listener.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 SpeechRecognitionEngine* sr_engine = 48 SpeechRecognitionEngine* sr_engine =
49 new GoogleOneShotRemoteEngine(NULL /* URLRequestContextGetter */); 49 new GoogleOneShotRemoteEngine(NULL /* URLRequestContextGetter */);
50 SpeechRecognitionEngineConfig config; 50 SpeechRecognitionEngineConfig config;
51 config.audio_num_bits_per_sample = 51 config.audio_num_bits_per_sample =
52 SpeechRecognizerImpl::kNumBitsPerAudioSample; 52 SpeechRecognizerImpl::kNumBitsPerAudioSample;
53 config.audio_sample_rate = SpeechRecognizerImpl::kAudioSampleRate; 53 config.audio_sample_rate = SpeechRecognizerImpl::kAudioSampleRate;
54 config.filter_profanities = false; 54 config.filter_profanities = false;
55 sr_engine->SetConfig(config); 55 sr_engine->SetConfig(config);
56 56
57 const int kTestingSessionId = 1; 57 const int kTestingSessionId = 1;
58 recognizer_ = new SpeechRecognizerImpl( 58 recognizer_ = new SpeechRecognizerImpl(this,
59 this, kTestingSessionId, false, false, sr_engine); 59 kTestingSessionId,
60 false, // continuous
61 false, // provisional_results
62 false, // using_audio_receiver
63 base::kNullProcessHandle,
64 sr_engine);
60 audio_manager_.reset(new media::MockAudioManager( 65 audio_manager_.reset(new media::MockAudioManager(
61 base::MessageLoop::current()->message_loop_proxy().get())); 66 base::MessageLoop::current()->message_loop_proxy().get()));
62 recognizer_->SetAudioManagerForTesting(audio_manager_.get()); 67 recognizer_->SetAudioManagerForTesting(audio_manager_.get());
63 68
64 int audio_packet_length_bytes = 69 int audio_packet_length_bytes =
65 (SpeechRecognizerImpl::kAudioSampleRate * 70 (SpeechRecognizerImpl::kAudioSampleRate *
66 GoogleOneShotRemoteEngine::kAudioPacketIntervalMs * 71 GoogleOneShotRemoteEngine::kAudioPacketIntervalMs *
67 ChannelLayoutToChannelCount(SpeechRecognizerImpl::kChannelLayout) * 72 ChannelLayoutToChannelCount(SpeechRecognizerImpl::kChannelLayout) *
68 SpeechRecognizerImpl::kNumBitsPerAudioSample) / (8 * 1000); 73 SpeechRecognizerImpl::kNumBitsPerAudioSample) / (8 * 1000);
69 audio_packet_.resize(audio_packet_length_bytes); 74 audio_packet_.resize(audio_packet_length_bytes);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 CheckEventsConsistency(); 134 CheckEventsConsistency();
130 } 135 }
131 136
132 void OnRecognitionStart(int session_id) override { 137 void OnRecognitionStart(int session_id) override {
133 recognition_started_ = true; 138 recognition_started_ = true;
134 CheckEventsConsistency(); 139 CheckEventsConsistency();
135 } 140 }
136 141
137 void OnEnvironmentEstimationComplete(int session_id) override {} 142 void OnEnvironmentEstimationComplete(int session_id) override {}
138 143
144 virtual void OnAudioReceiverReady(
145 int session_id,
146 const media::AudioParameters& params,
147 const base::SharedMemoryHandle memory,
148 const base::SyncSocket::TransitDescriptor socket) override {}
149
139 void OnSoundStart(int session_id) override { 150 void OnSoundStart(int session_id) override {
140 sound_started_ = true; 151 sound_started_ = true;
141 CheckEventsConsistency(); 152 CheckEventsConsistency();
142 } 153 }
143 154
144 void OnSoundEnd(int session_id) override { 155 void OnSoundEnd(int session_id) override {
145 sound_ended_ = true; 156 sound_ended_ = true;
146 CheckEventsConsistency(); 157 CheckEventsConsistency();
147 } 158 }
148 159
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 510
500 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); 511 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_);
501 EXPECT_FALSE(audio_ended_); 512 EXPECT_FALSE(audio_ended_);
502 EXPECT_FALSE(recognition_ended_); 513 EXPECT_FALSE(recognition_ended_);
503 recognizer_->AbortRecognition(); 514 recognizer_->AbortRecognition();
504 base::MessageLoop::current()->RunUntilIdle(); 515 base::MessageLoop::current()->RunUntilIdle();
505 CheckFinalEventsConsistency(); 516 CheckFinalEventsConsistency();
506 } 517 }
507 518
508 } // namespace content 519 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/speech/speech_recognizer_impl.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698