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

Side by Side Diff: webrtc/modules/audio_processing/test/conversational_speech/generator_unittest.cc

Issue 2750353002: Conversational speech tool: timing model with data access. (Closed)
Patch Set: deps fixed 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 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 #include <cstdio>
12 #include <memory>
13
11 #include "webrtc/modules/audio_processing/test/conversational_speech/config.h" 14 #include "webrtc/modules/audio_processing/test/conversational_speech/config.h"
15 #include "webrtc/modules/audio_processing/test/conversational_speech/timing.h"
12 #include "webrtc/test/gtest.h" 16 #include "webrtc/test/gtest.h"
17 #include "webrtc/test/testsupport/fileutils.h"
13 18
14 namespace webrtc { 19 namespace webrtc {
15 namespace test { 20 namespace test {
16 namespace { 21 namespace {
17 22
23 using conversational_speech::LoadTiming;
24 using conversational_speech::SaveTiming;
25 using conversational_speech::Turn;
26
18 const char* const audiotracks_path = "/path/to/audiotracks"; 27 const char* const audiotracks_path = "/path/to/audiotracks";
19 const char* const timing_filepath = "/path/to/timing_file.txt"; 28 const char* const timing_filepath = "/path/to/timing_file.txt";
20 const char* const output_path = "/path/to/output_dir"; 29 const char* const output_path = "/path/to/output_dir";
21 30
31 const std::vector<Turn> expected_timing = {
32 {"A", "a1", 0},
33 {"B", "b1", 0},
34 {"A", "a2", 100},
35 {"B", "b2", -200},
36 {"A", "a3", 0},
37 {"A", "a4", 0},
38 };
39 const std::size_t kNumberOfTurns = expected_timing.size();
40
22 } // namespace 41 } // namespace
23 42
24 TEST(ConversationalSpeechTest, Settings) { 43 TEST(ConversationalSpeechTest, Settings) {
25 conversational_speech::Config config( 44 const conversational_speech::Config config(
26 audiotracks_path, timing_filepath, output_path); 45 audiotracks_path, timing_filepath, output_path);
27 46
28 // Test getters. 47 // Test getters.
29 EXPECT_EQ(config.audiotracks_path(), audiotracks_path); 48 EXPECT_EQ(audiotracks_path, config.audiotracks_path());
30 EXPECT_EQ(config.timing_filepath(), timing_filepath); 49 EXPECT_EQ(timing_filepath, config.timing_filepath());
31 EXPECT_EQ(config.output_path(), output_path); 50 EXPECT_EQ(output_path, config.output_path());
51 }
52
53 TEST(ConversationalSpeechTest, ExpectedTimingSize) {
54 // Check the expected timing size.
55 EXPECT_EQ(kNumberOfTurns, 6u);
56 }
57
58 TEST(ConversationalSpeechTest, TimingSaveLoad) {
59 // Save test timing.
60 const std::string temporary_filepath = webrtc::test::TempFilename(
61 webrtc::test::OutputPath(), "TempTimingTestFile");
62 SaveTiming(temporary_filepath, expected_timing);
63
64 // Create a std::vector<Turn> instance by loading from file.
65 std::vector<Turn> actual_timing = LoadTiming(temporary_filepath);
66 std::remove(temporary_filepath.c_str());
67
68 // Check size.
69 EXPECT_EQ(expected_timing.size(), actual_timing.size());
70
71 // Check Turn instances.
72 for (size_t index = 0; index < expected_timing.size(); ++index) {
73 EXPECT_EQ(expected_timing[index], actual_timing[index])
74 << "turn #" << index << " not matching";
75 }
32 } 76 }
33 77
34 } // namespace test 78 } // namespace test
35 } // namespace webrtc 79 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698