#pragma once #include "engine/framework/assets/resource_bundle.h" #include "engine/framework/audio/dsp.h" #include "engine/framework/audio/nemo_mel_frontend.h" #include "engine/framework/core/backend_weight_store.h" #include "engine/framework/core/execution_context.h" #include "engine/framework/modules/conformer_modules.h" #include "engine/framework/modules/transformers/transformer_blocks.h" #include "engine/framework/runtime/model.h" #include "engine/framework/runtime/cache_slots.h" #include "engine/framework/tokenizers/sentencepiece.h" #include #include #include namespace engine::models::cohere_asr { struct CohereAssets { assets::ResourceBundle resources; std::shared_ptr source; std::vector vocabulary; std::vector window; audio::SparseMelFilterbank filterbank; std::shared_ptr frontend; int32_t special_token(const std::string & text) const; }; struct CohereWeights { std::unique_ptr store; modules::DepthwiseConvSubsamplingWeights subsampling; modules::LinearWeights encoder_out, head; std::vector encoder; std::vector decoder; core::TensorValue embedding, positions; modules::NormWeights embedding_norm, decoder_norm; }; std::shared_ptr load_cohere_assets(const std::filesystem::path & path); std::unique_ptr load_cohere_weights( const CohereAssets & assets, core::ExecutionContext & execution, assets::TensorStorageType type); audio::AudioTensor extract_cohere_frontend( const std::vector & samples, const CohereAssets & assets, size_t threads); class CohereRuntime { public: CohereRuntime(const CohereAssets & assets, const CohereWeights & weights, core::ExecutionContext & execution); ~CohereRuntime(); std::vector> transcribe(const std::vector> & samples, const std::vector & prompt, int64_t max_tokens); private: struct Graphs; const CohereAssets & assets_; const CohereWeights & weights_; core::ExecutionContext & execution_; runtime::CacheSlots, std::unique_ptr> graphs_; }; std::shared_ptr make_cohere_asr_loader(); } // namespace engine::models::cohere_asr