Skip to content

Commit

Permalink
Adding the ability to add silence in the result set of fingerprints, …
Browse files Browse the repository at this point in the history
…which may be useful for scenarios when the signal contains a lot of pauses that are considered as silence (podcasts).
  • Loading branch information
AddictedCS committed May 16, 2024
1 parent 3e12ad5 commit f008168
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/SoundFingerprinting/Configuration/FingerprintConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,15 @@ public FrequencyRange FrequencyRange
/// Frame normalization allows to apply
/// </remarks>
public IFrameNormalization FrameNormalizationTransform { get; set; } = null!;

/// <summary>
/// Gets or sets a value indicating whether to include silence fingerprints into the fingerprinted result set.
/// </summary>
/// <remarks>
/// Keep in mind that silence fingerprints will always cross-match with any other silence fingerprints. <br />
/// May be useful in scenarios when the dataset is small, and the content you are fingerprinting contains a lot of speech. <br />
/// Default value is false. <br/>
/// </remarks>
public bool TreatSilenceAsSignal { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/SoundFingerprinting/FingerprintService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ internal IEnumerable<Fingerprint> CreateOriginalFingerprintsFromFrames(IEnumerab
waveletDecomposition.DecomposeImageInPlace(rowCols, frame.Rows, frame.Cols, configuration.HaarWaveletNorm);
RangeUtils.PopulateIndexes(length, cachedIndexes);
var image = fingerprintDescriptor.ExtractTopWavelets(rowCols, configuration.TopWavelets, cachedIndexes);
if (!image.IsSilence)
if (!image.IsSilence || configuration.TreatSilenceAsSignal)
{
fingerprints.Add(new Fingerprint(image, frame.StartsAt, frame.SequenceNumber, originalPoint));
}
Expand Down

0 comments on commit f008168

Please sign in to comment.