Fangjun Kuang
Committed by GitHub

Fix a bug for offline paraformer (#816)

@@ -96,3 +96,8 @@ spoken-language-identification-test-wavs @@ -96,3 +96,8 @@ spoken-language-identification-test-wavs
96 my-release-key* 96 my-release-key*
97 vits-zh-hf-fanchen-C 97 vits-zh-hf-fanchen-C
98 sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01 98 sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01
  99 +*.dll
  100 +*.lib
  101 +*.tar.gz
  102 +*.tar.bz2
  103 +*.zip
@@ -40,7 +40,7 @@ OfflineParaformerGreedySearchDecoder::Decode( @@ -40,7 +40,7 @@ OfflineParaformerGreedySearchDecoder::Decode(
40 } 40 }
41 41
42 if (us_cif_peak) { 42 if (us_cif_peak) {
43 - int32_t dim = us_cif_peak.GetTensorTypeAndShapeInfo().GetShape()[1]; 43 + int32_t dim = us_cif_peak.GetTensorTypeAndShapeInfo().GetShape().back();
44 44
45 const auto *peak = us_cif_peak.GetTensorData<float>() + i * dim; 45 const auto *peak = us_cif_peak.GetTensorData<float>() + i * dim;
46 std::vector<float> timestamps; 46 std::vector<float> timestamps;
@@ -57,7 +57,10 @@ OfflineParaformerGreedySearchDecoder::Decode( @@ -57,7 +57,10 @@ OfflineParaformerGreedySearchDecoder::Decode(
57 timestamps.push_back(k * scale); 57 timestamps.push_back(k * scale);
58 } 58 }
59 } 59 }
  60 +
  61 + if (!timestamps.empty()) {
60 timestamps.pop_back(); 62 timestamps.pop_back();
  63 + }
61 64
62 if (timestamps.size() == results[i].tokens.size()) { 65 if (timestamps.size() == results[i].tokens.size()) {
63 results[i].timestamps = std::move(timestamps); 66 results[i].timestamps = std::move(timestamps);