Algorithm Search⌘K

Algorithmadvanced

RASTA filtering

Also called relative spectral filtering, RASTA.

Band-pass filter the time series of each log spectral band to remove slow channel effects and fast frame-to-frame noise.

Time
O(T B) worst
Space
O(B) extra
Where
B = the number of bands; T = the number of frames
Properties
deterministicexactnot in placeonline
Origin
Hynek Hermansky, Nelson Morgan, 1994

RASTA filtering runs a fixed band-pass filter along time over the log energy of each spectral band, one value per frame, so that changes slower than about 0.3 Hz and faster than about 13 Hz are removed. Cepstral mean normalization removes only the mean of each trajectory over an utterance or a window; RASTA also removes slow drifts and fast jitter, and it works frame by frame with no look at the whole utterance. Delta features are also a filter along time, but they are added as new features, while RASTA replaces the trajectories it filters. It was made for perceptual linear prediction, where the filter runs on the log critical band spectrum before the all-pole fit, and it works the same way on the log energies of a mel filter bank.

In plain words

A microphone or a telephone line acts like a fixed tone control: it makes some frequencies louder and some softer, and it does not change while a person talks. After the log, such a fixed change adds the same number to a band in every frame. Speech, on the other hand, changes the energy of a band a few times per second, as the syllables come and go. RASTA follows each band over time and keeps only the changes that happen at about the speed of speech. A level that stays the same, or that drifts very slowly, is removed, and so is very fast flicker from one frame to the next. The result is a set of band energies that depends less on the microphone and the line.

The problem

Given the log band energies X[t][j]X[t][j] of TT frames and BB bands, for example from a mel filter bank or the critical band analysis of PLP at 100 frames per second, compute filtered trajectories Y[t][j]Y[t][j] such that a constant added to a band trajectory does not change the output, and the output keeps the modulation frequencies of speech while it removes very slow and very fast changes.

The algorithm

Hermansky and Morgan use, for each band, the filter

H(z)=0.1 z4 2+z−1−z−3−2z−41−ρz−1,ρ=0.98.H(z) = 0.1\, z^{4}\, \frac{2 + z^{-1} - z^{-3} - 2 z^{-4}}{1 - \rho z^{-1}}, \qquad \rho = 0.98.

The factor z4z^4 only moves the output 4 frames earlier, so this page uses the causal filter without it, and its output is the same signal 4 frames later. The numerator is a smoothed slope over 5 frames, and the pole at ρ\rho is a leaky integrator. Before the first frame, the input is taken equal to the first value of the trajectory and the output to 0.

  1. RASTA(X, ρ) ▷ X[t][j] for t = 0 .. T-1 and j = 1 .. B, with 0 ≤ ρ < 1
  2. 1for j ← 1 to B do
  3. 2x ← (X[0][j], …, X[T-1][j]); x[-4], …, x[-1] ← x[0]; y[-1] ← 0
  4. 3for t ← 0 to T - 1 do u ← 0.1 (2 (x[t] - x[t-4]) + (x[t-1] - x[t-3]))
  5. 4y[t] ← u + ρ y[t-1]; Y[t][j] ← y[t]
  6. 5return Y

Line L3 is the numerator 0.1(2+z−1−z−3−2z−4)0.1(2 + z^{-1} - z^{-3} - 2z^{-4}), with the taps written in pairs so that the four differences are exactly 0 on a constant. Line L4 is the denominator. Only the 4 last inputs and the last output of each band must be kept, so the filter runs as the frames arrive.

Example

The impulse response h[n]h[n] and the step response g[n]=∑s≤nh[s]g[n] = \sum_{s \le n} h[s] with ρ=0.98\rho = 0.98 are:

nn 0 1 2 3 4 5 6 7
h[n]h[n] 0.2 0.296 0.2901 0.1843 −0.0194-0.0194 −0.0190-0.0190 −0.0186-0.0186 −0.0183-0.0183
g[n]g[n] 0.2 0.496 0.7861 0.9704 0.951 0.932 0.9133 0.8951

