voice_audio_multi/include/engine/framework/runtime/registry.h
Fabio c36510c21e
Some checks failed
Linux Build / Linux cpu (push) Has been cancelled
Linux Build / Linux cpu-clang (push) Has been cancelled
Linux Build / Linux vulkan (push) Has been cancelled
mac-build / macOS CPU (push) Has been cancelled
Nix Build / Nix (cpu) (push) Has been cancelled
Nix Build / Nix (vulkan) (push) Has been cancelled
windows-build / Windows CPU (push) Has been cancelled
Initial import: audio.cpp with Orange Pi documentation
2026-11-04 19:05:22 +01:00

74 lines
3 KiB
C++

#pragma once
#include "engine/framework/runtime/model.h"
#include <filesystem>
#include <memory>
#include <optional>
#include <string>
#include <vector>
namespace engine::runtime {
struct RegistryConfig {
std::vector<std::string> enabled_families;
};
class ModelRegistry {
public:
void register_loader(std::shared_ptr<IVoiceModelLoader> loader);
bool empty() const noexcept;
size_t size() const noexcept;
std::vector<std::string> families() const;
bool supports_family(const std::string & family) const noexcept;
/** Path-free loader catalog for ``--list-loaders --json``. */
std::vector<LoaderAdvertisement> advertise_loaders() const;
ModelInspection inspect(const ModelLoadRequest & request) const;
ModelInspection inspect(const std::filesystem::path & model_path) const;
std::unique_ptr<ILoadedVoiceModel> load(const ModelLoadRequest & request) const;
std::unique_ptr<ILoadedVoiceModel> load(const std::filesystem::path & model_path) const;
PackageLoadTarget resolve_package_load(
const std::string & family, const assets::ModelPackage & package) const;
/**
* What the named family's session options ask for beyond weight files, from the loader that
* owns the family (see IVoiceModelLoader::model_resources). A family with no loader registered
* in this registry -- or one that reports nothing -- yields an empty plan.
*/
ModelResourcePlan model_resources(
const std::string & family,
const std::filesystem::path & model_path,
const std::unordered_map<std::string, std::string> & session_options) const;
private:
void validate_request(const ModelLoadRequest & request) const;
const IVoiceModelLoader * find_loader(const ModelLoadRequest & request) const;
std::vector<std::shared_ptr<IVoiceModelLoader>> loaders_;
};
RegistryConfig load_registry_config(const std::filesystem::path & path);
ModelRegistry make_registry_from_config(
const RegistryConfig & config,
const std::vector<std::shared_ptr<IVoiceModelLoader>> & available_loaders);
ModelRegistry make_default_registry(const std::optional<std::filesystem::path> & config_path = std::nullopt);
/**
* Load a VAD model of any family built into this binary, for internal use such as ASR
* VAD chunking. Only loaders that advertise offline VAD are considered; for a weight
* file, the loader that uses exactly that file wins over a package in the same folder.
* A path no VAD loader claims is loaded as Silero VAD, as before this helper existed.
*/
std::unique_ptr<ILoadedVoiceModel> load_vad_model(const ModelLoadRequest & request);
/**
* Close the load-progress bracket opened by ModelRegistry::load: emit
* ``runtime.load.phase loaded`` and the final upload_progress curve point.
* Hosts call this once the task session is built — that is when the weight
* stores have actually uploaded — not when the registry load returns.
* Safe (no-op) when the load was never traced or was already closed.
*/
void finish_model_load_trace();
} // namespace engine::runtime