SongRec Library
A clean, library-focused Rust crate for audio recognition using Shazam's algorithm, with comprehensive device management.
Based on the original SongRec by marin-m.
Please note that this library was heavily modified with the help of an LLM, which means some stuff needs work, it is functional but not fully battle-tested. nor optimized I'm not intending to give a lot of time to doing this myself, as this was mostly done for a test rather than something really production ready
Features
- 🎵 Audio Recognition: Recognize songs from files or live audio
- 📊 Multiple Formats: JSON, CSV, and simple text output
- 🌐 Cross-Platform: Windows, and Linux support (macOS not tested)
Quick Start
Add to your Cargo.toml:
[]
= "0.5.0"
Basic usage:
use ;
let config = default.with_quiet_mode;
let songrec = new;
// Recognize from file
let result = songrec.recognize_from_file?;
println!;
Device Management
use AudioRecorder;
// List available audio devices
let devices = list_input_devices?;
for in devices.iter.enumerate
// Live recognition with specific device
let stream = songrec.start_continuous_recognition_with_device?;
for result in stream
Output Formats
use ;
// JSON (for APIs)
let json = format_result;
// CSV (for logging)
let csv = format_result;
// Simple text
let simple = format_result;
Examples
# Basic library usage
# Device management demonstration
CLI Tool
# List audio devices
# Recognize from file
API Reference
Core Types
SongRec: Main recognition interfaceConfig: Configuration builderRecognitionResult: Song metadata structureAudioRecorder: Device management
Configuration
let config = default
.with_sensitivity // Recognition sensitivity (0.0-1.0)
.with_network_timeout // API timeout in seconds
.with_quiet_mode; // Suppress debug output
Result Structure
Requirements
- Rust 1.70+
- Network connection (for Shazam API)
- Audio system access (for device operations)
License
GPL-3.0 (same as original SongRec)
Credits
This library is based on the original SongRec project by marin-m. This version focuses on providing a clean library interface while maintaining the core audio fingerprinting functionality from the original project.