All examples
Media

Speech activity on sample clocks

Inspect bounded RMS hysteresis windows, explicit activity intervals and flush semantics.

speech_activity.aner
// A tone fixture demonstrates energy activity; it is not a speech classifier.
import aner.audio
import aner.speech

let quiet = audio.tone(seconds: 0.2, rate: 16000, amplitude: 0.0)
let tone = audio.tone(seconds: 0.4, rate: 16000, amplitude: 0.2)
let fixture = audio.concat(audio.concat(quiet, tone), quiet)
let detector = speech.vad(rate: 16000, onset: 0.05, offset: 0.02,
    min_speech_ms: 60, silence_ms: 100, pre_roll_ms: 40)
let intervals = speech.activity()
detector.process_into(fixture, intervals)
print(intervals.count())
for index in Range(intervals.count()) {
    print(intervals.start(index))
    print(intervals.end(index))
    print(intervals.forced(index))
}

// Stream directly from reusable blocks; no freeze or per-block Tensor export.
detector.reset()
let source = audio.synthetic(frames: 16000, rate: 16000,
    amplitude: 0.2, block_frames: 137)
let block = audio.block_slot()
while source.read_into(block) == "ready" {
    detector.process_into(block, intervals)
    for index in Range(intervals.count()) { print(intervals.end(index)) }
}
source.close()
detector.flush_into(intervals)
print(intervals.count())
print(intervals.forced(0))

Make it your experiment.

Use Aner 0.1.0 or newer. Save this program as examples/media/speech_activity.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/media/speech_activity.aner
aner run examples/media/speech_activity.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Requires Aner 0.1.0 or newer. Native PCM/WAV, synthesis, FFT and speech activity are available independently of optional FFmpeg and model backends. Decoding, resampling or local transcription requires the corresponding capability and separately supplied inputs or weights.

Credential setup
aner check examples/media/speech_activity.aner
aner run examples/media/speech_activity.aner

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner