---
title: "ClikaRT::processor::AudioProcessor"
sidebar_label: "AudioProcessor"
description: "A config-driven audio feature processor. Move-only. One parameterized pipeline (selected by the config's feature type) turns audio into features: the raw waveform, a log-mel spectrogram, or a log-mel…"
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--class">class</span>

**Header:** `ClikaRT/processor/processor.h`

A config-driven audio feature processor. Move-only.

One parameterized pipeline (selected by the config's feature type) turns audio into features: the raw waveform, a log-mel spectrogram, or a log-mel filterbank. Every fallible operation returns [`Result`](../Result.md)`<T>`; the library never throws.

## Static member functions

### from\_huggingface() {#from_huggingface}

<div class="api-signature">

`static` [`AudioProcessor`](./AudioProcessor.md) **`from_huggingface`**(`std::string_view` `path`, [`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`)

</div>

Load a HuggingFace audio preprocessor (`preprocessor_config.json`). `path` is the model directory OR the json file itself. `where` binds the default placement. `path` is copied, not retained.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 244

</div>

### from\_directory() {#from_directory}

<div class="api-signature">

`static` [`AudioProcessor`](./AudioProcessor.md) **`from_directory`**(`std::string_view` `path`, [`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`)

</div>

Load from a model directory, detecting the preprocessor format present (currently HuggingFace). `path` is copied, not retained.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 249

</div>

### from\_config() {#from_config}

<div class="api-signature">

`static` [`AudioProcessor`](./AudioProcessor.md) **`from_config`**(`const` [`AudioProcessorConfig`](./AudioProcessorConfig.md)`&` `config`, [`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`)

</div>

Build from an explicit config; no config file needed. `config` is read during the call.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 254

</div>

### from\_args() {#from_args}

<div class="api-signature">

`static` [`AudioProcessor`](./AudioProcessor.md) **`from_args`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<std::int64_t>` `sampling_rate` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<std::int64_t>` `feature_size` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<std::int64_t>` `n_fft` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<std::int64_t>` `hop_length` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`<br />
)

</div>

Build directly from the COMMON log-mel knobs: no config file, no config object. Pass `{}` for any knob to take its default (16 kHz / 80 mel bins / n\_fft 400 / hop 160). For the full STFT/mel/normalization surface, build an [`AudioProcessorConfig`](./AudioProcessorConfig.md) and use [`from_config`](./AudioProcessor.md#from_config).

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 261

</div>

## Member functions

### AudioProcessor() {#AudioProcessor}

<div class="api-signature">

**`AudioProcessor`**(`AudioProcessor&&`) `noexcept`

</div>

move-construct (the source becomes an empty shell)

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 276

</div>

### operator=() {#operator-assign}

<div class="api-signature">

[`AudioProcessor`](./AudioProcessor.md)`&` **`operator=`**([`AudioProcessor`](./AudioProcessor.md)`&&`) `noexcept`

</div>

move-assign

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 277

</div>

### \~AudioProcessor() {#AudioProcessor-2}

<div class="api-signature">

**`~AudioProcessor`**()

</div>

destructor

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 278

</div>

### process(string\_view, StreamOrDevice) {#process}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`process`**(`std::string_view` `path`, [`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`) `const`

</div>

Decode an audio file, resample to the configured rate + downmix to mono, then compute features → a Float32 [`Tensor`](../Tensor.md) (shape per the configured feature type). `where` overrides the bound placement.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 284

</div>

### process(Span\< uint8\_t\>, StreamOrDevice) {#process-2}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`process`**([`ClikaRT::Span`](../Span.md)`<const std::uint8_t>` `bytes`, [`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`) `const`

</div>

Decode an audio file, resample to the configured rate + downmix to mono, then compute features → a Float32 [`Tensor`](../Tensor.md) (shape per the configured feature type). `where` overrides the bound placement.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 287

</div>

### process(Span\< float\>, int, StreamOrDevice) {#process-3}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`process`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const float>` `waveform`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int` `sample_rate`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`<br />
) `const`

</div>

Decode an audio file, resample to the configured rate + downmix to mono, then compute features → a Float32 [`Tensor`](../Tensor.md) (shape per the configured feature type). `where` overrides the bound placement.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 291

</div>

### process(Tensor, int, StreamOrDevice) {#process-4}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`process`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;`const` [`Tensor`](../Tensor.md)`&` `waveform`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int` `sample_rate`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`<br />
) `const`

</div>

Decode an audio file, resample to the configured rate + downmix to mono, then compute features → a Float32 [`Tensor`](../Tensor.md) (shape per the configured feature type). `where` overrides the bound placement.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 297

</div>

### process(string\_view, AudioProcessOptions, StreamOrDevice) {#process-5}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`process`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::string_view` `path`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`const` [`AudioProcessOptions`](./AudioProcessOptions.md)`&` `options`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`<br />
) `const`

</div>

Decode an audio file, resample to the configured rate + downmix to mono, then compute features → a Float32 [`Tensor`](../Tensor.md) (shape per the configured feature type). `where` overrides the bound placement.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 305

</div>

### process(Span\< uint8\_t\>, AudioProcessOptions, StreamOrDevice) {#process-6}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`process`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::uint8_t>` `bytes`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`const` [`AudioProcessOptions`](./AudioProcessOptions.md)`&` `options`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`<br />
) `const`

</div>

Decode an audio file, resample to the configured rate + downmix to mono, then compute features → a Float32 [`Tensor`](../Tensor.md) (shape per the configured feature type). `where` overrides the bound placement.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 308

</div>

### process(Span\< float\>, int, AudioProcessOptions, StreamOrDevice) {#process-7}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`process`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const float>` `waveform`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int` `sample_rate`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`const` [`AudioProcessOptions`](./AudioProcessOptions.md)`&` `options`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`<br />
) `const`

</div>

Decode an audio file, resample to the configured rate + downmix to mono, then compute features → a Float32 [`Tensor`](../Tensor.md) (shape per the configured feature type). `where` overrides the bound placement.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 312

</div>

### process(Tensor, int, AudioProcessOptions, StreamOrDevice) {#process-8}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`process`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;`const` [`Tensor`](../Tensor.md)`&` `waveform`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int` `sample_rate`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`const` [`AudioProcessOptions`](./AudioProcessOptions.md)`&` `options`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `where` `=` `{}`<br />
) `const`

</div>

Decode an audio file, resample to the configured rate + downmix to mono, then compute features → a Float32 [`Tensor`](../Tensor.md) (shape per the configured feature type). `where` overrides the bound placement.

<div class="api-declared">

Declared in `ClikaRT/processor/processor.h`, line 317

</div>
