pybind.cc 1.9 KB
Newer Older
Y
Yibing Liu 已提交
1
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Y
Yibing Liu 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

Y
Yibing Liu 已提交
18
#include "post_latgen_faster_mapped.h"
Y
Yibing Liu 已提交
19 20 21

namespace py = pybind11;

Y
Yibing Liu 已提交
22
PYBIND11_MODULE(post_latgen_faster_mapped, m) {
23 24 25
  m.doc() = "Decoder for Deep ASR model";

  py::class_<Decoder>(m, "Decoder")
Y
Yibing Liu 已提交
26 27 28 29
      .def(py::init<std::string,
                    std::string,
                    std::string,
                    std::string,
Y
Yibing Liu 已提交
30
                    size_t,
Y
Yibing Liu 已提交
31
                    kaldi::BaseFloat>())
32 33
      .def("decode_from_file",
           (void (Decoder::*)(std::string, size_t)) & Decoder::decode_from_file,
Y
Yibing Liu 已提交
34
           "Decode for the probability matrices in specifier "
35
           "and print the transcriptions.")
Y
Yibing Liu 已提交
36 37 38 39 40 41
      .def(
          "decode",
          (std::string (Decoder::*)(
              std::string, const std::vector<std::vector<kaldi::BaseFloat>>&)) &
              Decoder::decode,
          "Decode one input probability matrix "
42 43 44
          "and return the transcription.")
      .def("decode_batch",
           (std::vector<std::string> (Decoder::*)(
45
               std::vector<std::string>,
46 47 48 49 50
               const std::vector<std::vector<std::vector<kaldi::BaseFloat>>>&,
               size_t num_processes)) &
               Decoder::decode_batch,
           "Decode one batch of probability matrices "
           "and return the transcriptions.");
Y
Yibing Liu 已提交
51
}