>>> from wav2letter.decoder import LexiconFreeDecoder
Traceback (most recent call last):
File "
ImportError: cannot import name 'LexiconFreeDecoder'
Can you help me out?
Could you try just
import wav2letter
?
Could you try just
import wav2letter?
@tlikhomanenko
Yes,import wav2letterworks. Andimport wav2letter.decoderalso works. Butfrom wav2letter.decoder import LexiconFreeDecoderdoes not work.
ohh, sorry, didn't notice that you are importing LexiconFreeDecoder: we don't support it in python bindings right now. I will add this in future, but feel free to use this code (feel free to submit pull request on this as soon as you test if this works):
void LexiconFreeDecoder_decodeStep(
LexiconFreeDecoder& decoder,
uintptr_t emissions,
int T,
int N) {
decoder.decodeStep(reinterpret_cast<const float*>(emissions), T, N);
}
std::vector<DecodeResult> LexiconFreeDecoder_decode(
LexiconFreeDecoder& decoder,
uintptr_t emissions,
int T,
int N) {
return decoder.decode(reinterpret_cast<const float*>(emissions), T, N);
}
py::class_<LexiconFreeDecoder>(m, "LexiconFreeDecoder")
.def(py::init<
const DecoderOptions&,
const LMPtr,
const int,
const int,
const std::vector<float>&>())
.def("decode_begin", &LexiconFreeDecoder::decodeBegin)
.def(
"decode_step",
&LexiconFreeDecoder_decodeStep,
"emissions"_a,
"T"_a,
"N"_a)
.def("decode_end", &LexiconFreeDecoder::decodeEnd)
.def("decode", &LexiconFreeDecoder_decode, "emissions"_a, "T"_a, "N"_a)
.def("prune", &LexiconFreeDecoder::prune, "look_back"_a = 0)
.def(
"get_best_hypothesis",
&LexiconFreeDecoder::getBestHypothesis,
"look_back"_a = 0)
.def("get_all_final_hypothesis", &LexiconFreeDecoder::getAllFinalHypothesis);
Then you need to reinstall python bindings and LexiconFreeDecoder will be available.
ohh, sorry, didn't notice that you are importing LexiconFreeDecoder: we don't support it in python bindings right now. I will add this in future, but feel free to use this code (feel free to submit pull request on this as soon as you test if this works):
- add after line https://github.com/facebookresearch/wav2letter/blob/master/bindings/python/wav2letter/_decoder.cpp#L114
void LexiconFreeDecoder_decodeStep( LexiconFreeDecoder& decoder, uintptr_t emissions, int T, int N) { decoder.decodeStep(reinterpret_cast<const float*>(emissions), T, N); } std::vector<DecodeResult> LexiconFreeDecoder_decode( LexiconFreeDecoder& decoder, uintptr_t emissions, int T, int N) { return decoder.decode(reinterpret_cast<const float*>(emissions), T, N); }py::class_<LexiconFreeDecoder>(m, "LexiconFreeDecoder") .def(py::init< const DecoderOptions&, const LMPtr, const int, const int, const std::vector<float>&>()) .def("decode_begin", &LexiconFreeDecoder::decodeBegin) .def( "decode_step", &LexiconFreeDecoder_decodeStep, "emissions"_a, "T"_a, "N"_a) .def("decode_end", &LexiconFreeDecoder::decodeEnd) .def("decode", &LexiconFreeDecoder_decode, "emissions"_a, "T"_a, "N"_a) .def("prune", &LexiconFreeDecoder::prune, "look_back"_a = 0) .def( "get_best_hypothesis", &LexiconFreeDecoder::getBestHypothesis, "look_back"_a = 0) .def("get_all_final_hypothesis", &LexiconFreeDecoder::getAllFinalHypothesis);Then you need to reinstall python bindings and LexiconFreeDecoder will be available.
Many thanks! I'll try that later. Also I tried to use LexiconDecoder with a lexicon and that works well.
Also, need to include
#include "libraries/decoder/LexiconFreeDecoder.h"
around line 13
Thanks @Liam1030 for the help here
I was able to build...I'll submit a push if I'm able to test a model with this
Most helpful comment
Also, need to include
#include "libraries/decoder/LexiconFreeDecoder.h"around line 13
Thanks @Liam1030 for the help here
I was able to build...I'll submit a push if I'm able to test a model with this