Skip to content

Commit a327cd8

Browse files
committed
minor refactor for csharp binding test
1 parent 6f339a8 commit a327cd8

File tree

4 files changed

+8
-2165
lines changed

4 files changed

+8
-2165
lines changed

binding/dotnet/PorcupineTest/MainTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,17 @@ public void TestProcess()
5656

5757
Assert.IsTrue(File.Exists(modelFilePath), $"File.Exists(modelFilePath) --> {modelFilePath}");
5858
keywordPaths.ForEach(keywordFilePath => Assert.IsTrue(File.Exists(keywordFilePath), $"File.Exists(keywordFilePath) --> {keywordFilePath}"));
59-
Console.WriteLine(keywordPaths);
6059
Porcupine p = new Porcupine(modelFilePath, keywordPaths: keywordPaths, sensitivities: sensitivities);
61-
WAVFile file = new WAVFile();
62-
file.Open("multiple_keywords.wav", WAVFile.WAVFileMode.READ);
63-
Assert.AreEqual(p.SampleRate(), file.AudioFormat.SampleRateHz, "The samplerate is not equal!!!");
60+
6461
List<short> data = new List<short>();
65-
while (file.NumSamplesRemaining > 0)
66-
{
67-
data.Add(BitConverter.ToInt16(file.GetNextSample_ByteArray()));
62+
using (BinaryReader reader = new BinaryReader(File.Open("multiple_keywords.wav", FileMode.Open))) {
63+
reader.ReadBytes(44);
64+
65+
while (reader.BaseStream.Position != reader.BaseStream.Length) {
66+
data.Add(reader.ReadInt16());
67+
}
6868
}
69+
6970
int framecount = (int)Math.Floor((decimal)(data.Count / p.FrameLength()));
7071
var results = new List<int>();
7172
for (int i = 0; i < framecount; i++)
@@ -77,7 +78,6 @@ public void TestProcess()
7778
if (result >= 0)
7879
{
7980
results.Add(result);
80-
Console.WriteLine(result);
8181
}
8282
}
8383

0 commit comments

Comments
 (0)