microsoft / psi

Platform for Situated Intelligence
https://github.com/microsoft/psi/wiki
Other
542 stars 97 forks source link

Sixth code box in intro tutorial won't compile #14

Closed abegel closed 6 years ago

abegel commented 6 years ago

In the tutorial at https://microsoft.github.io/psi/tutorials/, the sixth code box that creates an audio pipeline for voice activity detection, won't compile. The tutorial should direct the user to add the Microsoft.Psi.Audio.Windows NuGet package. However, this package is not compatible with a .NET Core Console Application (which is what the tutorial directs the reader to create at the beginning); it requires .NET 4.7. So, to make this example work, the user has to create a new Console App with .NET 4.7, install the Microsoft.Psi.Runtime, Microsoft.Psi.Audio.Windows, and Microsoft.Psi.Speech.Windows NuGet packages. Then they have to add using Microsoft.Psi.Audio and using Microsoft.Psi.Speech to their C# code file, and then try out the code.

It might be worth explaining more about how the code picks a microphone to listen to and whether that detector should output anything at all while it runs if it doesn't hear anything. (maybe just test instructions would help).

AshleyF commented 6 years ago

Thank you very much for pointing this out! You're correct, AudioCapture requires .NET 4.7 (on Windows at least - the Linux AudioSource is .NET Standard).

To keep things simple, we will be updating this code sample to have only on .NET Standard dependencies and no hardware requirements (using a simple .wav file and AcousticFeatures component):

using (var p = Pipeline.Create())
{
    // Create an audio source component
    var waveFileAudioSource = new WaveFileAudioSource(p, "sample.wav");

    // Create an acoustic features component
    var acousticFeatures = new AcousticFeatures(p);

    // Pipe the output of the wave file audio source component into the input of the acoustic features
    waveFileAudioSource.Out.PipeTo(acousticFeatures.In);

    // Process the output of the acoustic features and print the messages to the console
    acousticFeatures.SpectralEntropy.Do(s => Console.WriteLine($"SpectralEntropy: {s}"));
    acousticFeatures.LogEnergy.Do(e => Console.WriteLine($"LogEnergy: {e}"));

    // Run the pipeline
    p.Run();
}

Also, a more complete explanation of audio capture (picking a microphone, etc.) and the voice activity detector behavior will be coming as well in docs specific to those components. We'll keep the Brief Introduction indeed brief for now.

Thanks again!