Perth Audio Watermarking and Detection

1.0.1 · active · verified Fri Apr 17

resemble-perth is an audio watermarking and detection library developed by Resemble AI. It allows embedding and detecting imperceptible watermarks in audio signals, primarily designed for identifying AI-generated content. The current stable version is 1.0.1, with new releases typically occurring as features are added or bug fixes are made.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Watermarker and Detector, embed a watermark into a dummy audio signal, and then detect its presence. It also shows a detection attempt on an unwatermarked signal.

import librosa
import numpy as np
from resemble_perth import Watermarker, Detector

# Create a dummy audio signal (replace with your actual audio file)
sr = 44100 # Sample rate in Hz
duration = 3 # seconds
# A simple sine wave for demonstration
y = np.sin(2 * np.pi * 440 * np.linspace(0, duration, int(sr * duration))).astype(np.float32)

# Initialize Watermarker and watermark the audio
watermarker = Watermarker()
watermarked_audio = watermarker.watermark(y, sr)

print(f"Original audio shape: {y.shape}, sample rate: {sr}")
print(f"Watermarked audio shape: {watermarked_audio.shape}")

# Initialize Detector and detect watermark
detector = Detector()
is_watermarked = detector.detect(watermarked_audio, sr)

print(f"Is audio watermarked? {is_watermarked}")

# Example with a non-watermarked audio
non_watermarked_audio = np.random.randn(int(sr * duration)).astype(np.float32)
is_watermarked_false = detector.detect(non_watermarked_audio, sr)
print(f"Is non-watermarked audio detected as watermarked? {is_watermarked_false}")

view raw JSON →