Fix a bug for offline paraformer (#816)

This commit is contained in:
Fangjun Kuang
2024-04-26 16:40:42 +08:00
committed by GitHub
parent 612002da57
commit f2d074aea9
2 changed files with 10 additions and 2 deletions

5
.gitignore vendored
View File

@@ -96,3 +96,8 @@ spoken-language-identification-test-wavs
my-release-key*
vits-zh-hf-fanchen-C
sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01
*.dll
*.lib
*.tar.gz
*.tar.bz2
*.zip

View File

@@ -40,7 +40,7 @@ OfflineParaformerGreedySearchDecoder::Decode(
}
if (us_cif_peak) {
int32_t dim = us_cif_peak.GetTensorTypeAndShapeInfo().GetShape()[1];
int32_t dim = us_cif_peak.GetTensorTypeAndShapeInfo().GetShape().back();
const auto *peak = us_cif_peak.GetTensorData<float>() + i * dim;
std::vector<float> timestamps;
@@ -57,7 +57,10 @@ OfflineParaformerGreedySearchDecoder::Decode(
timestamps.push_back(k * scale);
}
}
timestamps.pop_back();
if (!timestamps.empty()) {
timestamps.pop_back();
}
if (timestamps.size() == results[i].tokens.size()) {
results[i].timestamps = std::move(timestamps);