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

Unified Diff: webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc

Issue 2790933002: Conversational speech tool, simualtor + unit tests (Closed)
Patch Set: Using AppendFolder() to build paths to folders Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc
diff --git a/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc b/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc
index ce8b60b466044c58023a7752d31a97bde1d9d7da..ac24b969d81e6cfe8ec9a1f3cd35450f38050daf 100644
--- a/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc
+++ b/webrtc/modules/audio_processing/test/conversational_speech/multiend_call.cc
@@ -21,10 +21,11 @@ MultiEndCall::MultiEndCall(
rtc::ArrayView<const Turn> timing, const std::string& audiotracks_path,
std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory)
: timing_(timing), audiotracks_path_(audiotracks_path),
- wavreader_abstract_factory_(std::move(wavreader_abstract_factory)) {
+ wavreader_abstract_factory_(std::move(wavreader_abstract_factory)),
+ valid_(false) {
FindSpeakerNames();
- CreateAudioTrackReaders();
- valid_ = CheckTiming();
+ if (CreateAudioTrackReaders())
+ valid_ = CheckTiming();
}
MultiEndCall::~MultiEndCall() = default;
@@ -42,6 +43,10 @@ bool MultiEndCall::valid() const {
return valid_;
}
+int MultiEndCall::sample_rate() const {
+ return sample_rate_;
+}
+
std::size_t MultiEndCall::total_duration_samples() const {
return total_duration_samples_;
}
@@ -58,8 +63,9 @@ void MultiEndCall::FindSpeakerNames() {
}
}
-void MultiEndCall::CreateAudioTrackReaders() {
+bool MultiEndCall::CreateAudioTrackReaders() {
RTC_DCHECK(audiotrack_readers_.empty());
+ sample_rate_ = 0; // Sample rate will be set when reading the first track.
for (const Turn& turn : timing_) {
auto it = audiotrack_readers_.find(turn.audiotrack_file_name);
if (it != audiotrack_readers_.end())
@@ -72,9 +78,24 @@ void MultiEndCall::CreateAudioTrackReaders() {
// Map the audiotrack file name to a new instance of WavReaderInterface.
std::unique_ptr<WavReaderInterface> wavreader =
wavreader_abstract_factory_->Create(audiotrack_file_path.pathname());
+
+ if (sample_rate_ == 0) {
+ sample_rate_ = wavreader->SampleRate();
+ } else if (sample_rate_ != wavreader->SampleRate()) {
+ LOG(LS_ERROR) << "all the audio tracks should have the same sample rate";
+ return false;
+ }
+
+ if (wavreader->NumChannels() != 1) {
+ LOG(LS_ERROR) << "only mono audio tracks supported";
+ return false;
+ }
+
audiotrack_readers_.emplace(
turn.audiotrack_file_name, std::move(wavreader));
}
+
+ return true;
}
bool MultiEndCall::CheckTiming() {

Powered by Google App Engine
This is Rietveld 408576698