crates/veilvoice-meta/src/audio.rs
veilvoice-meta · 278 lines · read the source here · or on GitHub
Audio tag removal and replacement.
Tags are handled through lofty, which understands ID3v1/ID3v2, Vorbis comments, MP4 atoms and APE, so one code path covers every format VeilVoice imports. Only the tag blocks are rewritten: the audio stream is never re-encoded, so cleaning a file is lossless.
What tags give away
Far more than a title. Recording software writes its own name and version; phones write a device model; some encoders write a timestamp, and a few write a serial number or a user name taken from the account that made the file. None of that is audible, all of it survives de-identification untouched, and any of it can identify a speaker whose voice no longer does.
Stripping the voiceprint and leaving the tags would be a complete failure wearing the appearance of success, which is why this crate exists and why the CLI cleans by default.
Removal, or plausible replacement
crate::Policy chooses between deleting tags outright and writing bland ones. Both are legitimate: an empty tag block is itself a signal that a file has been processed, and in some situations looking ordinary matters more than being empty.
The gap lofty cannot close
lofty understands ID3v1/ID3v2, Vorbis comments, MP4 atoms and APE through one interface -- but it cannot remove an ID3v2 block from a WAV file. A WAV is a RIFF container and an ID3 chunk inside one is a chunk, not a tag, so the tag library does not see it. That is what crate::wav is for: a chunk-level cleaner that walks the RIFF structure directly. Without it, cleaning a WAV reported success and left the identifying block in place.
In plain words
Strips the hidden information out of an audio file: the artist, the title, the comments, the software that made it, the date, and anything else somebody wrote into it.
None of that is audible, and all of it travels with the file. A recording whose voice has been carefully veiled is not anonymous if the file still says who recorded it and on what.
WHAT THIS FILE CONTAINS
278 lines defining 3 functions (2 public), 0 types and 1 constant. Everything below is read out of the source, so it cannot disagree with the code.
What happens when it runs. These are the ways in: public, and nothing else in this file calls them, so they are what an outside caller reaches first.
clean_audio_fileline 81 · Strip or replace the tags of an audio file, in place.
reachesread_headclean_audio_tagsline 134 · Report which tag blocks a file carries, without modifying it.
reachesread_head
WHAT CALLS WHAT
The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.
The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
n_read_head["read_head<br/>line 57"]
n_clean_audio_file(["clean_audio_file<br/>line 81"])
n_clean_audio_tags(["clean_audio_tags<br/>line 134"])
n_clean_audio_file --> n_read_head
n_clean_audio_tags --> n_read_head
click n_read_head href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-meta/src/audio.rs#L57" "open the source"
click n_clean_audio_file href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-meta/src/audio.rs#L81" "open the source"
click n_clean_audio_tags href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-meta/src/audio.rs#L134" "open the source"
classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
class n_clean_audio_file,n_clean_audio_tags entry
classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
class n_read_head helper
This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.
ITEMS
| Item | Line | Documentation |
|---|---|---|
read_head fn | 57 | Read just enough of a file to identify its container. |
REALISTIC const | 71 | Tags written in Policy::Realistic mode. |
clean_audio_file pub fn | 81 | Strip or replace the tags of an audio file, in place. |
clean_audio_tags pub fn | 134 | Report which tag blocks a file carries, without modifying it. |