mirror of
https://github.com/csukuangfj/kaldifeat.git
synced 2025-08-09 18:12:17 +00:00
Change how options are displayed (#62)
* Change the way how FrameExtractionOptions is displayed * small fixes * Change the way how MelBankOptions is displayed * Change the way how SpectrogramOptions is displayed * Change the way how FbankOptions is displayed * Change the way how MfccOptions is displayed * Change the way how PlpOptions is displayed * Export num_frames * release v1.22
This commit is contained in:
parent
8ee0c34d3a
commit
94a567c638
@ -7,7 +7,7 @@ project(kaldifeat)
|
||||
# remember to change the version in
|
||||
# scripts/conda/kaldifeat/meta.yaml
|
||||
# scripts/conda-cpu/kaldifeat/meta.yaml
|
||||
set(kaldifeat_VERSION "1.21")
|
||||
set(kaldifeat_VERSION "1.22")
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
@ -53,20 +53,18 @@ struct MfccOptions {
|
||||
|
||||
std::string ToString() const {
|
||||
std::ostringstream os;
|
||||
os << "frame_opts: \n";
|
||||
os << frame_opts << "\n";
|
||||
os << "\n";
|
||||
os << "MfccOptions(";
|
||||
os << "frame_opts=" << frame_opts.ToString() << ", ";
|
||||
os << "mel_opts=" << mel_opts.ToString() << ", ";
|
||||
|
||||
os << "mel_opts: \n";
|
||||
os << mel_opts << "\n";
|
||||
os << "num_ceps=" << num_ceps << ", ";
|
||||
os << "use_energy=" << (use_energy ? "True" : "False") << ", ";
|
||||
os << "energy_floor=" << energy_floor << ", ";
|
||||
os << "raw_energy=" << (raw_energy ? "True" : "False") << ", ";
|
||||
os << "cepstral_lifter=" << cepstral_lifter << ", ";
|
||||
os << "htk_compat=" << (htk_compat ? "True" : "False") << ", ";
|
||||
os << "device=\"" << device << "\")";
|
||||
|
||||
os << "num_ceps: " << num_ceps << "\n";
|
||||
os << "use_energy: " << use_energy << "\n";
|
||||
os << "energy_floor: " << energy_floor << "\n";
|
||||
os << "raw_energy: " << raw_energy << "\n";
|
||||
os << "cepstral_lifter: " << cepstral_lifter << "\n";
|
||||
os << "htk_compat: " << htk_compat << "\n";
|
||||
os << "device: " << device << "\n";
|
||||
return os.str();
|
||||
}
|
||||
};
|
||||
|
@ -61,23 +61,21 @@ struct PlpOptions {
|
||||
|
||||
std::string ToString() const {
|
||||
std::ostringstream os;
|
||||
os << "frame_opts: \n";
|
||||
os << frame_opts << "\n";
|
||||
os << "\n";
|
||||
os << "PlpOptions(";
|
||||
|
||||
os << "mel_opts: \n";
|
||||
os << mel_opts << "\n";
|
||||
os << "frame_opts=" << frame_opts.ToString() << ", ";
|
||||
os << "mel_opts=" << mel_opts.ToString() << ", ";
|
||||
|
||||
os << "lpc_order: " << lpc_order << "\n";
|
||||
os << "num_ceps: " << num_ceps << "\n";
|
||||
os << "use_energy: " << use_energy << "\n";
|
||||
os << "energy_floor: " << energy_floor << "\n";
|
||||
os << "raw_energy: " << raw_energy << "\n";
|
||||
os << "compress_factor: " << compress_factor << "\n";
|
||||
os << "cepstral_lifter: " << cepstral_lifter << "\n";
|
||||
os << "cepstral_scale: " << cepstral_scale << "\n";
|
||||
os << "htk_compat: " << htk_compat << "\n";
|
||||
os << "device: " << device << "\n";
|
||||
os << "lpc_order=" << lpc_order << ", ";
|
||||
os << "num_ceps=" << num_ceps << ", ";
|
||||
os << "use_energy=" << (use_energy ? "True" : "False") << ", ";
|
||||
os << "energy_floor=" << energy_floor << ", ";
|
||||
os << "raw_energy=" << (raw_energy ? "True" : "False") << ", ";
|
||||
os << "compress_factor=" << compress_factor << ", ";
|
||||
os << "cepstral_lifter=" << cepstral_lifter << ", ";
|
||||
os << "cepstral_scale=" << cepstral_scale << ", ";
|
||||
os << "htk_compat=" << (htk_compat ? "True" : "False") << ", ";
|
||||
os << "device=\"" << device << "\")";
|
||||
return os.str();
|
||||
}
|
||||
};
|
||||
|
@ -36,13 +36,12 @@ struct SpectrogramOptions {
|
||||
|
||||
std::string ToString() const {
|
||||
std::ostringstream os;
|
||||
os << "frame_opts: \n";
|
||||
os << frame_opts << "\n";
|
||||
|
||||
os << "energy_floor: " << energy_floor << "\n";
|
||||
os << "raw_energy: " << raw_energy << "\n";
|
||||
// os << "return_raw_fft: " << return_raw_fft << "\n";
|
||||
os << "device: " << device << "\n";
|
||||
os << "SpectrogramOptions(";
|
||||
os << "frame_opts=" << frame_opts.ToString() << ", ";
|
||||
os << "energy_floor=" << energy_floor << ", ";
|
||||
os << "raw_energy=" << (raw_energy ? "True" : "False") << ", ";
|
||||
os << "return_raw_fft=" << (return_raw_fft ? "True" : "False") << ", ";
|
||||
os << "device=\"" << device << "\")";
|
||||
return os.str();
|
||||
}
|
||||
};
|
||||
|
@ -62,21 +62,20 @@ struct FrameExtractionOptions {
|
||||
}
|
||||
std::string ToString() const {
|
||||
std::ostringstream os;
|
||||
#define KALDIFEAT_PRINT(x) os << #x << ": " << x << "\n"
|
||||
KALDIFEAT_PRINT(samp_freq);
|
||||
KALDIFEAT_PRINT(frame_shift_ms);
|
||||
KALDIFEAT_PRINT(frame_length_ms);
|
||||
KALDIFEAT_PRINT(dither);
|
||||
KALDIFEAT_PRINT(preemph_coeff);
|
||||
KALDIFEAT_PRINT(remove_dc_offset);
|
||||
KALDIFEAT_PRINT(window_type);
|
||||
KALDIFEAT_PRINT(round_to_power_of_two);
|
||||
KALDIFEAT_PRINT(blackman_coeff);
|
||||
KALDIFEAT_PRINT(snip_edges);
|
||||
// KALDIFEAT_PRINT(allow_downsample);
|
||||
// KALDIFEAT_PRINT(allow_upsample);
|
||||
KALDIFEAT_PRINT(max_feature_vectors);
|
||||
#undef KALDIFEAT_PRINT
|
||||
os << "FrameExtractionOptions(";
|
||||
os << "samp_freq=" << samp_freq << ", ";
|
||||
os << "frame_shift_ms=" << frame_shift_ms << ", ";
|
||||
os << "frame_length_ms=" << frame_length_ms << ", ";
|
||||
os << "dither=" << dither << ", ";
|
||||
os << "preemph_coeff=" << preemph_coeff << ", ";
|
||||
os << "remove_dc_offset=" << (remove_dc_offset ? "True" : "False") << ", ";
|
||||
os << "window_type=" << '"' << window_type << '"' << ", ";
|
||||
os << "round_to_power_of_two=" << (round_to_power_of_two ? "True" : "False")
|
||||
<< ", ";
|
||||
os << "blackman_coeff=" << blackman_coeff << ", ";
|
||||
os << "snip_edges=" << (snip_edges ? "True" : "False") << ", ";
|
||||
os << "max_feature_vectors=" << max_feature_vectors << ")";
|
||||
|
||||
return os.str();
|
||||
}
|
||||
};
|
||||
|
@ -36,13 +36,14 @@ struct MelBanksOptions {
|
||||
|
||||
std::string ToString() const {
|
||||
std::ostringstream os;
|
||||
os << "num_bins: " << num_bins << "\n";
|
||||
os << "low_freq: " << low_freq << "\n";
|
||||
os << "high_freq: " << high_freq << "\n";
|
||||
os << "vtln_low: " << vtln_low << "\n";
|
||||
os << "vtln_high: " << vtln_high << "\n";
|
||||
os << "debug_mel: " << debug_mel << "\n";
|
||||
os << "htk_mode: " << htk_mode << "\n";
|
||||
os << "MelBanksOptions(";
|
||||
os << "num_bins=" << num_bins << ", ";
|
||||
os << "low_freq=" << low_freq << ", ";
|
||||
os << "high_freq=" << high_freq << ", ";
|
||||
os << "vtln_low=" << vtln_low << ", ";
|
||||
os << "vtln_high=" << vtln_high << ", ";
|
||||
os << "debug_mel=" << (debug_mel ? "True" : "False") << ", ";
|
||||
os << "htk_mode=" << (htk_mode ? "True" : "False") << ")";
|
||||
return os.str();
|
||||
}
|
||||
};
|
||||
|
@ -16,6 +16,35 @@ static void PybindFbankOptions(py::module &m) {
|
||||
using PyClass = FbankOptions;
|
||||
py::class_<PyClass>(m, "FbankOptions")
|
||||
.def(py::init<>())
|
||||
.def(py::init([](const MelBanksOptions &mel_opts,
|
||||
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")) -> 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("mel_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"))
|
||||
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
||||
.def_readwrite("use_energy", &PyClass::use_energy)
|
||||
|
@ -16,6 +16,35 @@ void PybindMfccOptions(py::module &m) {
|
||||
using PyClass = MfccOptions;
|
||||
py::class_<PyClass>(m, "MfccOptions")
|
||||
.def(py::init<>())
|
||||
.def(py::init([](const MelBanksOptions &mel_opts,
|
||||
const FrameExtractionOptions &frame_opts =
|
||||
FrameExtractionOptions(),
|
||||
int32_t num_ceps = 13, bool use_energy = true,
|
||||
float energy_floor = 0.0, bool raw_energy = true,
|
||||
float cepstral_lifter = 22.0, bool htk_compat = false,
|
||||
py::object device =
|
||||
py::str("cpu")) -> std::unique_ptr<MfccOptions> {
|
||||
auto opts = std::make_unique<MfccOptions>();
|
||||
opts->frame_opts = frame_opts;
|
||||
opts->mel_opts = mel_opts;
|
||||
opts->num_ceps = num_ceps;
|
||||
opts->use_energy = use_energy;
|
||||
opts->energy_floor = energy_floor;
|
||||
opts->raw_energy = raw_energy;
|
||||
opts->cepstral_lifter = cepstral_lifter;
|
||||
opts->htk_compat = htk_compat;
|
||||
|
||||
std::string s = static_cast<py::str>(device);
|
||||
opts->device = torch::Device(s);
|
||||
|
||||
return opts;
|
||||
}),
|
||||
py::arg("mel_opts"),
|
||||
py::arg("frame_opts") = FrameExtractionOptions(),
|
||||
py::arg("num_ceps") = 13, py::arg("use_energy") = true,
|
||||
py::arg("energy_floor") = 0.0f, py::arg("raw_energy") = true,
|
||||
py::arg("cepstral_lifter") = 22.0, py::arg("htk_compat") = false,
|
||||
py::arg("device") = py::str("cpu"))
|
||||
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
||||
.def_readwrite("num_ceps", &PyClass::num_ceps)
|
||||
|
@ -16,6 +16,41 @@ void PybindPlpOptions(py::module &m) {
|
||||
using PyClass = PlpOptions;
|
||||
py::class_<PyClass>(m, "PlpOptions")
|
||||
.def(py::init<>())
|
||||
.def(py::init([](const MelBanksOptions &mel_opts,
|
||||
const FrameExtractionOptions &frame_opts =
|
||||
FrameExtractionOptions(),
|
||||
int32_t lpc_order = 12, int32_t num_ceps = 13,
|
||||
bool use_energy = true, float energy_floor = 0.0,
|
||||
bool raw_energy = true, float compress_factor = 0.33333,
|
||||
int32_t cepstral_lifter = 22, float cepstral_scale = 1.0,
|
||||
bool htk_compat = false,
|
||||
py::object device =
|
||||
py::str("cpu")) -> std::unique_ptr<PlpOptions> {
|
||||
auto opts = std::make_unique<PlpOptions>();
|
||||
opts->frame_opts = frame_opts;
|
||||
opts->mel_opts = mel_opts;
|
||||
opts->lpc_order = lpc_order;
|
||||
opts->num_ceps = num_ceps;
|
||||
opts->use_energy = use_energy;
|
||||
opts->energy_floor = energy_floor;
|
||||
opts->raw_energy = raw_energy;
|
||||
opts->compress_factor = compress_factor;
|
||||
opts->cepstral_lifter = cepstral_lifter;
|
||||
opts->cepstral_scale = cepstral_scale;
|
||||
opts->htk_compat = htk_compat;
|
||||
|
||||
std::string s = static_cast<py::str>(device);
|
||||
opts->device = torch::Device(s);
|
||||
|
||||
return opts;
|
||||
}),
|
||||
py::arg("mel_opts"),
|
||||
py::arg("frame_opts") = FrameExtractionOptions(),
|
||||
py::arg("lpc_order") = 12, py::arg("num_ceps") = 13,
|
||||
py::arg("use_energy") = true, py::arg("energy_floor") = 0.0,
|
||||
py::arg("raw_energy") = true, py::arg("compress_factor") = 0.33333,
|
||||
py::arg("cepstral_lifter") = 22, py::arg("cepstral_scale") = 1.0,
|
||||
py::arg("htk_compat") = false, py::arg("device") = py::str("cpu"))
|
||||
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
||||
.def_readwrite("lpc_order", &PyClass::lpc_order)
|
||||
|
@ -15,7 +15,27 @@ namespace kaldifeat {
|
||||
static void PybindSpectrogramOptions(py::module &m) {
|
||||
using PyClass = SpectrogramOptions;
|
||||
py::class_<PyClass>(m, "SpectrogramOptions")
|
||||
.def(py::init<>())
|
||||
.def(py::init([](const FrameExtractionOptions &frame_opts =
|
||||
FrameExtractionOptions(),
|
||||
float energy_floor = 0.0, bool raw_energy = true,
|
||||
bool return_raw_fft = false,
|
||||
py::object device = py::str(
|
||||
"cpu")) -> std::unique_ptr<SpectrogramOptions> {
|
||||
auto opts = std::make_unique<SpectrogramOptions>();
|
||||
opts->frame_opts = frame_opts;
|
||||
opts->energy_floor = energy_floor;
|
||||
opts->raw_energy = raw_energy;
|
||||
opts->return_raw_fft = return_raw_fft;
|
||||
|
||||
std::string s = static_cast<py::str>(device);
|
||||
opts->device = torch::Device(s);
|
||||
|
||||
return opts;
|
||||
}),
|
||||
py::arg("frame_opts") = FrameExtractionOptions(),
|
||||
py::arg("energy_floor") = 0.0, py::arg("raw_energy") = true,
|
||||
py::arg("return_raw_fft") = false,
|
||||
py::arg("device") = py::str("cpu"))
|
||||
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||
.def_readwrite("energy_floor", &PyClass::energy_floor)
|
||||
.def_readwrite("raw_energy", &PyClass::raw_energy)
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "kaldifeat/python/csrc/feature-window.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "kaldifeat/csrc/feature-window.h"
|
||||
@ -14,7 +15,38 @@ namespace kaldifeat {
|
||||
static void PybindFrameExtractionOptions(py::module &m) {
|
||||
using PyClass = FrameExtractionOptions;
|
||||
py::class_<PyClass>(m, "FrameExtractionOptions")
|
||||
.def(py::init<>())
|
||||
.def(
|
||||
py::init([](float samp_freq = 16000, float frame_shift_ms = 10.0f,
|
||||
float frame_length_ms = 25.0f, float dither = 1.0f,
|
||||
float preemph_coeff = 0.97f, bool remove_dc_offset = true,
|
||||
const std::string &window_type = "povey",
|
||||
bool round_to_power_of_two = true,
|
||||
float blackman_coeff = 0.42f, bool snip_edges = true,
|
||||
int32_t max_feature_vectors =
|
||||
-1) -> std::unique_ptr<FrameExtractionOptions> {
|
||||
auto opts = std::make_unique<FrameExtractionOptions>();
|
||||
|
||||
opts->samp_freq = samp_freq;
|
||||
opts->frame_shift_ms = frame_shift_ms;
|
||||
opts->frame_length_ms = frame_length_ms;
|
||||
opts->dither = dither;
|
||||
opts->preemph_coeff = preemph_coeff;
|
||||
opts->remove_dc_offset = remove_dc_offset;
|
||||
opts->window_type = window_type;
|
||||
opts->round_to_power_of_two = round_to_power_of_two;
|
||||
opts->blackman_coeff = blackman_coeff;
|
||||
opts->snip_edges = snip_edges;
|
||||
opts->max_feature_vectors = max_feature_vectors;
|
||||
|
||||
return opts;
|
||||
}),
|
||||
py::arg("samp_freq") = 16000, py::arg("frame_shift_ms") = 10.0f,
|
||||
py::arg("frame_length_ms") = 25.0f, py::arg("dither") = 1.0f,
|
||||
py::arg("preemph_coeff") = 0.97f, py::arg("remove_dc_offset") = true,
|
||||
py::arg("window_type") = "povey",
|
||||
py::arg("round_to_power_of_two") = true,
|
||||
py::arg("blackman_coeff") = 0.42f, py::arg("snip_edges") = true,
|
||||
py::arg("max_feature_vectors") = -1)
|
||||
.def_readwrite("samp_freq", &PyClass::samp_freq)
|
||||
.def_readwrite("frame_shift_ms", &PyClass::frame_shift_ms)
|
||||
.def_readwrite("frame_length_ms", &PyClass::frame_length_ms)
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "kaldifeat/python/csrc/mel-computations.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "kaldifeat/csrc/mel-computations.h"
|
||||
@ -14,7 +15,24 @@ namespace kaldifeat {
|
||||
static void PybindMelBanksOptions(py::module &m) {
|
||||
using PyClass = MelBanksOptions;
|
||||
py::class_<PyClass>(m, "MelBanksOptions")
|
||||
.def(py::init<>())
|
||||
.def(py::init(
|
||||
[](int32_t num_bins = 25, float low_freq = 20,
|
||||
float high_freq = 0, float vtln_low = 100,
|
||||
float vtln_high = -500,
|
||||
bool debug_mel = false) -> std::unique_ptr<MelBanksOptions> {
|
||||
auto opts = std::make_unique<MelBanksOptions>();
|
||||
|
||||
opts->num_bins = num_bins;
|
||||
opts->low_freq = low_freq;
|
||||
opts->high_freq = high_freq;
|
||||
opts->vtln_low = vtln_low;
|
||||
opts->vtln_high = vtln_high;
|
||||
|
||||
return opts;
|
||||
}),
|
||||
py::arg("num_bins") = 25, py::arg("low_freq") = 20,
|
||||
py::arg("high_freq") = 0, py::arg("vtln_low") = 100,
|
||||
py::arg("vtln_high") = -500, py::arg("debug_mel") = false)
|
||||
.def_readwrite("num_bins", &PyClass::num_bins)
|
||||
.def_readwrite("low_freq", &PyClass::low_freq)
|
||||
.def_readwrite("high_freq", &PyClass::high_freq)
|
||||
|
@ -8,6 +8,8 @@ if torch.__version__.split("+")[0] != kaldifeat_torch_version.split("+")[0]:
|
||||
f"But you are using PyTorch {torch.__version__} to run it"
|
||||
)
|
||||
|
||||
from pathlib import Path as _Path
|
||||
|
||||
from _kaldifeat import (
|
||||
FbankOptions,
|
||||
FrameExtractionOptions,
|
||||
@ -15,6 +17,7 @@ from _kaldifeat import (
|
||||
MfccOptions,
|
||||
PlpOptions,
|
||||
SpectrogramOptions,
|
||||
num_frames,
|
||||
)
|
||||
|
||||
from .fbank import Fbank, OnlineFbank
|
||||
@ -24,7 +27,5 @@ from .online_feature import OnlineFeature
|
||||
from .plp import OnlinePlp, Plp
|
||||
from .spectrogram import Spectrogram
|
||||
|
||||
from pathlib import Path as _Path
|
||||
|
||||
cmake_prefix_path = _Path(__file__).parent / "share" / "cmake"
|
||||
del _Path
|
||||
|
@ -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
|
||||
|
@ -9,6 +9,7 @@ import kaldifeat
|
||||
|
||||
def test_default():
|
||||
opts = kaldifeat.FrameExtractionOptions()
|
||||
print(opts)
|
||||
assert opts.samp_freq == 16000
|
||||
assert opts.frame_shift_ms == 10.0
|
||||
assert opts.frame_length_ms == 25.0
|
||||
@ -22,7 +23,9 @@ def test_default():
|
||||
|
||||
|
||||
def test_set_get():
|
||||
opts = kaldifeat.FrameExtractionOptions()
|
||||
opts = kaldifeat.FrameExtractionOptions(samp_freq=22150)
|
||||
assert opts.samp_freq == 22150
|
||||
|
||||
opts.samp_freq = 44100
|
||||
assert opts.samp_freq == 44100
|
||||
|
||||
|
@ -9,6 +9,7 @@ import kaldifeat
|
||||
|
||||
def test_default():
|
||||
opts = kaldifeat.MelBanksOptions()
|
||||
print(opts)
|
||||
assert opts.num_bins == 25
|
||||
assert opts.low_freq == 20
|
||||
assert opts.high_freq == 0
|
||||
@ -19,10 +20,12 @@ def test_default():
|
||||
|
||||
|
||||
def test_set_get():
|
||||
opts = kaldifeat.MelBanksOptions()
|
||||
opts.num_bins = 100
|
||||
opts = kaldifeat.MelBanksOptions(num_bins=100)
|
||||
assert opts.num_bins == 100
|
||||
|
||||
opts.num_bins = 200
|
||||
assert opts.num_bins == 200
|
||||
|
||||
opts.low_freq = 22
|
||||
assert opts.low_freq == 22
|
||||
|
||||
|
@ -12,6 +12,7 @@ import kaldifeat
|
||||
|
||||
def test_default():
|
||||
opts = kaldifeat.MfccOptions()
|
||||
print(opts)
|
||||
|
||||
assert opts.frame_opts.samp_freq == 16000
|
||||
assert opts.frame_opts.frame_shift_ms == 10.0
|
||||
|
@ -12,6 +12,7 @@ import kaldifeat
|
||||
|
||||
def test_default():
|
||||
opts = kaldifeat.PlpOptions()
|
||||
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
|
||||
|
@ -12,6 +12,7 @@ import kaldifeat
|
||||
|
||||
def test_default():
|
||||
opts = kaldifeat.SpectrogramOptions()
|
||||
print(opts)
|
||||
|
||||
assert opts.frame_opts.samp_freq == 16000
|
||||
assert opts.frame_opts.frame_shift_ms == 10.0
|
||||
@ -30,7 +31,8 @@ def test_default():
|
||||
|
||||
|
||||
def test_set_get():
|
||||
opts = kaldifeat.SpectrogramOptions()
|
||||
opts = kaldifeat.SpectrogramOptions(energy_floor=10)
|
||||
assert opts.energy_floor == 10
|
||||
|
||||
opts.energy_floor = 1
|
||||
assert opts.energy_floor == 1
|
||||
@ -138,6 +140,30 @@ def test_pickle():
|
||||
assert str(opts) == str(opts2)
|
||||
|
||||
|
||||
def test_device():
|
||||
opts = kaldifeat.SpectrogramOptions(device="cpu")
|
||||
assert opts.device == torch.device("cpu")
|
||||
|
||||
opts = kaldifeat.SpectrogramOptions(device="cuda")
|
||||
assert opts.device == torch.device("cuda")
|
||||
|
||||
opts = kaldifeat.SpectrogramOptions(device="cuda:1")
|
||||
assert opts.device == torch.device("cuda:1")
|
||||
print(opts)
|
||||
|
||||
opts = kaldifeat.SpectrogramOptions(device=torch.device("cpu"))
|
||||
assert opts.device == torch.device("cpu")
|
||||
|
||||
opts = kaldifeat.SpectrogramOptions(device=torch.device("cuda"))
|
||||
assert opts.device == torch.device("cuda")
|
||||
|
||||
opts = kaldifeat.SpectrogramOptions(device=torch.device("cuda:3"))
|
||||
assert opts.device == torch.device("cuda:3")
|
||||
|
||||
opts = kaldifeat.SpectrogramOptions(device=torch.device("cuda", 2))
|
||||
assert opts.device == torch.device("cuda", 2)
|
||||
|
||||
|
||||
def main():
|
||||
test_default()
|
||||
test_set_get()
|
||||
@ -146,6 +172,7 @@ def main():
|
||||
test_from_dict_partial()
|
||||
test_from_dict_full_and_as_dict()
|
||||
test_pickle()
|
||||
test_device()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,6 +1,6 @@
|
||||
package:
|
||||
name: kaldifeat
|
||||
version: "1.21"
|
||||
version: "1.22"
|
||||
|
||||
source:
|
||||
path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}"
|
||||
|
@ -1,6 +1,6 @@
|
||||
package:
|
||||
name: kaldifeat
|
||||
version: "1.21"
|
||||
version: "1.22"
|
||||
|
||||
source:
|
||||
path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user