Take one band whose log energy is 3 in every frame except frame 3, where a short burst makes it 4. Lines L3 and L4 give the output 0, 0, 0, 0.2, 0.296, 0.2901, 0.1843, −0.0194-0.0194, and so on: the constant 3 is gone and the burst comes out as the impulse response. If the channel adds 10 to this band, so the input is 13 with a burst of 14, the output is the same. If the level jumps from 3 to 4 at frame 3 and stays there, the output is the step response: it rises to 0.97 within 4 frames and then decays by the factor 0.98 per frame, to half its peak after about 34 frames, or 0.34 s at 100 frames per second.

The magnitude of HH at 100 frames per second, with ρ=0.98\rho = 0.98:

modulation frequency (Hz) 0.1 0.5 1 2 5 10 20 30
∣H∣\lvert H \rvert 0.300 0.849 0.960 0.989 0.957 0.814 0.365 0.028
dB −10.5-10.5 −1.4-1.4 −0.4-0.4 −0.1-0.1 −0.4-0.4 −1.8-1.8 −8.7-8.7 −31.1-31.1

The peak is 0.9895 at 2.22 Hz, and the gain stays within 3 dB of the peak from 0.31 Hz to 12.8 Hz. The numerator factors as (1−z−2)(2+z−1+2z−2)(1 - z^{-2})(2 + z^{-1} + 2 z^{-2}), so HH is exactly 0 at 0 Hz, at 50 Hz, and at the frequency 1002πarccos⁡(−14)=29.0\frac{100}{2\pi} \arccos(-\frac14) = 29.0 Hz, where the zeros of 2+z−1+2z−22 + z^{-1} + 2z^{-2} lie on the unit circle.

Correctness

The filter computes a defined transform, so correctness means that lines L1 to L5 compute it and that it has the properties the problem asks for. The full proofs are below.

  • The recursion is the filter. Let x~[t]=x[t]−x[0]\tilde x[t] = x[t] - x[0] for t≥0t \ge 0 and x~[t]=0\tilde x[t] = 0 for t<0t < 0. Because the numerator taps sum to 0, line L3 gives the same uu for xx and for x~\tilde x, so y[t]=∑s=0th[s] x~[t−s]y[t] = \sum_{s=0}^{t} h[s]\, \tilde x[t - s], where hh is the impulse response of HH without z4z^4 (theorem).
  • Offsets are removed exactly. A constant trajectory gives y=0y = 0 from the first frame on, and adding a constant to a trajectory does not change any output (theorem).
  • A fixed channel is removed approximately. A fixed linear filter multiplies the spectrum by a fixed ∣C(f)∣2|C(f)|^2. It adds a constant to a log band only when ∣C(f)∣|C(f)| is nearly flat inside the band and the frames are much longer than the impulse response of the channel, so in practice RASTA removes most, not all, of a channel (heuristic).
  • Stable. The only pole is at ρ\rho with 0≤ρ<10 \le \rho < 1, so ∑n∣h[n]∣\sum_n |h[n]| is finite and a bounded input gives a bounded output (theorem).
  • Same on cepstra. The filter is linear and the same for every band, and the DCT of MFCC is a fixed linear map, so filtering the log bands and then taking the DCT gives the same result as filtering each cepstral coefficient (theorem).
Proof: The RASTA recursion is a stable band-pass filter that removes offsets exactlyfull

