mirror of
https://github.com/csukuangfj/kaldifeat.git
synced 2025-08-13 12:02:19 +00:00
Change the way how FbankOptions is displayed
This commit is contained in:
parent
32948f9556
commit
c576fcf935
@ -44,20 +44,18 @@ struct FbankOptions {
|
||||
|
||||
std::string ToString() const {
|
||||
std::ostringstream os;
|
||||
os << "frame_opts: \n";
|
||||
os << frame_opts << "\n";
|
||||
os << "\n";
|
||||
os << "FbankOptions(";
|
||||
|
||||
os << "mel_opts: \n";
|
||||
os << mel_opts << "\n";
|
||||
os << "frame_opts=" << frame_opts.ToString() << ", ";
|
||||
os << "mel_opts=" << mel_opts.ToString() << ", ";
|
||||
|
||||
os << "use_energy: " << use_energy << "\n";
|
||||
os << "energy_floor: " << energy_floor << "\n";
|
||||
os << "raw_energy: " << raw_energy << "\n";
|
||||
os << "htk_compat: " << htk_compat << "\n";
|
||||
os << "use_log_fbank: " << use_log_fbank << "\n";
|
||||
os << "use_power: " << use_power << "\n";
|
||||
os << "device: " << device << "\n";
|
||||
os << "use_energy=" << (use_energy ? "True" : "False") << ", ";
|
||||
os << "energy_floor=" << energy_floor << ", ";
|
||||
os << "raw_energy=" << (raw_energy ? "True" : "False") << ", ";
|
||||
os << "htk_compat=" << (htk_compat ? "True" : "False") << ", ";
|
||||
os << "use_log_fbank=" << (use_log_fbank ? "True" : "False") << ", ";
|
||||
os << "use_power=" << (use_power ? "True" : "False") << ", ";
|
||||
os << "device=\"" << device << "\")";
|
||||
return os.str();
|
||||
}
|
||||
};
|
||||
|
@ -16,6 +16,34 @@ static void PybindFbankOptions(py::module &m) {
|
||||
using PyClass = FbankOptions;
|
||||
py::class_<PyClass>(m, "FbankOptions")
|
||||
.def(py::init<>())
|
||||
.def(py::init([](const FrameExtractionOptions &frame_opts =
|
||||
FrameExtractionOptions(),
|
||||
bool use_energy = false, float energy_floor = 0.0f,
|
||||
bool raw_energy = true, bool htk_compat = false,
|
||||
bool use_log_fbank = true, bool use_power = true,
|
||||
py::object device = py::str("cpu"),
|
||||
const MelBanksOptions &mel_opts)
|
||||
-> std::unique_ptr<FbankOptions> {
|
||||
auto opts = std::make_unique<FbankOptions>();
|
||||
opts->frame_opts = frame_opts;
|
||||
opts->mel_opts = mel_opts;
|
||||
opts->use_energy = use_energy;
|
||||
opts->energy_floor = energy_floor;
|
||||
opts->raw_energy = raw_energy;
|
||||
opts->htk_compat = htk_compat;
|
||||
opts->use_log_fbank = use_log_fbank;
|
||||
opts->use_power = use_power;
|
||||
|
||||
std::string s = static_cast<py::str>(device);
|
||||
opts->device = torch::Device(s);
|
||||
|
||||
return opts;
|
||||
}),
|
||||
py::arg("frame_opts") = FrameExtractionOptions(),
|
||||
py::arg("use_energy") = false, py::arg("energy_floor") = 0.0f,
|
||||
py::arg("raw_energy") = true, py::arg("htk_compat") = false,
|
||||
py::arg("use_log_fbank") = true, py::arg("use_power") = true,
|
||||
py::arg("device") = py::str("cpu"), py::arg("mel_opts"))
|
||||
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
||||
.def_readwrite("use_energy", &PyClass::use_energy)
|
||||
|
@ -12,6 +12,7 @@ import kaldifeat
|
||||
|
||||
def test_default():
|
||||
opts = kaldifeat.FbankOptions()
|
||||
print(opts)
|
||||
assert opts.frame_opts.samp_freq == 16000
|
||||
assert opts.frame_opts.frame_shift_ms == 10.0
|
||||
assert opts.frame_opts.frame_length_ms == 25.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user