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

Side by Side Diff: webrtc/modules/audio_processing/test/conversational_speech/multiend_call.h

Issue 2781573002: Conversational Speech tool, MultiEndCall::CheckTiming() and tests (Closed)
Patch Set: final refactoring Created 3 years, 8 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MULTIEND_CALL _H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MULTIEND_CALL _H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MULTIEND_CALL _H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MULTIEND_CALL _H_
13 13
14 #include <map> 14 #include <map>
15 #include <memory> 15 #include <memory>
16 #include <set> 16 #include <set>
17 #include <string> 17 #include <string>
18 #include <utility>
19 #include <vector>
18 20
19 #include "webrtc/base/array_view.h" 21 #include "webrtc/base/array_view.h"
20 #include "webrtc/base/constructormagic.h" 22 #include "webrtc/base/constructormagic.h"
21 #include "webrtc/modules/audio_processing/test/conversational_speech/timing.h" 23 #include "webrtc/modules/audio_processing/test/conversational_speech/timing.h"
22 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_a bstract_factory.h" 24 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_a bstract_factory.h"
23 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_i nterface.h" 25 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_i nterface.h"
24 26
25 namespace webrtc { 27 namespace webrtc {
26 namespace test { 28 namespace test {
27 namespace conversational_speech { 29 namespace conversational_speech {
28 30
29 class MultiEndCall { 31 class MultiEndCall {
30 public: 32 public:
33 struct SpeakingTurn {
34 // Constructor required in order to use std::vector::emaplace().
35 SpeakingTurn(std::string new_speaker_name,
36 std::string new_audiotrack_file_name,
37 std::size_t new_begin, std::size_t new_end)
hlundin-webrtc 2017/04/06 08:10:04 We tend to use size_t instead of std::size_t. Incl
AleBzk 2017/04/06 16:42:42 Done.
38 : speaker_name(std::move(new_speaker_name)),
hlundin-webrtc 2017/04/06 08:10:04 In not an expert in move semantics, but this looks
kwiberg-webrtc 2017/04/06 08:35:32 Well, yes. It's up to the caller to create the B t
AleBzk 2017/04/06 16:42:42 Thanks for your comments on this point. Before ans
hlundin-webrtc 2017/04/07 10:24:09 You can keep this as is. I was mainly concerned th
AleBzk 2017/04/07 11:37:06 Acknowledged.
39 audiotrack_file_name(std::move(new_audiotrack_file_name)),
40 begin(new_begin), end(new_end) {}
41 std::string speaker_name;
42 std::string audiotrack_file_name;
43 std::size_t begin;
44 std::size_t end;
45 };
46
31 MultiEndCall( 47 MultiEndCall(
32 rtc::ArrayView<const Turn> timing, const std::string& audiotracks_path, 48 rtc::ArrayView<const Turn> timing, const std::string& audiotracks_path,
33 std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory); 49 std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory);
34 ~MultiEndCall(); 50 ~MultiEndCall();
35 51
36 const std::set<std::string>& speaker_names() const; 52 const std::set<std::string>& speaker_names() const;
37 const std::map<std::string, std::unique_ptr<WavReaderInterface>>& 53 const std::map<std::string, std::unique_ptr<WavReaderInterface>>&
38 audiotrack_readers() const; 54 audiotrack_readers() const;
55 bool valid() const;
56 std::size_t total_duration_samples() const;
hlundin-webrtc 2017/04/06 08:10:04 size_t
AleBzk 2017/04/06 16:42:42 Done.
57 const std::vector<SpeakingTurn>& speaking_turns() const;
39 58
40 private: 59 private:
41 // Find unique speaker names. 60 // Finds unique speaker names.
42 void FindSpeakerNames(); 61 void FindSpeakerNames();
43 62
44 // Create one WavReader instance for each unique audiotrack. 63 // Creates one WavReader instance for each unique audiotrack.
45 void CreateAudioTrackReaders(); 64 void CreateAudioTrackReaders();
46 65
47 // Check the speaking turns timing. 66 // Validates the speaking turns timing information. Accepts cross-talk, but
48 void CheckTiming(); 67 // only up to 2 speakers. Rejects unordered turns and self cross-talk.
68 bool CheckTiming();
69
70 // Detects cross-talk, which occurs when two turns from the same speaker
71 // overlap in time.
72 bool DetectSelfCrossTalk(
73 const std::vector<std::size_t>& speaking_turn_indices) const;
hlundin-webrtc 2017/04/06 08:10:04 size_t
AleBzk 2017/04/06 16:42:42 Done.
49 74
50 rtc::ArrayView<const Turn> timing_; 75 rtc::ArrayView<const Turn> timing_;
51 const std::string& audiotracks_path_; 76 const std::string& audiotracks_path_;
52 std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory_; 77 std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory_;
53 std::set<std::string> speaker_names_; 78 std::set<std::string> speaker_names_;
54 std::map<std::string, std::unique_ptr<WavReaderInterface>> 79 std::map<std::string, std::unique_ptr<WavReaderInterface>>
55 audiotrack_readers_; 80 audiotrack_readers_;
81 bool valid_;
82 std::size_t total_duration_samples_;
hlundin-webrtc 2017/04/06 08:10:04 size_t
AleBzk 2017/04/06 16:42:42 Done.
83 std::vector<SpeakingTurn> speaking_turns_;
56 84
57 RTC_DISALLOW_COPY_AND_ASSIGN(MultiEndCall); 85 RTC_DISALLOW_COPY_AND_ASSIGN(MultiEndCall);
58 }; 86 };
59 87
60 } // namespace conversational_speech 88 } // namespace conversational_speech
61 } // namespace test 89 } // namespace test
62 } // namespace webrtc 90 } // namespace webrtc
63 91
64 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MULTIEND_C ALL_H_ 92 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_MULTIEND_C ALL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698