We work in the real RAM on one band, since lines L1 and L2 only select the bands one at a time and each band is filtered on its own. Fix 0≤ρ<10 \le \rho < 1 and a trajectory x[0],…,x[T−1]x[0], \ldots, x[T-1]. Line L2 sets x[−4]=⋯=x[−1]=x[0]x[-4] = \cdots = x[-1] = x[0] and y[−1]=0y[-1] = 0. Write b=(b0,…,b4)=0.1 (2,1,0,−1,−2)b = (b_0, \ldots, b_4) = 0.1\,(2, 1, 0, -1, -2), so line L3 computes u[t]=∑k=04bkx[t−k]u[t] = \sum_{k=0}^{4} b_k x[t - k]: the pairs 2(x[t]−x[t−4])2(x[t] - x[t-4]) and (x[t−1]−x[t−3])(x[t-1] - x[t-3]) are just a grouping of the same sum. Line L4 computes y[t]=u[t]+ρ y[t−1]y[t] = u[t] + \rho\, y[t-1].

Let hh be the impulse response of Hc(z)=(∑kbkz−k)/(1−ρz−1)H_c(z) = (\sum_k b_k z^{-k}) / (1 - \rho z^{-1}), the filter of the paper without the factor z4z^4: h[n]=∑k=0min⁡(n,4)bkρ n−kh[n] = \sum_{k=0}^{\min(n, 4)} b_k \rho^{\,n-k} for n≥0n \ge 0.

Lemma 1 (the taps sum to zero). ∑k=04bk=0\sum_{k=0}^{4} b_k = 0, so u[t]u[t] does not change when the same constant is added to x[t−4],…,x[t]x[t-4], \ldots, x[t].

Proof. 0.1(2+1+0−1−2)=00.1(2 + 1 + 0 - 1 - 2) = 0, and ∑kbk(x[t−k]+a)=u[t]+a∑kbk\sum_k b_k (x[t-k] + a) = u[t] + a \sum_k b_k. □\square

Lemma 2 (the recursion is the filter). Let x~[t]=x[t]−x[0]\tilde x[t] = x[t] - x[0] for t≥0t \ge 0 and x~[t]=0\tilde x[t] = 0 for t<0t < 0. Then for every t≥0t \ge 0,

y[t]=∑s=0th[s] x~[t−s].y[t] = \sum_{s=0}^{t} h[s]\, \tilde x[t - s].

Proof. For t≥0t \ge 0 the five inputs of u[t]u[t] are x[t−k]x[t-k], which equal x~[t−k]+x[0]\tilde x[t-k] + x[0] for every kk, also for t−k<0t - k < 0 where both sides are x[0]x[0]. By Lemma 1, u[t]=∑kbkx~[t−k]u[t] = \sum_k b_k \tilde x[t-k]. Unrolling line L4 with y[−1]=0y[-1] = 0 gives y[t]=∑i=0tρ iu[t−i]y[t] = \sum_{i=0}^{t} \rho^{\,i} u[t - i]. Substitute uu and collect the terms with s=i+ks = i + k; since x~\tilde x is 0 at negative times, y[t]=∑s=0tx~[t−s]∑k=0min⁡(s,4)bkρ s−k=∑sh[s]x~[t−s]y[t] = \sum_{s=0}^{t} \tilde x[t-s] \sum_{k=0}^{\min(s,4)} b_k \rho^{\,s-k} = \sum_{s} h[s] \tilde x[t - s]. □\square

So the output is the zero-state response of HcH_c to x~\tilde x, and the output of the paper's filter H=z4HcH = z^4 H_c is the same sequence shifted 4 frames earlier.

Lemma 3 (offsets are removed exactly). If x[t]=ax[t] = a for all tt, then y[t]=0y[t] = 0 for all t≥0t \ge 0. If x′[t]=x[t]+ax'[t] = x[t] + a for all tt, then y′[t]=y[t]y'[t] = y[t] for all t≥0t \ge 0.

Proof. In the first case x~=0\tilde x = 0, and Lemma 2 gives y=0y = 0. In the second case x′[0]=x[0]+ax'[0] = x[0] + a, so x~′=x~\tilde x' = \tilde x, and Lemma 2 gives the same output. □\square

