Interface IGenreClassifier<T>
- Namespace
- AiDotNet.Interfaces
- Assembly
- AiDotNet.dll
public interface IGenreClassifier<T> : IFullModel<T, Tensor<T>, Tensor<T>>, IModel<Tensor<T>, Tensor<T>, ModelMetadata<T>>, IModelSerializer, ICheckpointableModel, IParameterizable<T, Tensor<T>, Tensor<T>>, IFeatureAware, IFeatureImportance<T>, ICloneable<IFullModel<T, Tensor<T>, Tensor<T>>>, IGradientComputable<T, Tensor<T>, Tensor<T>>, IJitCompilable<T>
Type Parameters
T
- Inherited Members
- Extension Methods
Properties
IsOnnxMode
Gets whether this model is running in ONNX inference mode.
bool IsOnnxMode { get; }
Property Value
SampleRate
Gets the expected sample rate for input audio.
int SampleRate { get; }
Property Value
SupportedGenres
Gets the list of genres this model can classify.
IReadOnlyList<string> SupportedGenres { get; }
Property Value
SupportsMultiLabel
Gets whether this model supports multi-label classification.
bool SupportsMultiLabel { get; }
Property Value
Remarks
For Beginners: Multi-label means a song can belong to multiple genres at once (e.g., both "rock" and "electronic"). Single-label forces one choice.
Methods
Classify(Tensor<T>)
Classifies the genre of audio.
GenreClassificationResult<T> Classify(Tensor<T> audio)
Parameters
audioTensor<T>Audio waveform tensor [samples] or [channels, samples].
Returns
- GenreClassificationResult<T>
Genre classification result.
Remarks
For Beginners: This is the main method for classifying genre. - Pass in audio of a song - Get back the most likely genre(s)
ClassifyAsync(Tensor<T>, CancellationToken)
Classifies genre asynchronously.
Task<GenreClassificationResult<T>> ClassifyAsync(Tensor<T> audio, CancellationToken cancellationToken = default)
Parameters
audioTensor<T>Audio waveform tensor.
cancellationTokenCancellationTokenCancellation token for async operation.
Returns
- Task<GenreClassificationResult<T>>
Genre classification result.
ExtractFeatures(Tensor<T>)
Extracts audio features used for classification.
Tensor<T> ExtractFeatures(Tensor<T> audio)
Parameters
audioTensor<T>Audio waveform tensor.
Returns
- Tensor<T>
Feature tensor used by the classifier.
GetGenreProbabilities(Tensor<T>)
Gets genre probabilities for all supported genres.
IReadOnlyDictionary<string, T> GetGenreProbabilities(Tensor<T> audio)
Parameters
audioTensor<T>Audio waveform tensor.
Returns
- IReadOnlyDictionary<string, T>
Dictionary mapping genre names to probability scores.
GetTopGenres(Tensor<T>, int)
Gets top-K genre predictions.
IReadOnlyList<GenrePrediction<T>> GetTopGenres(Tensor<T> audio, int k = 5)
Parameters
audioTensor<T>Audio waveform tensor.
kintNumber of top genres to return.
Returns
- IReadOnlyList<GenrePrediction<T>>
List of top genre predictions with probabilities.
TrackGenreOverTime(Tensor<T>, double)
Tracks genre over time within a piece.
GenreTrackingResult<T> TrackGenreOverTime(Tensor<T> audio, double segmentDuration = 10)
Parameters
audioTensor<T>Audio waveform tensor.
segmentDurationdoubleDuration of each analysis segment in seconds.
Returns
- GenreTrackingResult<T>
Genre tracking result showing genre over time.
Remarks
For Beginners: Some songs change style during playback. This tracks the dominant genre at different points in the song.