Allow modify model config at decode time for ASR (#1124)

This commit is contained in:
ivan provalov
2024-07-13 07:30:47 -07:00
committed by GitHub
parent ab71c3976d
commit de04b3b9bf
15 changed files with 121 additions and 13 deletions

View File

@@ -12,6 +12,10 @@
namespace sherpa_onnx {
void OfflineWhisperGreedySearchDecoder::SetConfig(const OfflineWhisperModelConfig &config) {
config_ = config;
}
std::vector<OfflineWhisperDecoderResult>
OfflineWhisperGreedySearchDecoder::Decode(Ort::Value cross_k,
Ort::Value cross_v) {
@@ -129,6 +133,13 @@ OfflineWhisperGreedySearchDecoder::Decode(Ort::Value cross_k,
std::vector<OfflineWhisperDecoderResult> ans(1);
const auto &id2lang = model_->GetID2Lang();
if (id2lang.count(initial_tokens[1])) {
ans[0].lang = id2lang.at(initial_tokens[1]);
} else {
ans[0].lang = "";
}
ans[0].tokens = std::move(predicted_tokens);
return ans;