Lemma 4 (the impulse and step responses). h[0]=0.2h[0] = 0.2, h[1]=0.1+0.2ρh[1] = 0.1 + 0.2\rho, h[2]=ρ h[1]h[2] = \rho\, h[1], h[3]=−0.1+ρ h[2]h[3] = -0.1 + \rho\, h[2], h[4]=−0.2+ρ h[3]h[4] = -0.2 + \rho\, h[3], and h[n]=ρ n−4h[4]h[n] = \rho^{\,n-4} h[4] for n≥4n \ge 4. The step response g[n]=∑s=0nh[s]g[n] = \sum_{s=0}^{n} h[s] satisfies g[n]=ρ n−3g[3]g[n] = \rho^{\,n-3} g[3] for n≥3n \ge 3.

Proof. The impulse response satisfies line L4 with u[n]=bnu[n] = b_n for n≤4n \le 4 and u[n]=0u[n] = 0 after, which gives the values. For the step, u[n]=∑k=0min⁡(n,4)bku[n] = \sum_{k=0}^{\min(n,4)} b_k, which is 0 for n≥4n \ge 4 by Lemma 1, so g[n]=ρ g[n−1]g[n] = \rho\, g[n-1] for n≥4n \ge 4. □\square

With ρ=0.98\rho = 0.98 this gives h=0.2,0.296,0.29008,0.18428,−0.01941,…h = 0.2, 0.296, 0.29008, 0.18428, -0.01941, \ldots and g[3]=0.97036g[3] = 0.97036, the values in the example.

Lemma 5 (stability). ∑n≥0∣h[n]∣<∞\sum_{n \ge 0} |h[n]| < \infty, so a bounded input gives a bounded output: if ∣x~[t]∣≤K|\tilde x[t]| \le K for all tt, then ∣y[t]∣≤K∑n∣h[n]∣|y[t]| \le K \sum_n |h[n]|.

Proof. By Lemma 4, ∑n≥4∣h[n]∣=∣h[4]∣/(1−ρ)\sum_{n \ge 4} |h[n]| = |h[4]| / (1 - \rho), which is finite since ρ<1\rho < 1. The bound follows from Lemma 2 and the triangle inequality. □\square

Lemma 6 (the frequency response). For a frame rate rr and a modulation frequency ff, let z=ej2πf/rz = e^{j 2\pi f / r}. Then ∣H(z)∣=∣Hc(z)∣|H(z)| = |H_c(z)|, and HcH_c is 0 exactly at f=0f = 0, at f=r/2f = r/2, and at f=r2πarccos⁡(−14)f = \frac{r}{2\pi} \arccos(-\frac14) in [0,r/2][0, r/2].

Proof. ∣z4∣=1|z^4| = 1 on the unit circle. The numerator is 0.1 (2(1−z−4)+z−1(1−z−2))=0.1 (1−z−2)(2+z−1+2z−2)0.1\,(2(1 - z^{-4}) + z^{-1}(1 - z^{-2})) = 0.1\,(1 - z^{-2})(2 + z^{-1} + 2 z^{-2}), using 1−z−4=(1−z−2)(1+z−2)1 - z^{-4} = (1 - z^{-2})(1 + z^{-2}). The first factor is 0 at z=±1z = \pm 1. The second is z−1(2z+2z−1+1)=z−1(4cos⁡ω+1)z^{-1}(2 z + 2 z^{-1} + 1) = z^{-1}(4 \cos\omega + 1) on the unit circle, which is 0 exactly when cos⁡ω=−14\cos \omega = -\frac14. The denominator 1−ρz−11 - \rho z^{-1} is never 0 on the unit circle because ρ<1\rho < 1. □\square

Lemma 7 (same on cepstra). Let DD be any fixed K×BK \times B matrix, such as the DCT of MFCC. Filtering every band of XX and then applying DD to each frame gives the same result as applying DD to each frame and then filtering every coefficient.

