mutterkey
KDE-first push-to-talk transcription tool for KDE Plasma
Loading...
Searching...
No Matches
whispercpptranscriber.h
Go to the documentation of this file.
1#pragma once
2
3#include "config.h"
7
8#include <atomic>
9#include <memory>
10
11struct whisper_context;
12struct whisper_state;
13class WhisperCppModelHandle;
14
28{
29public:
36 [[nodiscard]] static std::shared_ptr<const TranscriptionModelHandle>
37 loadModelHandle(const TranscriberConfig &config, RuntimeError *error = nullptr);
38
45 [[nodiscard]] static std::unique_ptr<TranscriptionSession>
46 createSession(TranscriberConfig config, std::shared_ptr<const TranscriptionModelHandle> model);
47
53 WhisperCppTranscriber(TranscriberConfig config, std::shared_ptr<const TranscriptionModelHandle> model);
54
59
61 WhisperCppTranscriber &operator=(const WhisperCppTranscriber &) = delete;
63 WhisperCppTranscriber &operator=(WhisperCppTranscriber &&) = delete;
64
69 [[nodiscard]] static QString backendNameStatic();
70
80 [[nodiscard]] static RuntimeDiagnostics diagnosticsStatic();
81 [[nodiscard]] QString backendName() const override;
82
88 bool warmup(RuntimeError *error = nullptr) override;
89
95 [[nodiscard]] TranscriptUpdate pushAudioChunk(const AudioChunk &chunk) override;
96
101 [[nodiscard]] TranscriptUpdate finish() override;
102
106 [[nodiscard]] TranscriptUpdate cancel() override;
107
108private:
113 static void freeState(whisper_state *state) noexcept;
114
120 bool ensureState(RuntimeError *error = nullptr);
121
123 TranscriberConfig m_config;
125 std::shared_ptr<const WhisperCppModelHandle> m_model;
127 std::unique_ptr<whisper_state, void (*)(whisper_state *)> m_state;
129 std::vector<float> m_bufferedSamples;
131 std::atomic_bool m_cancelRequested = false;
132};
133
139[[nodiscard]] std::shared_ptr<const TranscriptionEngine> createWhisperCppTranscriptionEngine(const TranscriberConfig &config);
Mutable per-session transcription interface.
In-process transcription backend backed by vendored whisper.cpp.
TranscriptUpdate pushAudioChunk(const AudioChunk &chunk) override
Appends one normalized chunk to the current utterance buffer.
static RuntimeDiagnostics diagnosticsStatic()
Returns runtime diagnostics for the embedded whisper runtime.
static BackendCapabilities capabilitiesStatic()
Returns the static capability snapshot for the whisper.cpp runtime.
WhisperCppTranscriber(TranscriberConfig config, std::shared_ptr< const TranscriptionModelHandle > model)
Creates a mutable session from a loaded model handle.
static QString backendNameStatic()
Returns the backend name used in diagnostics.
TranscriptUpdate finish() override
Decodes the buffered utterance and emits final transcript events.
bool warmup(RuntimeError *error=nullptr) override
Eagerly initializes the whisper.cpp context.
QString backendName() const override
Returns the backend identifier for this live session.
TranscriptUpdate cancel() override
Requests cooperative cancellation of active backend work.
static std::shared_ptr< const TranscriptionModelHandle > loadModelHandle(const TranscriberConfig &config, RuntimeError *error=nullptr)
Loads an immutable whisper.cpp model handle.
static std::unique_ptr< TranscriptionSession > createSession(TranscriberConfig config, std::shared_ptr< const TranscriptionModelHandle > model)
Creates a mutable session from a generic app-owned model handle.
~WhisperCppTranscriber() override
Releases the owned whisper.cpp state.
Runtime configuration types, defaults, and JSON loading entrypoints.
Product-owned model package manifest and validated package value types.
One normalized streaming audio unit passed into a transcription session.
Product-owned backend/runtime metadata surfaced to app code.
Runtime inspection data kept separate from static backend capabilities.
Structured runtime-layer failure with user-facing and diagnostic text.
Transcription runtime configuration.
Definition config.h:62
Result of one streaming session operation.
Stable engine/session boundary for embedded transcription backends.
Shared value types exchanged by the transcription pipeline.
std::shared_ptr< const TranscriptionEngine > createWhisperCppTranscriptionEngine(const TranscriberConfig &config)
Creates the embedded whisper.cpp engine implementation.