Cheat sheets

Speaker Verification, Spoofing and Watermarks

Enroll, score and threshold speakers, detect spoofed audio, and mark every generation with a watermark and C2PA.

  • Concepts and terms
  • Tasks and commands
  • Annotated code
  • Diagrams
  • Defaults and numbers
  • Troubleshooting
  • Questions and tips

Source

Verify and mark#

real or fakerealanchorsignclientTestutterance3 s or moremodelCountermeasureAASIST orRawNet2modelSpeakerencoderECAPA-TDNN,192-dprocessCosine scorethreshold from adev setmodelTTS outputevery generationprocessAudioSeal16-bit payloadstoreC2PA manifestsigned metadatastoreEnrollment3 to 5 cleanclips, meanreal or fakerealanchorsignclientTest utterance3 s or moremodelCountermeasureAASIST or RawNet2modelSpeaker encoderECAPA-TDNN, 192-dprocessCosine scorethreshold from a devsetmodelTTS outputevery generationprocessAudioSeal16-bit payloadstoreC2PA manifestsigned metadatastoreEnrollment3 to 5 clean clips,mean

From Lesson 06.06, Lesson 06.16

Tasks in code#

TaskCode
Verify a speakerverify(enroll, test, threshold=0.75)
EER and its thresholdeer(same_scores, diff_scores)
Diarize a meetingPipeline.from_pretrained("pyannote/speaker-diarization-3.1")
Load the watermark generatorAudioSeal.load_generator("audioseal_wm_16bits")
Detect a watermarkdetector.detect_watermark(watermarked, sample_rate=16000)
Toy spoof featurespectral_rolloff(spec, percentile=0.85)
Toy text watermarkwatermarked_sample(n, seed_prefix, bias=0.9)
Green-token z-scoredetect(tokens)

From Lesson 06.06, Lesson 06.16, 18.23 code/main.py

Verify with ECAPA#

from speechbrain.pretrained import EncoderClassifier
clf = EncoderClassifier.from_hparams(source="speechbrain/spkrec-ecapa-voxceleb")
enroll = torch.stack([clf.encode_batch(load(x))3-5 clean samples
for x in enrollment_clips]).mean(0)average them
score = clf.similarity(enroll, clf.encode_batch(load("test.wav"))).item()
verdict = score > 0.25tune on your data

From Lesson 06.06

Embed and detect AudioSeal#

generator = AudioSeal.load_generator("audioseal_wm_16bits")
detector = AudioSeal.load_detector("audioseal_detector_16bits")
audio = load_wav("generated.wav", sr=16000)[None, None, :]
payload = torch.tensor([[1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0]])
watermark = generator.get_watermark(audio, sample_rate=16000, message=payload)
watermarked = audio + watermark
result, decoded_payload = detector.detect_watermark(watermarked, sample_rate=16000)

From Lesson 06.16

Formulas#

EER
the threshold where False Accept Rate equals False Reject Rate.
AAM-softmax
\cos(\theta + m) for the correct class. Typical m = 0.2, s = 30.
Verification
1:1. Identification: 1:N. Open-set: unenrolled speakers in the test set.
Green list
hash the previous K tokens, add \delta to green logits.
z-score
(green count - expected) / \sqrt{n p (1 - p)}, p = 0.5.
Bit Recovery Accuracy
fraction of payload bits recovered after an attack.

From Lesson 06.06, Lesson 18.23, 18.23 code/main.py, Lesson 06.16

Watermark families#

AudioSeal
localized, per frame. Survives MP3, AAC, EQ, ±10% speed, +10 dB SNR noise.
WavMark
32 bits/sec. Gaussian noise or MP3 compression removes it.
WaveVerify
FiLM generator, Mixture-of-Experts detector. Handles reversal and speed.
Stable Signature
fine-tuned image decoder. Decoder fine-tuning removes it.
SynthID-text
biased next-token sampling. Paraphrase destroys it.
Pitch shift
Bit Recovery Accuracy below 0.6 for all watermarks.

From Lesson 06.16, Lesson 18.23

Numbers#

SettingDefaultNote
ECAPA embedding192-dWavLM-large is 256-d
ECAPA threshold0.25SpeechBrain typical, tune it
Enrollment samples3-5Clean samples, averaged
ECAPA on VoxCeleb1-O0.87%EER, 15 M params
ASVspoof 5 SOTA~7.23%EER. In the wild expect 5-10%
AudioSeal payload16-bitPer-frame at 16 kHz
AudioSeal detector485× realtime1000× faster than WavMark
Text watermark z4z >= 4 is very strong evidence

From Lesson 06.06, Lesson 06.16, 18.23 code/main.py

Ship a generation#

1Consentwith a clone reference, verify_consent(user_id,clone_reference) first.2Synthesizetts_model.synthesize(text, voice).3Watermarkaudioseal_embed(audio,payload=build_payload(user_id, model_id)).4Signc2pa_sign(audio_with_wm, user_id,timestamp=now()) gives the manifest.5Logkeep a retention-policy-compliant audit log.6Checkrun the detector in your CI.

From Lesson 06.16

Abbreviations#

ECAPA-TDNN
1D conv, squeeze-excitation, attention pooling to 192-d.
PLDA
Probabilistic LDA. Likelihood-ratio scoring on top of cosine.
AS-norm
normalizes each score against an imposter cohort.
CM
countermeasure. Real speech or synthetic.
SASV
speaker verification plus CM in one biometric system.
AASIST
graph attention on spectral features. Anti-spoofing SOTA.
C2PA
cryptographically signed, tamper-evident provenance metadata.
SynthID
watermark for text, image, audio and video.

From Lesson 06.06, Lesson 06.16, Lesson 18.23

Troubleshooting#

SymptomCauseFix
EER rises on phone callsTrained on VoxCeleb web videoEvaluate on the target channel
EER degrades sharplyTest audio under 3 secondsGet longer test audio
Anchor fails for one speakerOne noisy enrollmentAverage 3 or more clean samples
Magnitude dominates the scoreEmbeddings not normalizedL2-normalize first
Detector fails in the real worldAASIST overfits ASVspoof LACalibrate on your domain
Watermark gone after an editAggressive pitch shiftKeep a detection fallback
Manifest missing on a rehostMetadata strip and re-encodeAdd a watermark too
Text watermark goneParaphraseDo not rely on it alone

From Lesson 06.06, Lesson 06.16, Lesson 18.23

Use X when#

  • Closed-set 1:1 on edge: ECAPA-TDNN plus a cosine threshold.
  • Open-set in the cloud: WavLM-SV plus AS-norm.
  • Meetings and podcasts: pyannote/speaker-diarization-3.1.
  • Shipping TTS or cloning: AudioSeal on every output.
  • Voice unlock: AASIST and ECAPA ensemble plus a liveness challenge.
  • Call-center fraud: AASIST on a 20% sample of calls.

From Lesson 06.06, Lesson 06.16

Questions#

Watermark or detector?
Both. Pitch shift removes most watermarks.
Does a liveness phrase stop clones?
It stops replay, not real-time cloning.
No SynthID signal means real?
No. Other models do not add it.
Why C2PA and a watermark?
Metadata is rich but strippable. Watermarks persist but carry bits.
What do you report with EER?
The EER and the threshold at the EER.

From Lesson 06.16, Lesson 18.23, Lesson 06.06