-
Notifications
You must be signed in to change notification settings - Fork 4
/
SearchEngineDemo.cs
41 lines (32 loc) · 1.18 KB
/
SearchEngineDemo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using csharp_deep_learning_audio;
using System.IO;
using System.Collections.Generic;
namespace csharp_deep_learning_audio_samples
{
class SearchEngineDemo
{
public static void Demo()
{
AudioSearchEngine c = new AudioSearchEngine();
string dataDirPath = Path.Combine(IOUtils.AssemblyDirectory, "..", "..", "..", "..", "gtzan", "genres");
string[] subDirectories = Directory.GetDirectories(dataDirPath);
foreach(string subDirectory in subDirectories)
{
string[] files = Directory.GetFiles(subDirectory, "*.au");
foreach(string file in files)
{
c.IndexAudio(file);
}
}
int topK = 10;
List<ComparableAudioEntry> result = c.Query(
Path.Combine(IOUtils.AssemblyDirectory, "..", "..", "..", "..", "music-samples", "example.mp3"),
topK);
for(int i=0; i < result.Count; ++i)
{
Console.WriteLine("#{0} (Score: {1}): {2}", i + 1, result[i].Distance, result[i].AudioFile);
}
}
}
}