# helia_edge.models.fastenhancer

FastEnhancer folded-inference model for streaming spectral enhancement.

Adapted from aask1357/fastenhancer (revision e74cab1, models/fastenhancer/
default/model.py), the revision of the onnx-vd-v1.0.0 release. One call processes one STFT frame: ``spec_in`` is
(n_fft // 2 + 1, 1, 2) real/imag, and each RNNFormer block carries a GRU state
(freq, channels). Callers zero the states only at independent sequence starts
and feed each ``state_out_k`` back as ``state_in_k``. The graph matches the
released ONNX inference form, with BatchNorm and weight normalization folded.
STFT/iSTFT framing, weight files and weight terms are the caller's concern.

## helia_edge.models.fastenhancer.linear_filterbanks

`function` · `python`

```python
linear_filterbanks(n_freq: int, n_filter: int) -> tuple[np.ndarray, np.ndarray]
```

Return fixed triangular (pre, post) frequency projections as [in, out] kernels.

Follows upstream revision e74cab1, which produced the onnx-vd-v1.0.0
weights; upstream changed this formula in 8d2d419 (2026-02-25).

Source: `helia_edge/models/fastenhancer.py:22`

## helia_edge.models.fastenhancer.FastEnhancerCompression

`class` · `python`

```python
FastEnhancerCompression(compression: float, **kwargs={})
```

Drop the Nyquist bin and compress magnitude: x * max(|x|, 1e-5)^(c - 1).

Source: `helia_edge/models/fastenhancer.py:40`

### helia_edge.models.fastenhancer.FastEnhancerCompression.compression

`attribute` · `python`

```python
compression = compression
```

Source: `helia_edge/models/fastenhancer.py:46`

### helia_edge.models.fastenhancer.FastEnhancerCompression.call

`method` · `python`

```python
call(spec)
```

Source: `helia_edge/models/fastenhancer.py:48`

### helia_edge.models.fastenhancer.FastEnhancerCompression.get_config

`method` · `python`

```python
get_config()
```

Source: `helia_edge/models/fastenhancer.py:53`

## helia_edge.models.fastenhancer.FastEnhancerMaskOutput

`class` · `python`

```python
FastEnhancerMaskOutput(compression: float, **kwargs={})
```

Apply a complex mask, undo compression and restore a zero Nyquist bin.

Source: `helia_edge/models/fastenhancer.py:57`

### helia_edge.models.fastenhancer.FastEnhancerMaskOutput.compression

`attribute` · `python`

```python
compression = compression
```

Source: `helia_edge/models/fastenhancer.py:63`

### helia_edge.models.fastenhancer.FastEnhancerMaskOutput.call

`method` · `python`

```python
call(inputs)
```

Source: `helia_edge/models/fastenhancer.py:65`

### helia_edge.models.fastenhancer.FastEnhancerMaskOutput.get_config

`method` · `python`

```python
get_config()
```

Source: `helia_edge/models/fastenhancer.py:75`

## helia_edge.models.fastenhancer.FastEnhancerFrequencyProjection

`class` · `python`

```python
FastEnhancerFrequencyProjection(units: int, **kwargs={})
```

Project the frequency axis of (batch, freq, channels) with a [in, out] kernel.

Source: `helia_edge/models/fastenhancer.py:79`

### helia_edge.models.fastenhancer.FastEnhancerFrequencyProjection.units

`attribute` · `python`

```python
units = units
```

Source: `helia_edge/models/fastenhancer.py:85`

### helia_edge.models.fastenhancer.FastEnhancerFrequencyProjection.build

`method` · `python`

```python
build(input_shape)
```

Source: `helia_edge/models/fastenhancer.py:87`

### helia_edge.models.fastenhancer.FastEnhancerFrequencyProjection.call

`method` · `python`

```python
call(x)
```

Source: `helia_edge/models/fastenhancer.py:90`

### helia_edge.models.fastenhancer.FastEnhancerFrequencyProjection.get_config

`method` · `python`

```python
get_config()
```

Source: `helia_edge/models/fastenhancer.py:93`

## helia_edge.models.fastenhancer.FastEnhancerGRUStep

`class` · `python`

```python
FastEnhancerGRUStep(units: int, **kwargs={})
```

One GRU step per frequency band, gates z, r, h and reset after matmul.

Matches ONNX GRU with ``linear_before_reset=1`` and PyTorch ``nn.GRU``:
h' = z * h + (1 - z) * tanh(Wx + bw + r * (Rh + br)). Returns h'.

Source: `helia_edge/models/fastenhancer.py:97`

### helia_edge.models.fastenhancer.FastEnhancerGRUStep.units

`attribute` · `python`

```python
units = units
```

Source: `helia_edge/models/fastenhancer.py:107`

### helia_edge.models.fastenhancer.FastEnhancerGRUStep.build

`method` · `python`

```python
build(input_shape)
```

Source: `helia_edge/models/fastenhancer.py:109`

### helia_edge.models.fastenhancer.FastEnhancerGRUStep.call

`method` · `python`

```python
call(inputs)
```

Source: `helia_edge/models/fastenhancer.py:118`

### helia_edge.models.fastenhancer.FastEnhancerGRUStep.get_config

`method` · `python`

```python
get_config()
```

Source: `helia_edge/models/fastenhancer.py:128`

## helia_edge.models.fastenhancer.FastEnhancerPositionalEmbedding

`class` · `python`

```python
FastEnhancerPositionalEmbedding()
```

Add a learned (freq, channels) embedding.

Source: `helia_edge/models/fastenhancer.py:132`

### helia_edge.models.fastenhancer.FastEnhancerPositionalEmbedding.build

`method` · `python`

```python
build(input_shape)
```

Source: `helia_edge/models/fastenhancer.py:136`

### helia_edge.models.fastenhancer.FastEnhancerPositionalEmbedding.call

`method` · `python`

```python
call(x)
```

Source: `helia_edge/models/fastenhancer.py:139`

## helia_edge.models.fastenhancer.FastEnhancerFrequencyAttention

`class` · `python`

```python
FastEnhancerFrequencyAttention(num_heads: int, use_bias: bool = False, **kwargs={})
```

Multi-head self-attention across frequency bands, no output projection.

The qkv kernel is [channels, 3 * channels] with per-head interleaved
columns: head h uses q = 3dh*h + [0, dh), k = + [dh, 2dh), v = + [2dh, 3dh).

Source: `helia_edge/models/fastenhancer.py:143`

### helia_edge.models.fastenhancer.FastEnhancerFrequencyAttention.num_heads

`attribute` · `python`

```python
num_heads = num_heads
```

Source: `helia_edge/models/fastenhancer.py:153`

### helia_edge.models.fastenhancer.FastEnhancerFrequencyAttention.use_bias

`attribute` · `python`

```python
use_bias = use_bias
```

Source: `helia_edge/models/fastenhancer.py:154`

### helia_edge.models.fastenhancer.FastEnhancerFrequencyAttention.build

`method` · `python`

```python
build(input_shape)
```

Source: `helia_edge/models/fastenhancer.py:156`

### helia_edge.models.fastenhancer.FastEnhancerFrequencyAttention.call

`method` · `python`

```python
call(x)
```

Source: `helia_edge/models/fastenhancer.py:161`

### helia_edge.models.fastenhancer.FastEnhancerFrequencyAttention.get_config

`method` · `python`

```python
get_config()
```

Source: `helia_edge/models/fastenhancer.py:175`

## helia_edge.models.fastenhancer.build

`function` · `python`

```python
build(
    params: FastEnhancerParams,
    input_shape: tuple[int | None, ...] | None = None,
    *,
    batch_size: int | None = None,
    name: str | None = None,
) -> keras.Model
```

Construct an untrained one-frame FastEnhancer with named streaming inputs and outputs.

Inputs: ``spec_in`` (bins, 1, 2) and ``state_in_k`` (freq, channels) per block. Outputs: ``spec_out``
and ``state_out_k``. Fixed linear filterbanks are initialized and frozen; other weights are untrained
until imported with a mapping from ``fastenhancer_params`` (``FASTENHANCER_T_ONNX`` or
``fastenhancer_mapping``).

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| params | FastEnhancerParams | Required | Model parameters. |
| input_shape | tuple[int \| None, ...] \| None | None | None, or ``spec_in``'s fixed shape ``(bins, 1, 2)``. |
| batch_size | int \| None | None | Static batch size; None for a dynamic batch. |
| name | str \| None | None | Model name; the family when None. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | keras.Model | keras.Model: The model, named ``fastenhancer`` unless ``name`` is given. |

Source: `helia_edge/models/fastenhancer.py:187`