Proof. By Lemma 2 each output is Y[t][j]=∑sh[s](X[t−s][j]−X[0][j])Y[t][j] = \sum_{s} h[s] (X[t-s][j] - X[0][j]), a linear map of the trajectory with the same weights for every jj. So ∑jDijY[t][j]=∑sh[s](∑jDijX[t−s][j]−∑jDijX[0][j])\sum_j D_{i j} Y[t][j] = \sum_s h[s] \bigl(\sum_j D_{ij} X[t-s][j] - \sum_j D_{ij} X[0][j]\bigr), which is the filter applied to the trajectory of coefficient ii. □\square

Theorem. For 0≤ρ<10 \le \rho < 1, RASTA returns for each band the output of the stable filter HcH_c, the paper's filter delayed by 4 frames, applied to the trajectory minus its first value. A constant offset on a band changes no output, and the filter has zeros at 0 Hz and at half the frame rate.

Proof. Lemmas 2, 3, 5 and 6. □\square

The tests check Lemma 4 against the first values of the impulse and step responses, Lemma 3 on a constant and on an offset trajectory, Lemma 6 by comparing the gain on long sines with ∣Hc∣|H_c|, and a fixed channel added to every frame of a log band spectrogram.

Complexity

In the real RAM, line L3 costs 4 additions and 2 multiplications and line L4 one multiplication and one addition, so the work is O(TB)O(T B), about 8 operations per band and frame. The state is 4 past inputs and 1 past output per band, O(B)O(B) numbers, beyond the output. The implementation here copies each band into a list, which uses O(T)O(T) more memory but does not change the time.

Properties

  • Causal and online. The causal form needs no future frames; its output is the noncausal filter of the paper delayed by 4 frames.
  • Linear and time invariant along time. The filter commutes with any fixed linear map across the bands, such as the DCT.
  • Not a linear phase filter. The pole makes the group delay change with the modulation frequency, so peaks of the trajectories move by different amounts. Recognizers trained on RASTA features learn this shape.
  • Long memory. With ρ=0.98\rho = 0.98 the time constant is about 50 frames, or 0.5 s. The filter needs about this long to forget an old level.

Variants and improvements

  • Pole 0.94. Ellis's widely used rastamat code uses ρ=0.94\rho = 0.94, which shortens the memory to about 16 frames and moves the 3 dB band to 0.88 Hz to 13.5 Hz.
  • J-RASTA. Hermansky and Morgan also describe filtering ln⁡(1+JS)\ln(1 + J S) in place of ln⁡S\ln S, where JJ depends on the noise level. For small JSJ S this is nearly linear in SS, so additive noise becomes closer to an offset that the filter can reduce.
  • RASTA on cepstra. Many systems filter the cepstral coefficients in place of the log bands. By the linearity argument above the result is the same up to the truncation of the DCT.
  • Learned temporal filters. Later work designed the filter along time from data, for example with linear discriminant analysis on long spans of log band energies.

When to use it

Use RASTA when the channel changes between training and test, for example different microphones or telephone lines, and the system must process speech as it arrives, so that the mean over a whole utterance is not available. For offline recognition with utterances of a few seconds, cepstral mean normalization over the utterance is simpler and removes a constant offset just as well. Do not expect RASTA to remove additive noise: noise adds to the power, not to the log, and spectral subtraction or a Wiener filter addresses it.

Pitfalls

  • Filter the log, not the energy. The channel becomes an offset only after the log. RASTA on the power spectrum does not remove it.
  • Frame rate. The coefficients are designed for 100 frames per second. At another frame rate every frequency of the response scales with the rate, so the pass band moves.
  • Start up. The first frames depend on the initial state. This page repeats the first input and sets the past output to 0, so a constant start gives 0; other toolkits start differently, and their first frames do not match.
  • Delay. The causal output is 4 frames late compared with the filter of the paper. When RASTA features are combined with unfiltered features, align them first.
  • Short utterances. With ρ=0.98\rho = 0.98 a change of channel is forgotten only after about half a second, so utterances shorter than that keep part of the channel.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

rasta_filtering.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/rasta-filtering/. The authors are listed in prov/C4662N.jsonl.

