Realm

Audio processing basics

Source-owned programs from the current OA SDK. Rust and Python examples follow their respective public APIs.

Rust · Python

Example

This example is currently documented in Python only.

Tu_audio_basics.py

1import os
2
3import oa
4asset_root = os.environ.get("OA_ASSET", "asset")
5asset = os.path.join(asset_root, "audio/oaNarration.flac")
6output_root = os.environ.get("OA_VAR", "var")
7output = os.path.join(output_root, "tutorial/audio/oaNarrationNormalized.wav")
8os.makedirs(os.path.dirname(output), exist_ok=True)
9
10audio = oa.audio.decode_file(asset)
11clean = oa.audio.normalize(audio, -3.0)
12oa.audio.save_wav_f32(output, clean)
13
14print(f"Channels: {clean.channels} Sample-rate: {clean.sample_rate} "
15 f"Duration: {clean.duration_seconds:.2f} s")
16print(f"Saved: {os.path.abspath(output)}")
17

Run Rust tutorials from the OA checkout with cargo run --release --example <name>. Run Python with the environment containing the OA native extension. Consult each program's arguments and capability checks before running it.