Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Deep Learning for Audio in CSharp and Keras

License

NotificationsYou must be signed in to change notification settings

machine-proxy/csharp-deep-learning-audio

Repository files navigation

Deep Learning for Audio in CSharp and Keras

Environment Configuration Before Install

The packages runs in x64 and built with .NET 4.6.1. Therefore you need to

  • Set the "Target framework" to ".NET Framework 4.6.1" in the Application tab of your project Properties
  • Set the "Platform Target" to x64 in the Build tab of your project Properties
  • Set the .NET configuration manager to x64 in Visual Studio IDE

Install

Make sure that you have the following installed:

  • TensorFlowSharp Version 1.7.0 (used to run the tensorflow audio classifier trained models)

Run the following command in your nuget manager console:

Install-Package TensorFlow-Deep-Music -Version 1.0.3

The following dlls are also installed when installing the TensorFlow-Deep-Music:

  • Bass.NET Version 1.0.0 (used to convert audio file to melgram)
  • System.ValueTuple Version 4.4.0 (required by TensorFlowSharp)

Usage

Audio Encoder and Audio Classifier

Below is thecode showing how to useAudioClassifierto predict the genres of an audio file:

usingSystem;usingcsharp_deep_learning_audio;usingSystem.IO;namespacecsharp_deep_learning_audio_samples{classProgram{staticvoidMain(string[]args){AudioClassifierc=newAudioClassifier();stringdataDirPath=@"C:\Users\chen0\git\csharp-deep-learning-audio\gtzan\genres";string[]subDirectories=Directory.GetDirectories(dataDirPath);foreach(stringsubDirectoryinsubDirectories){string[]files=Directory.GetFiles(subDirectory,"*.au");foreach(stringfileinfiles){Console.WriteLine("classifing: {0}",file);Console.WriteLine("predicted: {0}",c.PredictLabel(file));break;}}}}}

Audio Search Engine

Below is thecode showing how to index music files and perform query to find similar songs:

usingSystem;usingcsharp_deep_learning_audio;usingSystem.IO;usingSystem.Collections.Generic;namespacecsharp_deep_learning_audio_samples{classSearchEngineDemo{publicstaticvoidDemo(){AudioSearchEnginec=newAudioSearchEngine();stringdataDirPath=Path.Combine(IOUtils.AssemblyDirectory,"..","..","..","..","gtzan","genres");string[]subDirectories=Directory.GetDirectories(dataDirPath);foreach(stringsubDirectoryinsubDirectories){string[]files=Directory.GetFiles(subDirectory,"*.au");foreach(stringfileinfiles){c.IndexAudio(file);}}inttopK=10;List<ComparableAudioEntry>result=c.Query(Path.Combine(IOUtils.AssemblyDirectory,"..","..","..","..","music-samples","example.mp3"),topK);for(inti=0;i<result.Count;++i){Console.WriteLine("#{0} (Score: {1}): {2}",i+1,result[i].Distance,result[i].AudioFile);}}}}

About

Deep Learning for Audio in CSharp and Keras

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp