janitor

janitor
git clone https://git.prime8.dev/janitor.git
Log | Files | Refs | README | LICENSE

mel-computations.cc (2211B)


      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 
     19 #include "kaldi-native-fbank/python/csrc/mel-computations.h"
     20 
     21 #include <string>
     22 
     23 #include "kaldi-native-fbank/csrc/mel-computations.h"
     24 #include "kaldi-native-fbank/python/csrc/utils.h"
     25 
     26 namespace knf {
     27 
     28 static void PybindMelBanksOptions(py::module &m) {  // NOLINT
     29   using PyClass = MelBanksOptions;
     30   py::class_<PyClass>(m, "MelBanksOptions")
     31       .def(py::init<>())
     32       .def_readwrite("num_bins", &PyClass::num_bins)
     33       .def_readwrite("low_freq", &PyClass::low_freq)
     34       .def_readwrite("high_freq", &PyClass::high_freq)
     35       .def_readwrite("vtln_low", &PyClass::vtln_low)
     36       .def_readwrite("vtln_high", &PyClass::vtln_high)
     37       .def_readwrite("debug_mel", &PyClass::debug_mel)
     38       .def_readwrite("htk_mode", &PyClass::htk_mode)
     39       .def_readwrite("is_librosa", &PyClass::is_librosa)
     40       .def_readwrite("norm", &PyClass::norm)
     41       .def("__str__",
     42            [](const PyClass &self) -> std::string { return self.ToString(); })
     43       .def("as_dict",
     44            [](const PyClass &self) -> py::dict { return AsDict(self); })
     45       .def_static("from_dict",
     46                   [](py::dict dict) -> PyClass {
     47                     return MelBanksOptionsFromDict(dict);
     48                   })
     49       .def(py::pickle(
     50           [](const PyClass &self) -> py::dict { return AsDict(self); },
     51           [](py::dict dict) -> PyClass {
     52             return MelBanksOptionsFromDict(dict);
     53           }));
     54 }
     55 
     56 void PybindMelComputations(py::module &m) {  // NOLINT
     57   PybindMelBanksOptions(m);
     58 }
     59 
     60 }  // namespace knf