I am developing a voice recognition software and one of the requirements for the voice recognition engine is a wave stream. The function is recognition engine.setInputToWaveStream(Stream audioSource)
So I have started looking into how to get a a wave file from a webpage using memorystream. This is my current code.
using (WebClient webClient = new WebClient())
{
byte[] data = webClient.DownloadData(@"http://192.0.2.82:6180/audio.wav");
using (MemoryStream mem = new MemoryStream(data))
{
recEngine.SetInputToWaveStream(mem);
}
}
This is not working so could someone please point me to the right direction. I have tried looking at other resources but most of them are outdated and the NAudio library solutions are not working for me.
It looks like you're passing the data into the MemoryStream where the size of the stream should be declared.
From the docs on
MemoryStream()
Try something like this:
Depending on the format of your .wav data you could also use
mem.WriteByte