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

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

Powered by Google App Engine
This is Rietveld 408576698