Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check NumFramesDecoded when using intermediate #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Nnet3LatgenFasterDecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,9 @@ void Nnet3LatgenFasterDecoder::GetLattice(kaldi::CompactLattice *clat, bool end_
}
}


int32 Nnet3LatgenFasterDecoder::NumFramesDecoded() const {
return decoder_->NumFramesDecoded();
}

} /* namespace apiai */
1 change: 1 addition & 0 deletions src/Nnet3LatgenFasterDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Nnet3LatgenFasterDecoder: public OnlineDecoder {
virtual void InputFinished();
virtual void GetLattice(kaldi::CompactLattice *clat, bool end_of_utterance);
virtual void CleanUp();
virtual int32 NumFramesDecoded() const;
private:
std::string nnet3_rxfilename_;

Expand Down
5 changes: 3 additions & 2 deletions src/OnlineDecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ void OnlineDecoder::Decode(Request &request, Response &response) {

int time_left_ms = decoding_timeout_ms;
while ((wave_part = request.NextChunk(samples_left, time_left_ms)) != NULL) {

samp_counter += wave_part->Dim();

if (AcceptWaveform(request.Frequency(), *wave_part, do_endpointing) == false && do_endpointing) {
Expand All @@ -192,7 +191,9 @@ void OnlineDecoder::Decode(Request &request, Response &response) {
samples_left = std::min(max_samples_limit - samp_counter, samples_per_chunk);
}

if ((intermediate_samples_interval > 0) && (samp_counter > (intermediate_samples_interval * intermediate_counter))) {
if ((intermediate_samples_interval > 0)
&& (samp_counter > (intermediate_samples_interval * intermediate_counter))
&& NumFramesDecoded() > 0) {
intermediate_counter++;
std::vector<DecodedData> decodeData;
if (DecodeIntermediate(1, &decodeData) > 0) {
Expand Down
4 changes: 4 additions & 0 deletions src/OnlineDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class OnlineDecoder : public Decoder {
* Calculate intermediate results
*/
virtual kaldi::int32 DecodeIntermediate(int bestCount, std::vector<DecodedData> *result);
/**
* Return the number of frames decoded thus far
*/
virtual int32 NumFramesDecoded() const = 0;

std::string word_syms_rxfilename_;
kaldi::BaseFloat chunk_length_secs_;
Expand Down