Speech Recognition Configuration Provider For ASP.NET Core

Written by Khalid Abuhakmeh
2
This post is days old.

The ASP.NET Monsters recently announced a competition to create configuration providers for ASP.NET Core, but they are not just looking for your grandmother’s configuration provider.

The Summer of Config is all about creating the wackiest, most insane configuration provider that you can dream up. We want you jammin’ on the ASP.NET Core code, bringing us your questions, experimenting with the code and seeing your creativity. BRING IT ON!

Challenge accepted.

Speech Configuration Provider

The configuration provider I wrote uses the SpeechRecognitionEngine found in the .NET framework to transcribe audio files into text. Each audio file is added to the configuration builder and processed when Build is called, with the filename being the key and the transcription being the value.

public Startup(IHostingEnvironment env)
{
    var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddImageFile(null, "config\\config.jpg", "config\\config.jpg.regions", false, true)
        .AddSpeech("config\\NotFoundMessage.wav", true, true)
        .AddEnvironmentVariables();

    Configuration = builder.Build();
}

The audio file says “This is ridiculous.” Listen to it below.

And the results are:

results asp.net core configuration provider speech

If you’d like to try it yourself, you can go to the GitHub repository.

Suggested reading

Comments