Loading...
Searching...
No Matches
ear_inference.c
Go to the documentation of this file.
20 * @details The capture thread never shares its live sample buffer with ORT; stale generations are discarded. */
49/** @brief Keep class/threshold selection module-owned rather than assigning acoustic semantics to the common parser. */
79 if (!inference_settings_read(&settings, settings_path, model_setting, NULL, error, capacity)) return false;
82 !inference_context_open(&network, &settings, "ear_pcm_classifier_v1", error, capacity)) return false;
87 model->inputs[0].type == ONNX_FLOAT32 && model->inputs[0].bytes == (size_t)model->audio_samples * sizeof(float) &&
99/** @brief Accept finite probabilities without confusing them with measured loudness or localization confidence. */
121/** @brief Own the model session off the ALSA thread and publish only still-current capture generations. */
166void ear_inference_push(const int16_t *samples, size_t count, uint64_t end_us, uint64_t error_us)
175 /* Dropping an overloaded window is safer than delaying audio reads and joining samples across an overrun. */
178 const uint64_t tail = (uint64_t)(count - index - 1) * UINT64_C(1000000) / network.model.audio_rate;
static bool ini_uint(const char *text, uint64_t *number)
Parse digits-only uint64; overflow and signs are rejected.
Definition bounded_ini.h:52
static bool ini_real(const char *text, double *number)
Parse finite decimal/exponent notation, rejecting range errors and suffixes.
Definition bounded_ini.h:67
static bool enabled(void)
Report explicit opt-in independently of process or model readiness.
Definition dipla_camera_backend.c:75
static void * classify_windows(void *unused)
Own the model session off the ALSA thread and publish only still-current capture generations.
Definition ear_inference.c:122
void ear_inference_stop(void)
Request termination, join the classifier and release its model; repeat calls are harmless.
Definition ear_inference.c:219
bool ear_inference_start(char *error, size_t capacity)
Start the sole classifier thread after successful ONNX configuration.
Definition ear_inference.c:155
bool ear_inference_take(struct ear_inference_result *result)
Consume at most one completed original-window result without blocking capture.
Definition ear_inference.c:199
int ear_inference_file(const char *filename)
Classify exact whole windows from a regular little-endian signed-16 mono PCM file.
Definition ear_inference.c:233
static bool model_setting(void *unused, const char *key, const char *value)
Keep class/threshold selection module-owned rather than assigning acoustic semantics to the common pa...
Definition ear_inference.c:50
bool ear_inference_configure(const char *settings_path, unsigned rate, bool *enabled, char *error, size_t capacity)
Select the explicit detector and qualify an ONNX PCM contract before capture starts.
Definition ear_inference.c:69
static bool run_window(struct ear_inference_result *result)
Accept finite probabilities without confusing them with measured loudness or localization confidence.
Definition ear_inference.c:100
void ear_inference_push(const int16_t *samples, size_t count, uint64_t end_us, uint64_t error_us)
Supply capture samples without waiting for model execution or a busy model mailbox.
Definition ear_inference.c:166
void ear_inference_discontinuity(void)
Invalidate queued/completed evidence after capture continuity breaks, including in-flight generations...
Definition ear_inference.c:209
Bounded PCM classification without allowing model latency to stall ALSA capture.
bool inference_context_run(struct inference_context *context, char *error, size_t capacity)
Run the currently prepared tensors using the context's timeout policy.
Definition inference_model.c:346
bool inference_context_open(struct inference_context *context, const struct inference_settings *settings, const char *adapter, char *error, size_t capacity)
Verify a bundle, map bounded tensors and bind one warm session.
Definition inference_model.c:277
void inference_context_close(struct inference_context *context)
Release the session before unmapping its borrowed tensor storage.
Definition inference_model.c:373
Integrity-checked model contracts and independently owned tensor workspaces.
bool inference_settings_read(struct inference_settings *settings, const char *filename, ini_field_handler extra, void *context, char *error, size_t capacity)
Parse one flat INI, delegate application keys and resolve paths against the selected file.
Definition inference_settings.c:158
void inference_settings_init(struct inference_settings *settings, enum inference_backend backend)
Reset storage and select conservative thread/timeout defaults.
Definition inference_settings.c:28
void onnx_session_cancel(struct onnx_session *session)
Request cooperative cancellation from another thread; join the owner before destroying storage.
Definition onnx_session.c:325
One classified audio window; probability and measured level are different evidence.
Definition ear_inference.h:28
Independent, noncopyable model owner; mapped tensor buffers and session are reused between jobs.
Definition inference_model.h:43
Parsed descriptor with self-referencing tensor-name pointers; do not copy after parsing.
Definition inference_model.h:31
struct onnx_tensor outputs[ONNX_TENSOR_LIMIT]
Definition inference_model.h:36
Per-application configuration; all resolved paths belong to this caller-owned value.
Definition inference_settings.h:39