mirror of
https://github.com/csukuangfj/kaldifeat.git
synced 2025-08-15 13:02:20 +00:00
small fixes
This commit is contained in:
parent
68c0414bde
commit
f28857495d
@ -62,21 +62,20 @@ struct FrameExtractionOptions {
|
|||||||
}
|
}
|
||||||
std::string ToString() const {
|
std::string ToString() const {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
#define KALDIFEAT_PRINT(x) os << #x << ": " << x << "\n"
|
os << "FrameExtractionOptions(";
|
||||||
KALDIFEAT_PRINT(samp_freq);
|
os << "samp_freq=" << samp_freq << ", ";
|
||||||
KALDIFEAT_PRINT(frame_shift_ms);
|
os << "frame_shift_ms=" << frame_shift_ms << ", ";
|
||||||
KALDIFEAT_PRINT(frame_length_ms);
|
os << "frame_length_ms=" << frame_length_ms << ", ";
|
||||||
KALDIFEAT_PRINT(dither);
|
os << "dither=" << dither << ", ";
|
||||||
KALDIFEAT_PRINT(preemph_coeff);
|
os << "preemph_coeff=" << preemph_coeff << ", ";
|
||||||
KALDIFEAT_PRINT(remove_dc_offset);
|
os << "remove_dc_offset=" << (remove_dc_offset ? "True" : "False") << ", ";
|
||||||
KALDIFEAT_PRINT(window_type);
|
os << "window_type=" << '"' << window_type << '"' << ", ";
|
||||||
KALDIFEAT_PRINT(round_to_power_of_two);
|
os << "round_to_power_of_two=" << (round_to_power_of_two ? "True" : "False")
|
||||||
KALDIFEAT_PRINT(blackman_coeff);
|
<< ", ";
|
||||||
KALDIFEAT_PRINT(snip_edges);
|
os << "blackman_coeff=" << blackman_coeff << ", ";
|
||||||
// KALDIFEAT_PRINT(allow_downsample);
|
os << "snip_edges=" << (snip_edges ? "True" : "False") << ", ";
|
||||||
// KALDIFEAT_PRINT(allow_upsample);
|
os << "max_feature_vectors=" << max_feature_vectors << ")";
|
||||||
KALDIFEAT_PRINT(max_feature_vectors);
|
|
||||||
#undef KALDIFEAT_PRINT
|
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -70,26 +70,7 @@ static void PybindFrameExtractionOptions(py::module &m) {
|
|||||||
.def_readwrite("allow_upsample", &PyClass::allow_upsample)
|
.def_readwrite("allow_upsample", &PyClass::allow_upsample)
|
||||||
#endif
|
#endif
|
||||||
.def("__str__",
|
.def("__str__",
|
||||||
[](const PyClass &self) -> std::string {
|
[](const PyClass &self) -> std::string { return self.ToString(); })
|
||||||
std::ostringstream os;
|
|
||||||
os << "FrameExtractionOptions(";
|
|
||||||
os << "samp_freq=" << self.samp_freq << ", ";
|
|
||||||
os << "frame_shift_ms=" << self.frame_shift_ms << ", ";
|
|
||||||
os << "frame_length_ms=" << self.frame_length_ms << ", ";
|
|
||||||
os << "dither=" << self.dither << ", ";
|
|
||||||
os << "preemph_coeff=" << self.preemph_coeff << ", ";
|
|
||||||
os << "remove_dc_offset="
|
|
||||||
<< (self.remove_dc_offset ? "True" : "False") << ", ";
|
|
||||||
os << "window_type=" << '"' << self.window_type << '"' << ", ";
|
|
||||||
os << "round_to_power_of_two="
|
|
||||||
<< (self.round_to_power_of_two ? "True" : "False") << ", ";
|
|
||||||
os << "blackman_coeff=" << self.blackman_coeff << ", ";
|
|
||||||
os << "snip_edges=" << (self.snip_edges ? "True" : "False")
|
|
||||||
<< ", ";
|
|
||||||
os << "max_feature_vectors=" << self.max_feature_vectors << ")";
|
|
||||||
|
|
||||||
return os.str();
|
|
||||||
})
|
|
||||||
.def(py::pickle(
|
.def(py::pickle(
|
||||||
[](const PyClass &self) -> py::dict { return AsDict(self); },
|
[](const PyClass &self) -> py::dict { return AsDict(self); },
|
||||||
[](py::dict dict) -> PyClass {
|
[](py::dict dict) -> PyClass {
|
||||||
|
@ -9,6 +9,7 @@ import kaldifeat
|
|||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
opts = kaldifeat.FrameExtractionOptions()
|
opts = kaldifeat.FrameExtractionOptions()
|
||||||
|
print(opts)
|
||||||
assert opts.samp_freq == 16000
|
assert opts.samp_freq == 16000
|
||||||
assert opts.frame_shift_ms == 10.0
|
assert opts.frame_shift_ms == 10.0
|
||||||
assert opts.frame_length_ms == 25.0
|
assert opts.frame_length_ms == 25.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user