Tier 2 - Encoding-robust acoustic fingerprint match (audfprint)
本頁為腳本自動產生的英文技術明細。名詞說明:TT = Taiwan-Tongues 資料集(
adi-gov-tw/Taiwan-Tongues-ASR-CE-dataset-zhtw);CV = Mozilla Common Voice。中文總結請見研究報告。
Generated by scripts/03_fingerprint_audfprint.py on 2026-12-03; runtime 125.5 s on 8 CPU cores.
Headline
- 3366 / 3366 (100.00%) Taiwan-Tongues clips with a Common Voice reference return that reference as the top-1 acoustic match out of 8366 indexed CV clips.
- True-pair score (time-consistent common landmarks): median 257, minimum 27; the matched fraction of query hashes is median 104% (min 98%). The time offset is 0 s for every pair, as expected for a verbatim copy.
- False-match baseline (every TT clip against 5,000 CV clips that are not in TT): median 4, 99.9th percentile 13, maximum 16.
- Decision threshold >= 14 common landmarks (rule: max(--min-threshold, floor(p99.9 of negative scores) + 1); zero-false-positive threshold would be 17). At this threshold: TP = 3366, FN = 0, FP = 2 (FP counted over all 3787 queries incl. the 421 zh-CN clips whose reference is not on disk).
- Smallest margin between the true match and the best wrong candidate in the full index: 25 landmarks.
- Robustness simulation (300 clips x 5 degradations): top-1 accuracy 100.0-100.0%; the hardest condition (
e_combined_a_c_d) is still detected at the threshold in 100.0% of clips. A re-encoded, resampled, trimmed or re-gained copy would therefore have been caught.
Method
audfprint (Dan Ellis, MIT licence, https://github.com/dpwe/audfprint, commit cb03ba99feafd41b8874307f0f4e808a6ce34362) implements Shazam-style landmark fingerprinting: audio is resampled to 11,025 Hz, spectrogram peaks (512-pt FFT, 256 hop = 23.2 ms frames) are paired into (f1, f2, dt) landmarks and hashed to 20-bit keys stored with their frame time. A query is scored against each candidate reference by the number of common hashes whose (reference time - query time) agree within +-2 frames. The score is independent of codec, bit-rate and gain; trimming shifts the offset but not the count. Byte-level or decoded-PCM equality is not required.
Steps performed by the script:
- Hash all 3366 CV counterparts (
A_cv/) and all 5000 CV zh-TW clips that are not in TT (A_distractor/); build one index with all 8366 (2,372,730 hashes) and a second index with the distractors only (1,468,211 hashes). - Query every TT clip (3787) against the full index; record the top-10 candidates, the rank and score of the true counterpart, and the best wrong candidate.
- Negative control: query the same TT clips against the distractor-only index (no true counterpart can exist there); the best score per query is the false-match baseline.
- Threshold = max(10, floor(99.9th percentile of false scores) + 1); classify every query.
- Robustness: 300 random zh-TW TT clips (seed 0) are degraded with ffmpeg (see below) and queried against the full index.
Parameters
| parameter | value | why |
|---|---|---|
| --density | 70 | landmarks/s; default 20 gives only ~50 hashes for a 2.5 s clip, 70 gives ~150-300 |
| --hashbits | 20 | 2^20 buckets x depth 100; ~2.4 hashes/bucket for this index |
| --shifts | 2 | sub-frame time shifts for index and query; doubles surviving matches after re-encode/trim |
| --match-win | 2 | +-2 frames (46 ms) alignment tolerance (audfprint default) |
| --min-count | 0 | record every candidate so the false-match distribution is not truncated |
| --search-depth | 100 | candidates examined per query, ranked by raw hits (default) |
| --samplerate / FFT / hop | 11025 / 512 / 256 | audfprint fixed front end |
Parameter choice was checked on 40 clips under the harshest degradation (32 kbps + 0.3 s trim + -6 dB) before the run: density 40/70/100 and shifts 1/2/4 all gave 40/40 top-1 against 440 references, but density 70 with shifts 2 (index and query) raised the median true score from 40 to 83 and the minimum from 10 to 17 compared with shifts 1, and the minimum is the figure that matters for a threshold. shifts 4 adds ~40% more hashes at twice the query cost; density 100 adds ~40% more index.
Equivalent CLI commands
The script calls the same classes the CLI uses (Analyzer.wavfile2hashes, HashTable.store, Matcher.match_hashes). The equivalent command lines are:
git clone https://github.com/dpwe/audfprint.git tools/audfprint && git -C tools/audfprint checkout cb03ba99feafd41b8874307f0f4e808a6ce34362
# reference index (A_cv + A_distractor)
python tools/audfprint/audfprint.py new --dbase ref_full.pklz --density 70 --hashbits 20 --shifts 2 --ncores 8 --list ref_files.txt
# distractor-only index
python tools/audfprint/audfprint.py new --dbase ref_distractor.pklz --density 70 --hashbits 20 --shifts 2 --ncores 8 --list distractor_files.txt
# queries (add --min-count 1 to see weak false matches; the script uses 0 via the API)
python tools/audfprint/audfprint.py match --dbase ref_full.pklz --density 70 --shifts 2 --match-win 2 --max-matches 10 --find-time-range --ncores 8 --list tt_files.txt
# full pipeline as run here
python scripts/03_fingerprint_audfprint.py --sample data/sample --out results/03_fingerprint --ncores 8
Results
True pairs vs. false-match baseline
Score = number of time-consistent common landmarks (audfprint filtered count). frac = score / number of hashes in the query clip; it can slightly exceed 1.0 for identical audio because the +-2-frame window also counts hashes that recur at neighbouring frames.
| set | n | min | p1 | p5 | median | p95 | p99.9 | max | median frac |
|---|---|---|---|---|---|---|---|---|---|
| true pairs (TT vs its CV counterpart, full index) | 3366 | 27 | 66 | 106 | 257 | 531 | 1121 | 1598 | 1.04 |
| best wrong candidate (full index) | 3366 | 2 | 2 | 3 | 4 | 8 | 13 | 16 | - |
| negative control (TT vs distractor-only index) | 3787 | 2 | 2 | 3 | 4 | 7 | 13 | 16 | 0.02 |
Query clips: duration median 3.1 s (range 1.1-10.3 s), hashes median 257 (range 27-1526).
Decision at threshold
| value | |
|---|---|
| threshold (common landmarks) | >= 14 |
| rule | max(--min-threshold, floor(p99.9 of negative scores) + 1) |
| 99.9th percentile of false scores | 13.2 |
| negatives at or above threshold | 4 / 3787 |
| zero-FP threshold (max false score + 1) | 17 |
| TP (counterpart on disk, top-1 is counterpart, score >= thr) | 3366 |
| FN (counterpart on disk, not accepted) | 0 |
| FP (accepted but top-1 is not the counterpart, or no counterpart on disk) | 2 |
| TN (no counterpart on disk, nothing accepted) | 419 |
Clips without a counterpart on disk are the ~420 zh-CN TT clips for which no CV mirror had the file (see Tier 1); they are queried as an additional negative set.
The 2 false positive(s)
| key | locale | dur s | hashes | top-1 | score | frac | matched span s | offset s | same speaker | same sentence |
|---|---|---|---|---|---|---|---|---|---|---|
| train-000049090 | zh-CN | 5.436 | 641 | common_voice_zh-TW_19366504.mp3 | 14 | 0.022 | 0.07 | 0.30 | False | False |
| train-000094641 | zh-CN | 7.236 | 830 | common_voice_zh-TW_30656799.mp3 | 14 | 0.017 | 0.05 | 0.07 | False | False |
These are chance coincidences, not shared recordings: the matched landmarks are ~2% of the query's hashes (true pairs: >= 98%; degraded copies: >= 13%) and span well under 0.1 s of audio (true pairs: median 1.4 s), on long clips whose many hashes give more opportunities for random collisions. Negative-control scores grow weakly with clip length for the same reason.
Alternative decision rules
| rule | TP | FN | FP | negatives accepted | degraded detected (min over conditions) |
|---|---|---|---|---|---|
| primary p99.9 (score >= 14) | 3366 | 0 | 2 | 4 | 100.0% |
| zero fp max neg plus 1 (score >= 17) | 3366 | 0 | 0 | 0 | 99.7% |
| primary plus frac 0.10 (score >= 14, frac >= 0.10) | 3366 | 0 | 0 | 1 | 100.0% |
Either raising the score threshold to the maximum false score + 1, or adding a length-normalised criterion (matched fraction >= 0.10), removes all false positives while keeping every true pair; the only cost is a slightly lower catch rate on the very shortest heavily degraded clips.
Top-1 mismatches
None: every TT clip with a reference on disk returned that reference at rank 1.
Robustness simulation (would a disguised copy be caught?)
300 random zh-TW TT clips were degraded with ffmpeg and queried against the full index (8366 references). None of the degraded files is byte- or PCM-identical to the original. Expected offset: 0 s for (a), (b), (d) and 0.3 s for (c), (e).
| condition | ffmpeg recipe | top-1 acc | detected (score >= thr) | true in top-10 | score min / p5 / median | score retained (median) | frac median | best wrong max | offset median s |
|---|---|---|---|---|---|---|---|---|---|
| a_mp3_32kbps | re-encode MP3 32 kbps (-c:a libmp3lame -b:a 32k) |
100.0% | 100.0% | 100.0% | 15 / 43 / 100 | 40% | 0.38 | 13 | 0.000 |
| b_resample16k_mp3_48k_64kbps | 16 kHz WAV (-ar 16000) then MP3 48 kHz 64 kbps (-ar 48000 -b:a 64k) |
100.0% | 100.0% | 100.0% | 41 / 76 / 170 | 70% | 0.72 | 13 | 0.000 |
| c_trim_start_0.3s | cut 0.3 s from start (-ss 0.3), MP3 64 kbps |
100.0% | 100.0% | 100.0% | 17 / 42 / 110 | 43% | 0.49 | 10 | 0.302 |
| d_gain_minus6dB | gain -6 dB (-af volume=-6dB), MP3 64 kbps |
100.0% | 100.0% | 100.0% | 25 / 60 / 149 | 60% | 0.63 | 11 | 0.000 |
| e_combined_a_c_d | (a)+(c)+(d): -ss 0.3 -af volume=-6dB -b:a 32k |
100.0% | 100.0% | 100.0% | 15 / 33 / 81 | 33% | 0.34 | 12 | 0.302 |
Interpretation
- A verbatim copy produces a score equal to (nearly) all of the query's hashes at offset 0; this is what every TT/CV pair shows. The negative control shows what unrelated speech of the same language, often the same sentence text read by other speakers, produces: a handful of coincidental landmarks. The two distributions do not overlap at the chosen threshold.
- The degradation experiment shows the same detector catching copies that were re-encoded at 32 kbps, passed through 16 kHz, trimmed, or attenuated, so the Tier-1 byte-identity result is not an artefact of the comparison being too strict: an encoding-level disguise would also have been detected, with the trim recovered as a non-zero time offset.
- Limits: landmark fingerprints identify the recording, not the speaker or the sentence. They would not match a different take of the same sentence by the same speaker (which is desirable here). Heavy time-stretching or pitch-shifting is not covered by this method (see Tier 3 for speaker-level evidence).
Files
query_results.csv- one row per TT clip: top-1 candidate, score, offset, rank/score of the true counterpart, best wrong candidate, negative-control score, decision.negative_control.csv- per-clip best score against the distractor-only index.degraded_results.csv- per (clip, condition) result of the robustness simulation;degraded/holds the files.mismatches.csv- clips whose top-1 was not the true counterpart, with speaker/sentence of both.summary.json- all numbers above.