"""RASTA filtering of the log band energies of speech, after Hermansky and Morgan (1994).

Each band trajectory (the log energy of one band, one value per frame) goes
through the band-pass filter

    H(z) = 0.1 (2 + z^-1 - z^-3 - 2 z^-4) / (1 - rho z^-1),

which is the filter of the paper without its factor z^4. That factor only moves
the output 4 frames earlier, so this causal form gives the same output 4 frames
later. The paper uses rho = 0.98. Ellis's rastamat code uses rho = 0.94.

Before the first frame the input is taken equal to x[0] and the output to 0, so a
constant trajectory gives 0 from the first frame on. The numerator taps sum to 0,
so adding a constant to a trajectory does not change the output.
"""

from typing import List, Sequence


def rasta_filter(x: Sequence[float], rho: float = 0.98) -> List[float]:
    """Filter one trajectory: y[t] = sum_k b_k x[t - k] + rho y[t - 1], with b = 0.1 (2, 1, 0, -1, -2)."""
    if not 0.0 <= rho < 1.0:
        raise ValueError("rho must be in [0, 1) for a stable filter")
    if not x:
        return []
    y: List[float] = []
    prev = 0.0

    def past(t: int) -> float:
        return x[t] if t >= 0 else x[0]

    for t in range(len(x)):
        # the taps in pairs, so that a constant gives exactly 0
        u = 0.1 * (2.0 * (x[t] - past(t - 4)) + (past(t - 1) - past(t - 3)))  # @line L3
        prev = u + rho * prev  # @line L4
        y.append(prev)
    return y  # @line L5


def rasta_bands(log_bands: Sequence[Sequence[float]], rho: float = 0.98) -> List[List[float]]:
    """Filter every band of a log band spectrogram given as rows of frames (T rows of B values).

    Returns T rows of B values. Each column (one band over time) is filtered on its own."""
    if not log_bands:
        return []
    width = len(log_bands[0])
    if any(len(row) != width for row in log_bands):
        raise ValueError("all frames must have the same number of bands")
    columns = []
    for j in range(width):  # @line L1
        traj = [row[j] for row in log_bands]  # @line L2
        columns.append(rasta_filter(traj, rho))
    return [[columns[j][t] for j in range(width)] for t in range(len(log_bands))]
test_rasta_filtering.py 98 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/rasta-filtering/. The authors are listed in prov/C4662N.jsonl.

import cmath
import math
import random

from rasta_filtering import rasta_bands, rasta_filter


def _h(f, rho, frame_rate=100.0):
    z = cmath.exp(2j * math.pi * f / frame_rate)
    return 0.1 * (2 + z**-1 - z**-3 - 2 * z**-4) / (1 - rho * z**-1)


def test_impulse_response():
    rho = 0.98
    x = [0.0] * 5 + [1.0] + [0.0] * 30
    y = rasta_filter(x, rho)
    assert y[:5] == [0.0] * 5
    b = [0.2, 0.1, 0.0, -0.1, -0.2]
    # h[n] = sum_{k <= min(n, 4)} b_k rho^(n - k)
    for n in range(30):
        ref = sum(b[k] * rho ** (n - k) for k in range(min(n, 4) + 1))
        assert abs(y[5 + n] - ref) < 1e-12


def test_constant_gives_zero():
    assert all(v == 0.0 for v in rasta_filter([3.5] * 50))


def test_offset_does_not_change_the_output():
    rng = random.Random(2)
    x = [rng.uniform(-5, 5) for _ in range(300)]
    for rho in (0.98, 0.94):
        a = rasta_filter(x, rho)
        b = rasta_filter([v + 17.0 for v in x], rho)
        assert all(abs(u - v) < 1e-9 for u, v in zip(a, b))


