Skip to content

Profazia/clarifae

Repository files navigation

Clarifae

Real-time AI audio clarity for rooted Android

A Magisk / KernelSU / APatch module that cleans both your microphone and the audio you hear in real time using open-source speech-enhancement models — configurable from a WebUI.


Clarifae installs one native effect library (libclarifae.so) that exposes two descriptors, registered via audio_effects.xml:

  • a capture pre-processor on input streams (microphone, calls/VoIP, camcorder, voice recognition) — cleans your outgoing voice; and
  • a playback post-processor on output streams (media/music, calls, …) — cleans the audio you hear.

Each side can be toggled independently and is denoised on the fly by one of three engines, selectable as clarity modes.

Note on output + music: these are speech-enhancement models. On voice content (calls, videos, podcasts) output cleanup clarifies nicely; on actual music it treats instruments as noise and degrades them — use the separate Playback strength slider (or turn output off) to taste.

Brand: primary #435787, secondary #68aaf3, font Creative Caps.

Contents

Clarity modes

Mode Engine Profile Status
1 · Low latency RNNoise Compact RNN denoiser, lowest CPU/latency, 48 kHz framed Default, works out of the box
2 · Balanced DTLN Dual-signal LSTM via TensorFlow Lite, stronger denoising ⚠️ Experimental — needs TFLite + models
3 · Maximum clarity DeepFilterNet Full-band 48 kHz deep filtering, highest quality ⚠️ Experimental — needs libdf + model

Modes 2 and 3 are optional builds. If their runtime/models aren't present, Clarifae transparently falls back to RNNoise — it never silently breaks your audio.

Features

  • Both directions: mic input and playback output cleanup, each toggleable, from one native AudioFlinger effect (pre-processing + post-processing descriptors).
  • Three AI clarity modes with graceful fallback.
  • Branded WebUI: master + per-side toggles, mode picker, separate mic/playback strength, max-suppression / voice-gate sliders, high-pass & auto-gain, capture-source and playback-stream selection, live engine status, logs.
  • Live, reboot-free settings via persist.clarifae.* properties (the effect re-reads on change).
  • clarifae-ctl CLI for scripting and debugging.
  • Clean uninstall — the original audio_effects.xml is only shadowed, never edited.

Requirements

  • A rooted Android device with Magisk ≥ 24.0, KernelSU, or APatch.
  • For the WebUI: KernelSU/APatch have a built-in WebUI launcher; on Magisk, install MMRL to open module WebUIs.
  • To build from source: Android NDK (r27+), CMake, and network access for fetch_deps.sh.

Quick start

# from the project folder:
# 1. fetch RNNoise + weights, then build the native effect for all ABIs
./scripts/fetch_deps.sh
./build.sh                      # -> lib/<abi>/

# 2. package a flashable zip
./scripts/package.sh            # -> dist/clarifae-v1.0.0.zip

# 3. flash dist/clarifae-v1.0.0.zip in Magisk/KernelSU/APatch, reboot
# 4. open the Clarifae WebUI, toggle it on, pick a mode

See INSTALL.md for details, optional DTLN/DeepFilterNet builds, and verification steps.

How it works

 INPUT   mic app ─▶ AudioRecord ─▶ capture chain  ─┐  <preprocess> → clarifae_ns
                                                    ├─▶ libclarifae.so (effect.c)
 OUTPUT  media/call ◀─ AudioTrack ◀─ playback mix ─┘  <postprocess> → clarifae_out
                               │  s16/float ⇄ float, live config from persist.clarifae.*
                               ▼
                  backend: rnnoise │ dtln │ deepfilternet
                               │  resample ⇄ engine rate, frame, enhance, wet/dry + atten cap
                               ▼
              cleaned audio ─▶ back to the app (input) / to the speaker (output)

Configuration flows: WebUI → clarifae-ctlconfig.confpersist.clarifae.* → effect. The effect detects a property change (via the property serial) and reloads parameters / re-opens the backend on the next audio buffer, so most changes apply without a reboot. See docs/ARCHITECTURE.md.

Configuration reference

/data/adb/clarifae/config.conf is the source of truth (edited by the WebUI/clarifae-ctl) and is mirrored to system properties the effect reads:

Key / property persist.clarifae.* Values Default Meaning
enabled 0 / 1 1 Master on/off (bypass = passthrough)
in_enabled 0 / 1 1 Clean the microphone (input)
out_enabled 0 / 1 1 Clean playback (output)
mode 1 / 2 / 3 1 RNNoise / DTLN / DeepFilterNet
strength 0100 70 Wet/dry blend for the mic
out_strength 0100 60 Wet/dry blend for playback (lower for music)
atten_db 060 24 Max suppression depth (protects tone)
vad 0100 50 Voice-activity sensitivity (gate / auto-gain)
targets csv of mic,voice_comm,camcorder,voice_rec mic,voice_comm Capture sources (input)
out_targets csv of music,voice_call,ring,alarm,notification,system music,voice_call Playback streams (output)
highpass 0 / 1 1 DC/rumble high-pass pre-filter
autogain 0 / 1 0 Gentle make-up gain on speech
loglevel 03 1 logcat verbosity (tag Clarifae)

Effect UUIDs: input (pre-proc) c1a71fae-0001-… (type = AOSP noise-suppression); output (post-proc) c1a71fae-0002-… (custom Clarifae type).

clarifae-ctl commands

clarifae-ctl get                 # print config.conf
clarifae-ctl get-json            # settings as JSON
clarifae-ctl set KEY VALUE       # validate + write config + sync property
clarifae-ctl set-many K=V K=V…   # batch set
clarifae-ctl apply               # push all config -> persist.clarifae.*
clarifae-ctl status              # human-readable engine status
clarifae-ctl status-json         # status as JSON (used by the WebUI)
clarifae-ctl restart-audio       # respawn audioserver to reload effects
clarifae-ctl reset               # restore defaults
clarifae-ctl log                 # tail ctl log + logcat -s Clarifae
clarifae-ctl version

Limitations & caveats

  • Auto-attach is device-dependent. It edits the device's audio_effects.xml via an overlay. Some vendors use non-standard formats/locations; if patching fails the library is still installed and you can attach it manually (see docs/TROUBLESHOOTING.md).
  • Not every app/stream gets cleaned. Effects apply per audio source (input) and per stream type (output). Apps using their own DSP, a raw/unprocessed source, direct/offload output, or exotic routes may bypass it. New sessions pick up changes; some need a restart-audio.
  • Output post-processing support varies by device more than input pre-processing — some ROMs ignore or restrict <postprocess> stream effects.
  • Music will be degraded if you enable output on the music stream — these are speech models. Use Playback strength or disable playback cleanup for music.
  • SELinux/vendor variance. persist.clarifae.* live under default_prop; a defensive sepolicy.rule is included for stricter devices.
  • DTLN/DeepFilterNet are experimental and require extra runtimes/models; without them Clarifae uses RNNoise.
  • Real-time enhancement adds a small fixed latency (~10 ms for RNNoise + resampler).

Licensing & credits

Clarifae module code is provided as-is for the brand owner. It builds on:

Verify each upstream license before redistribution. TensorFlow Lite (DTLN backend) is Apache-2.0.

About

Real-time AI microphone clarity for rooted Android (Magisk/KernelSU/APatch) — RNNoise/DTLN/DeepFilterNet audio pre-processing effect with a WebUI.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors