Commit 882a0402 authored by Benoit Favre's avatar Benoit Favre
Browse files

disable lattice generation, change partial hyp interval

parent ff37cb00
......@@ -615,6 +615,15 @@ static void gst_kaldinnet2onlinedecoder_final_result(
int64 *tot_num_frames, double *tot_like, guint *num_words) {
if (clat.NumStates() == 0) {
KALDI_WARN<< "Empty lattice.";
// ADDED
int hyp_length = 0;
GstBuffer *buffer = gst_buffer_new_and_alloc(hyp_length + 1);
gst_buffer_fill(buffer, 0, "", hyp_length);
gst_buffer_memset(buffer, hyp_length, '\n', 1);
gst_pad_push(filter->srcpad, buffer);
/* Emit a signal for applications. */
g_signal_emit(filter, gst_kaldinnet2onlinedecoder_signals[FINAL_RESULT_SIGNAL], 0, "");
return;
}
CompactLattice best_path_clat;
......@@ -764,7 +773,7 @@ static void gst_kaldinnet2onlinedecoder_loop(
GST_DEBUG_OBJECT(filter, "Starting decoding loop..");
#ifndef THREADED_DECODER // used for partial result, unavailable with threading
BaseFloat traceback_period_secs = 1.0;
BaseFloat traceback_period_secs = 0.2;
#endif
int32 chunk_length = int32(filter->sample_rate * filter->chunk_length_in_secs);
......@@ -810,24 +819,32 @@ static void gst_kaldinnet2onlinedecoder_loop(
#endif
}
#ifndef THREADED_DECODER // the threaded decoder just starts when it gets data
//fprintf(stderr, "START advance_decoding ()\n");
decoder.AdvanceDecoding();
//fprintf(stderr, " END advance_decoding ()\n");
#endif
if (!more_data) {
fprintf(stderr, "BREAK !more_data\n");
break;
}
//fprintf(stderr, "do_endpointing = %d\n", filter->do_endpointing);
filter->do_endpointing = true;
if (filter->do_endpointing
&& decoder.EndpointDetected(*(filter->endpoint_config))) {
#ifdef THREADED_DECODER // must stop it (the non-threaded is already idle)
decoder.TerminateDecoding();
#endif
GST_DEBUG_OBJECT(filter, "Endpoint detected!");
fprintf(stderr, "BREAK end_point\n");
break;
}
num_seconds_decoded += filter->chunk_length_in_secs;
#ifndef THREADED_DECODER // I think it's only relevant to the single-thread version
if (num_seconds_decoded - last_traceback > traceback_period_secs) {
Lattice lat;
//fprintf(stderr, "START get_best_path ()\n");
decoder.GetBestPath(false, &lat);
//fprintf(stderr, " END get_best_path ()\n");
gst_kaldinnet2onlinedecoder_partial_result(filter, lat);
last_traceback += traceback_period_secs;
}
......@@ -838,13 +855,17 @@ static void gst_kaldinnet2onlinedecoder_loop(
decoder.Wait();
#endif
GST_DEBUG_OBJECT(filter, "Getting lattice..");
//fprintf(stderr, "START finalize_decoding ()\n");
decoder.FinalizeDecoding();
//fprintf(stderr, " END finalize_decoding ()\n");
CompactLattice clat;
bool end_of_utterance = true;
#ifdef THREADED_DECODER
decoder.GetLattice(end_of_utterance, &clat, NULL);
#else
decoder.GetLattice(end_of_utterance, &clat);
//fprintf(stderr, "START get_lattice ()\n");
//decoder.GetLattice(end_of_utterance, &clat);
//fprintf(stderr, " END get_lattice ()\n");
#endif
GST_DEBUG_OBJECT(filter, "Lattice done");
if ((filter->lm_fst != NULL) && (filter->big_lm_const_arpa != NULL)) {
......@@ -859,8 +880,10 @@ static void gst_kaldinnet2onlinedecoder_loop(
int64 num_frames = 0;
guint num_words = 0;
//fprintf(stderr, "START final_result ()\n");
gst_kaldinnet2onlinedecoder_final_result(filter, clat, &num_frames,
&tot_like, &num_words);
//fprintf(stderr, " END final_result ()\n");
if (num_words > 0) {
// Only update adaptation state if the utterance was not empty
#ifdef THREADED_DECODER
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment