{"id":10199,"library":"resemble-perth","title":"Perth Audio Watermarking and Detection","description":"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.","status":"active","version":"1.0.1","language":"en","source_language":"en","source_url":"https://github.com/resemble-ai/Perth","tags":["audio","watermarking","detection","signal processing","ai-generated content"],"install":[{"cmd":"pip install resemble-perth","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Fundamental numerical operations and array handling for audio data.","package":"numpy"},{"reason":"Scientific computing library, used for signal processing tasks.","package":"scipy"},{"reason":"Reading and writing audio files in various formats.","package":"soundfile"},{"reason":"Backend for reading diverse audio formats.","package":"audioread"},{"reason":"Audio analysis library, commonly used for loading and preprocessing audio data (recommended in examples).","package":"librosa"}],"imports":[{"symbol":"Watermarker","correct":"from resemble_perth import Watermarker"},{"symbol":"Detector","correct":"from resemble_perth import Detector"}],"quickstart":{"code":"import librosa\nimport numpy as np\nfrom resemble_perth import Watermarker, Detector\n\n# Create a dummy audio signal (replace with your actual audio file)\nsr = 44100 # Sample rate in Hz\nduration = 3 # seconds\n# A simple sine wave for demonstration\ny = np.sin(2 * np.pi * 440 * np.linspace(0, duration, int(sr * duration))).astype(np.float32)\n\n# Initialize Watermarker and watermark the audio\nwatermarker = Watermarker()\nwatermarked_audio = watermarker.watermark(y, sr)\n\nprint(f\"Original audio shape: {y.shape}, sample rate: {sr}\")\nprint(f\"Watermarked audio shape: {watermarked_audio.shape}\")\n\n# Initialize Detector and detect watermark\ndetector = Detector()\nis_watermarked = detector.detect(watermarked_audio, sr)\n\nprint(f\"Is audio watermarked? {is_watermarked}\")\n\n# Example with a non-watermarked audio\nnon_watermarked_audio = np.random.randn(int(sr * duration)).astype(np.float32)\nis_watermarked_false = detector.detect(non_watermarked_audio, sr)\nprint(f\"Is non-watermarked audio detected as watermarked? {is_watermarked_false}\")","lang":"python","description":"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."},"warnings":[{"fix":"For best results and accuracy, ensure input audio is resampled to 44.1 kHz or 24 kHz. Other sample rates might impact watermarking and detection performance. Use a library like `librosa.resample` for this.","message":"Optimal Performance with Specific Sample Rates","severity":"gotcha","affected_versions":"1.0.x"},{"fix":"The `watermark` and `detect` methods strictly expect audio data as a 1D `numpy.ndarray` (float32 or float64). Ensure your audio files are loaded and converted into this format. `librosa.load` is a recommended tool.","message":"Input Audio Must Be a NumPy Array","severity":"gotcha","affected_versions":"1.0.x"},{"fix":"The library primarily uses CPU for processing. For very long audio files or large datasets, consider segmenting audio into smaller chunks for processing or optimizing your processing pipeline externally, as direct GPU acceleration is not currently offered.","message":"CPU-bound Processing for Large Audio","severity":"gotcha","affected_versions":"1.0.x"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install resemble-perth` in your terminal. If using a virtual environment, ensure it is activated before running your script.","cause":"The `resemble-perth` library is not installed in the current Python environment or the environment is not activated.","error":"ModuleNotFoundError: No module named 'resemble_perth'"},{"fix":"Convert your audio data to a NumPy array (e.g., `np.array(your_audio_list)`). If loading from a file, use `librosa.load('audio.wav', sr=None)[0]` to get a 1D NumPy array of audio samples.","cause":"The input audio provided to `watermark` or `detect` is not a `numpy.ndarray`, but a different type like a list, tuple, or a PyTorch/TensorFlow tensor.","error":"TypeError: 'list' object cannot be interpreted as a numpy array"},{"fix":"Resample your audio to a supported sample rate, ideally 44.1 kHz or 24 kHz, before passing it to the watermarker/detector. Example with `librosa`: `resampled_audio = librosa.resample(audio, orig_sr=X, target_sr=44100)`.","cause":"The provided sample rate (X) for the audio is outside the supported range or not one of the recommended sample rates.","error":"ValueError: Audio sample rate X is not supported"}]}