mel-computations.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Copyright (c) 2022 Xiaomi Corporation (authors: Fangjun Kuang)
  3. *
  4. * See LICENSE for clarification regarding multiple authors
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include "kaldi-native-fbank/python/csrc/mel-computations.h"
  19. #include <string>
  20. #include "mel-computations.h"
  21. #include "kaldi-native-fbank/python/csrc/utils.h"
  22. namespace knf {
  23. static void PybindMelBanksOptions(py::module &m) { // NOLINT
  24. using PyClass = MelBanksOptions;
  25. py::class_<PyClass>(m, "MelBanksOptions")
  26. .def(py::init<>())
  27. .def_readwrite("num_bins", &PyClass::num_bins)
  28. .def_readwrite("low_freq", &PyClass::low_freq)
  29. .def_readwrite("high_freq", &PyClass::high_freq)
  30. .def_readwrite("vtln_low", &PyClass::vtln_low)
  31. .def_readwrite("vtln_high", &PyClass::vtln_high)
  32. .def_readwrite("debug_mel", &PyClass::debug_mel)
  33. .def_readwrite("htk_mode", &PyClass::htk_mode)
  34. .def("__str__",
  35. [](const PyClass &self) -> std::string { return self.ToString(); })
  36. .def("as_dict",
  37. [](const PyClass &self) -> py::dict { return AsDict(self); })
  38. .def_static("from_dict",
  39. [](py::dict dict) -> PyClass {
  40. return MelBanksOptionsFromDict(dict);
  41. })
  42. .def(py::pickle(
  43. [](const PyClass &self) -> py::dict { return AsDict(self); },
  44. [](py::dict dict) -> PyClass {
  45. return MelBanksOptionsFromDict(dict);
  46. }));
  47. }
  48. void PybindMelComputations(py::module &m) { // NOLINT
  49. PybindMelBanksOptions(m);
  50. }
  51. } // namespace knf