IGenreClassifier<T>
Interfaces · AiDotNet.Interfaces
Interface for music genre classification models.
Implements: IFeatureAware, IFullModel<T, Tensor<T>, Tensor<T>>, IGradientComputable<T, Tensor<T>, Tensor<T>>
Known implementations: GenreClassifier<T>
For Beginners
Genre classification is like having an expert listener label what type of music a song is.
How it works:
- Audio features are extracted (mel-spectrograms, MFCCs, etc.)
- A neural network analyzes these features
- The network outputs probabilities for each genre
Common genres:
- Rock, Pop, Hip-Hop, R&B
- Jazz, Blues, Classical
- Electronic, EDM, House, Techno
- Country, Folk, Reggae
Use cases:
- Music library organization
- Streaming service recommendations
- Radio station automation
- Music analysis and research
Challenges:
- Genre boundaries are fuzzy (many songs blend genres)
- Genre definitions vary between cultures and time periods
- Sub-genres vs main genres (is “death metal” a genre or sub-genre?)
How It Works
Genre classification automatically categorizes music into genres like rock, jazz, classical, hip-hop, etc. This is useful for music organization, recommendation, and discovery.
This interface extends IFullModel for Tensor-based audio processing.
Properties
| Property | Summary |
|---|---|
IReadOnlyList<string> SupportedGenres { get; } |
Gets the list of genres this model can classify. |
bool IsOnnxMode { get; } |
Gets whether this model is running in ONNX inference mode. |
bool SupportsMultiLabel { get; } |
Gets whether this model supports multi-label classification. |
int SampleRate { get; } |
Gets the expected sample rate for input audio. |
Methods
| Method | Summary |
|---|---|
GenreClassificationResult<T> Classify(Tensor<T> audio) |
Classifies the genre of audio. |
GenreTrackingResult<T> TrackGenreOverTime(Tensor<T> audio, double segmentDuration) |
Tracks genre over time within a piece. |
IReadOnlyDictionary<string, T> GetGenreProbabilities(Tensor<T> audio) |
Gets genre probabilities for all supported genres. |
IReadOnlyList<GenrePrediction<T>> GetTopGenres(Tensor<T> audio, int k) |
Gets top-K genre predictions. |
Task<GenreClassificationResult<T>> ClassifyAsync(Tensor<T> audio, CancellationToken cancellationToken) |
Classifies genre asynchronously. |
Tensor<T> ExtractFeatures(Tensor<T> audio) |
Extracts audio features used for classification. |