diff --git a/omni/BUILD b/omni/BUILD index ea163f1..5db777e 100644 --- a/omni/BUILD +++ b/omni/BUILD @@ -263,6 +263,7 @@ cc_binary( "//omni/text2speech:qwen3_tts", # build_cleaner: keep "//runtime/executor:default_gpu_accelerator", "//runtime/proto:any2any_session_config_cc_proto", + "//runtime/proto:speech2text_metadata_cc_proto", "//runtime/proto:speech2text_session_config_cc_proto", "//runtime/proto:text2image_session_config_cc_proto", "//runtime/proto:text2speech_session_config_cc_proto", diff --git a/omni/omni_runner.cc b/omni/omni_runner.cc index ba0e53f..1be1840 100644 --- a/omni/omni_runner.cc +++ b/omni/omni_runner.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include // NOLINT: Required for std::error_code. #include @@ -44,6 +45,7 @@ #include "omni/omni_registry.h" #include "omni/omni_session.h" #include "runtime/proto/any2any_session_config.pb.h" +#include "runtime/proto/speech2text_metadata.pb.h" #include "runtime/proto/speech2text_session_config.pb.h" #include "runtime/proto/text2image_session_config.pb.h" #include "runtime/proto/text2speech_session_config.pb.h" @@ -87,6 +89,11 @@ ABSL_FLAG(float, overlap_ratio, 0.4f, "ASR chunk overlap ratio between 0.0 and 1.0."); ABSL_FLAG(std::string, text_merger_type, "timestamp", "ASR text merger strategy: timestamp or levenshtein."); +ABSL_FLAG(std::optional, asr_decode_skip_until_token_id, std::nullopt, + "Overrides Speech2TextMetadata.decode_skip_until_token_id, the token " + "that ends the model's header before the transcript (e.g. " + " for fine-tuned Qwen3-ASR checkpoints with a remapped " + "vocabulary). -1 disables header skipping."); // TTS session flags. ABSL_FLAG(std::string, language, "en-US", @@ -307,9 +314,11 @@ absl::Status RunOmniRunner() { litert::lm::proto::Any2AnySessionConfig any2any_config; litert::lm::proto::Speech2TextSessionConfig asr_config; + litert::lm::proto::Speech2TextMetadata asr_metadata; litert::lm::proto::Text2SpeechSessionConfig tts_config; litert::lm::proto::Text2ImageSessionConfig t2i_config; const MessageLite* session_config = nullptr; + const MessageLite* metadata = nullptr; if (reg.metadata_proto_type_id == "litert.lm.proto.Any2AnyMetadata") { any2any_config.set_generate_audio(absl::GetFlag(FLAGS_generate_audio)); @@ -338,6 +347,12 @@ absl::Status RunOmniRunner() { TEXT_MERGER_TYPE_TIMESTAMP); } session_config = &asr_config; + if (const auto skip_until_id = + absl::GetFlag(FLAGS_asr_decode_skip_until_token_id); + skip_until_id.has_value()) { + asr_metadata.set_decode_skip_until_token_id(*skip_until_id); + metadata = &asr_metadata; + } } else if (reg.metadata_proto_type_id == "litert.lm.proto.Text2ImageMetadata") { if (text.empty()) { @@ -387,7 +402,8 @@ absl::Status RunOmniRunner() { const absl::Time load_start = absl::Now(); ABSL_ASSIGN_OR_RETURN( - auto engine, OmniEngine::Create(model_name, settings, session_config)); + auto engine, + OmniEngine::Create(model_name, settings, session_config, metadata)); const double load_sec = absl::ToDoubleSeconds(absl::Now() - load_start); ABSL_LOG(INFO) << absl::StrFormat("Loaded OmniEngine '%s' in %.3f s.", engine->model_name(), load_sec);