def test_step_decays_geometrically():
    rho = 0.98
    x = [0.0] * 10 + [1.0] * 200
    y = rasta_filter(x, rho)
    # after the 5 numerator taps have all seen the step, only the pole acts
    for t in range(14, 210):
        assert abs(y[t] - rho * y[t - 1]) < 1e-12
    # the first outputs are the partial sums of the taps: 0.2, then 0.2 rho + 0.1, ...
    assert abs(y[10] - 0.2) < 1e-12 and abs(y[11] - (0.2 * rho + 0.3)) < 1e-12
    assert y[209] < 0.03 * max(y)


def test_sine_gain_matches_the_transfer_function():
    rho = 0.98
    for f in (0.5, 4.0, 12.0, 25.0):
        n = 4000
        x = [math.sin(2 * math.pi * f * t / 100.0) for t in range(n)]
        y = rasta_filter(x, rho)
        tail = range(2000, n)
        c = sum(y[t] * math.cos(2 * math.pi * f * t / 100.0) for t in tail) * 2 / len(tail)
        s = sum(y[t] * math.sin(2 * math.pi * f * t / 100.0) for t in tail) * 2 / len(tail)
        assert abs(math.hypot(c, s) - abs(_h(f, rho))) < 2e-3


def test_pass_band_numbers():
    # the -3 dB points of the paper's filter at 100 frames per second
    assert abs(_h(0.0 + 1e-9, 0.98)) < 1e-6
    peak = max(abs(_h(i / 100.0, 0.98)) for i in range(1, 5000))
    assert abs(_h(0.30, 0.98)) < peak / math.sqrt(2) < abs(_h(0.32, 0.98))
    assert abs(_h(12.9, 0.98)) < peak / math.sqrt(2) < abs(_h(12.8, 0.98))


def test_bands_remove_a_fixed_channel():
    rng = random.Random(4)
    spec = [[rng.uniform(-3, 3) for _ in range(6)] for _ in range(80)]
    channel = [0.5, -1.0, 2.0, 0.0, 3.0, -0.25]  # a fixed log gain per band
    a = rasta_bands(spec)
    b = rasta_bands([[v + g for v, g in zip(row, channel)] for row in spec])
    assert len(a) == 80 and all(len(r) == 6 for r in a)
    assert all(abs(u - v) < 1e-9 for ra, rb in zip(a, b) for u, v in zip(ra, rb))
    col = rasta_filter([row[2] for row in spec])
    assert all(abs(a[t][2] - col[t]) < 1e-15 for t in range(80))


def test_bad_arguments():
    assert rasta_filter([]) == [] and rasta_bands([]) == []
    for bad in (1.0, -0.1):
        try:
            rasta_filter([1.0], bad)
        except ValueError:
            continue
        raise AssertionError(bad)
    try:
        rasta_bands([[1.0, 2.0], [1.0]])
    except ValueError:
        pass
    else:
        raise AssertionError("ragged input must fail")

History

Hermansky and colleagues introduced RASTA in the early 1990s as an addition to perceptual linear prediction, and Hermansky and Morgan gave the full account in 1994. The idea came from hearing: listeners pay little attention to a sound whose spectrum does not change, and the spectrum of speech changes at the rate of syllables. A filter along time on the log spectrum copies this, and since a fixed channel is an offset in the log domain, the same filter removes the channel. RASTA-PLP was widely used for telephone speech in the 1990s, and the idea of filtering band trajectories along time led to later work on modulation spectrum features.

References

  1. Hynek Hermansky and Nelson Morgan, RASTA processing of speech, IEEE Transactions on Speech and Audio Processing 2(4), 1994, 578 to 589, the RASTA band-pass filter of the log critical band trajectories, its transfer function with the pole at 0.98, and the J-RASTA variant for additive noise
  2. Xuedong Huang, Alex Acero and Hsiao-Wuen Hon, Spoken Language Processing, Prentice Hall, 2001, Chapter 10 (Environmental Robustness), the discussion of cepstral mean normalization and RASTA
  3. Daniel P. W. Ellis, PLP and RASTA (and MFCC, and inversion) in Matlab, the function rastafilt.m, which uses a pole of 0.94

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example