public DuplicatesDetectorService(IModelService modelService, IAudioService audioService, IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.modelService = modelService; this.audioService = audioService; this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; }
public QueryCommand(IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; FingerprintConfiguration = FingerprintConfiguration.Default; QueryConfiguration = QueryConfiguration.Default; }
public DuplicatesDetectorService(IModelService modelService, IAudioService audioService, IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.modelService = modelService; this.audioService = audioService; this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; }
public QueryCommand(IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; FingerprintConfiguration = new EfficientFingerprintConfigurationForQuerying(); QueryConfiguration = new DefaultQueryConfiguration(); }
public QueryCommand(IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; queryConfiguration = new DefaultQueryConfiguration(); queryMatchRegistry = NoOpQueryMatchRegistry.NoOp; }
internal QueryCommand(IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; FingerprintConfiguration = new EfficientFingerprintConfigurationForQuerying(); QueryConfiguration = new DefaultQueryConfiguration { FingerprintConfiguration = FingerprintConfiguration }; }
private bool TryQuery(IQueryFingerprintService service, Hashes hashes, out IEnumerable <QueryResult> results) { try { var result = service.Query(hashes, configuration.QueryConfiguration, modelService); if (!downtimeHashes.Any()) { results = new[] { result }.AsEnumerable(); return(true); } results = ConsumeDowntimeHashes(service) .Concat(ConsumeExternalDowntimeHashes(service)) .Concat(new[] { result }); configuration?.RestoredAfterErrorCallback.Invoke(); return(true); } catch (Exception e) { var timedHashes = StoreDowntimeEntries(hashes); InvokeExceptionCallback(e, timedHashes); results = Enumerable.Empty <QueryResult>(); return(false); } }
public FingerprintCommandBuilderIntTest() { bassAudioService = new BassAudioService(); naudioAudioService = new NAudioService(); modelService = new SqlModelService(); fingerprintCommandBuilder = new FingerprintCommandBuilder(); queryFingerprintService = new QueryFingerprintService(); }
public FingerprintCommandBuilderIntTest() { bassAudioService = new BassAudioService(); naudioAudioService = new NAudioService(); modelService = new SqlModelService(); fingerprintCommandBuilder = new FingerprintCommandBuilder(); queryFingerprintService = new QueryFingerprintService(); }
private IEnumerable <QueryResult> ConsumeDowntimeHashes(IQueryFingerprintService service) { while (downtimeHashes.Any()) { var timedHashes = downtimeHashes.Dequeue(); yield return(service.Query(timedHashes, configuration.QueryConfiguration, modelService)); } }
public RealtimeQueryCommand(IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; downtimeHashes = new Queue <Hashes>(); configuration = new DefaultRealtimeQueryConfiguration( e => { /* do nothing */ }, e => { /* do nothing */ }, fingerprints => { /* do nothing */ }, (e, _) => throw e, () => { /* do nothing */ }); }
public override void SetUp() { base.SetUp(); modelService = new SqlModelService(); DependencyResolver.Current.Bind <IAudioService, BassAudioService>(); fingerprintCommandBuilderWithBass = new FingerprintCommandBuilder(); DependencyResolver.Current.Bind <IAudioService, NAudioService>(); fingerprintCommandBuilderWithNAudio = new FingerprintCommandBuilder(); queryFingerprintService = new QueryFingerprintService(modelService); }
private IEnumerable <QueryResult> ConsumeExternalDowntimeHashes(IQueryFingerprintService service) { foreach (var downtimeHash in configuration.DowntimeHashes) { if (downtimeHash.IsEmpty) { continue; } yield return(service.Query(downtimeHash, configuration.QueryConfiguration, modelService)); } }
private IEnumerable <QueryResult> ConsumeDowntimeHashes(IQueryFingerprintService service) { var list = new List <QueryResult>(); while (downtimeHashes.Any()) { var timedHashes = downtimeHashes.Dequeue(); var results = service.Query(timedHashes, configuration.QueryConfiguration, modelService); list.Add(results); } return(list); }
private IEnumerable <QueryResult> ConsumeExternalDowntimeHashes(IQueryFingerprintService service) { var list = new List <QueryResult>(); foreach (var downtimeHash in configuration.DowntimeHashes) { if (downtimeHash.IsEmpty) { continue; } var results = service.Query(downtimeHash, configuration.QueryConfiguration, modelService); list.Add(results); } return(list); }
internal QueryCommandBuilder(IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; }
internal QueryCommand(IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; QueryConfiguration = new DefaultQueryConfiguration(); }
public FaultyQueryService(int faultyCounts, IQueryFingerprintService goodOne) { this.faultyCounts = faultyCounts; this.goodOne = goodOne; }
internal QueryCommandBuilder(IFingerprintCommandBuilder fingerprintCommandBuilder, IQueryFingerprintService queryFingerprintService) { this.fingerprintCommandBuilder = fingerprintCommandBuilder; this.queryFingerprintService = queryFingerprintService; }
private async Task <double> QueryAndHash(CancellationToken cancellationToken, IQueryFingerprintService service) { var realtimeSamplesAggregator = new RealtimeAudioSamplesAggregator(configuration.Stride, MinSamplesForOneFingerprint); var resultsAggregator = new StatefulRealtimeResultEntryAggregator(configuration.ResultEntryFilter, configuration.QueryConfiguration); double queryLength = 0d; await foreach (var audioSamples in realtimeCollection.WithCancellation(cancellationToken)) { if (audioSamples.SampleRate != SupportedFrequency) { throw new ArgumentException($"{nameof(audioSamples)} should be provided down sampled to {SupportedFrequency}Hz"); } queryLength += audioSamples.Duration; var prefixed = realtimeSamplesAggregator.Aggregate(audioSamples); var hashes = (await CreateQueryFingerprints(fingerprintCommandBuilder, prefixed)).WithStreamId(streamId); hashes = hashesInterceptor(hashes).WithTimeOffset(audioSamples.Duration - hashes.DurationInSeconds); if (!TryQuery(service, hashes, out var queryResults)) { continue; } foreach (var queryResult in queryResults) { var aggregatedResult = resultsAggregator.Consume(queryResult.ResultEntries, queryResult.QueryHashes.DurationInSeconds, queryResult.QueryHashes.TimeOffset); InvokeSuccessHandler(aggregatedResult); InvokeDidNotPassFilterHandler(aggregatedResult); } } var purged = resultsAggregator.Purge(); InvokeSuccessHandler(purged); InvokeDidNotPassFilterHandler(purged); return(queryLength); }
private async Task <double> QueryAndHash(CancellationToken cancellationToken, IQueryFingerprintService service) { var realtimeSamplesAggregator = new RealtimeAudioSamplesAggregator(configuration.Stride, MinSamplesForOneFingerprint); var resultsAggregator = new StatefulRealtimeResultEntryAggregator(configuration.ResultEntryFilter, configuration.QueryConfiguration); double queryLength = 0d; AudioSamples?audioSamples; while ((audioSamples = await realtimeCollection.TryReadAsync(cancellationToken)) != null) { if (audioSamples.SampleRate != SupportedFrequency) { throw new ArgumentException($"{nameof(audioSamples)} should be provided down sampled to {SupportedFrequency}Hz"); } queryLength += audioSamples.Duration; var prefixed = realtimeSamplesAggregator.Aggregate(audioSamples); var hashes = await CreateQueryFingerprints(fingerprintCommandBuilder, prefixed); InvokeHashedFingerprintsCallback(hashes); if (!TryQuery(service, hashes, out var queryResults)) { continue; } foreach (var queryResult in queryResults) { var aggregatedResult = resultsAggregator.Consume(queryResult.ResultEntries, hashes.DurationInSeconds, audioSamples.Duration - prefixed.Duration); InvokeSuccessHandler(aggregatedResult); InvokeDidNotPassFilterHandler(aggregatedResult); } } var purged = resultsAggregator.Consume(Enumerable.Empty <ResultEntry>(), 0, 0); InvokeSuccessHandler(purged); InvokeDidNotPassFilterHandler(purged); return(queryLength); }
public FingerprintQueryBuilder(IFingerprintUnitBuilder fingerprintUnitBuilder, IQueryFingerprintService queryFingerprintService, IMinHashService minHashService) { this.fingerprintUnitBuilder = fingerprintUnitBuilder; this.queryFingerprintService = queryFingerprintService; this.minHashService = minHashService; }
private async Task <double> QueryAndHash(CancellationToken cancellationToken, IQueryFingerprintService service) { var realtimeSamplesAggregator = new RealtimeAudioSamplesAggregator(configuration.Stride, MinSamplesForOneFingerprint); var resultsAggregator = new StatefulRealtimeResultEntryAggregator(configuration.ResultEntryFilter, configuration.PermittedGap); double queryLength = 0d; while (!realtimeCollection.IsFinished && !cancellationToken.IsCancellationRequested) { AudioSamples audioSamples; try { if (!realtimeCollection.TryTake(out audioSamples, configuration.MillisecondsDelay, cancellationToken)) { continue; } } catch (OperationCanceledException) { return(queryLength); } if (audioSamples.SampleRate != SupportedFrequency) { throw new ArgumentException($"{nameof(audioSamples)} should be provided down sampled to {SupportedFrequency}Hz"); } queryLength += audioSamples.Duration; var prefixed = realtimeSamplesAggregator.Aggregate(audioSamples); var hashes = await CreateQueryFingerprints(fingerprintCommandBuilder, prefixed); InvokeHashedFingerprintsCallback(hashes); if (!TryQuery(service, hashes, out var queryResults)) { continue; } foreach (var queryResult in queryResults) { var aggregatedResult = resultsAggregator.Consume(queryResult.ResultEntries, prefixed.Duration); InvokeSuccessHandler(aggregatedResult); InvokeDidNotPassFilterHandler(aggregatedResult); } } return(queryLength); }