#pragma once #include "engine/framework/core/backend.h" #include #include #include namespace engine::audio { struct GTCRNModelState; struct GTCRNWaveformOutput { int sample_rate = 16000; std::vector samples; }; class GTCRNModel { public: static GTCRNModel load_from_safetensors(const std::filesystem::path & checkpoint_path); static GTCRNModel load_from_safetensors( const std::filesystem::path & checkpoint_path, const core::BackendConfig & backend_config); GTCRNModel(); ~GTCRNModel(); GTCRNModel(GTCRNModel &&) noexcept; GTCRNModel & operator=(GTCRNModel &&) noexcept; GTCRNModel(const GTCRNModel &) = delete; GTCRNModel & operator=(const GTCRNModel &) = delete; GTCRNWaveformOutput denoise_mono_16k(const std::vector & waveform) const; std::unique_ptr create_streaming_session() const; private: explicit GTCRNModel(std::shared_ptr state); std::shared_ptr state_; }; class GTCRNStreamingSession { public: explicit GTCRNStreamingSession(std::shared_ptr state); ~GTCRNStreamingSession(); GTCRNStreamingSession(GTCRNStreamingSession &&) noexcept; GTCRNStreamingSession & operator=(GTCRNStreamingSession &&) noexcept; GTCRNStreamingSession(const GTCRNStreamingSession &) = delete; GTCRNStreamingSession & operator=(const GTCRNStreamingSession &) = delete; void reset(); void process_stft_frame(const float * spec_frame_257x2, float * out_spec_frame_257x2); private: struct State; std::shared_ptr model_; std::unique_ptr state_; }; } // namespace engine::audio