NeuralCodecs 0.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package NeuralCodecs --version 0.1.0
NuGet\Install-Package NeuralCodecs -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NeuralCodecs" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NeuralCodecs --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NeuralCodecs, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NeuralCodecs as a Cake Addin #addin nuget:?package=NeuralCodecs&version=0.1.0 // Install NeuralCodecs as a Cake Tool #tool nuget:?package=NeuralCodecs&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NeuralCodecs
NeuralCodecs is a .NET library for neural audio codec implementations, designed for efficient audio compression and reconstruction.
Features
Work In Progress
- DAC: Descript Audio Codec
Requirements
- Torchsharp or libTorch targeting your desired platform
Usage
Creating/loading the model
There are several ways to load a model:
- Using static factory method:
// Load SNAC model with static method provided for built-in models
var model = await NeuralCodecs.CreateSNACAsync("model.pt");
Using premade config:
SnacConfig provides premade configurations for 24kHz, 32kHz, and 44kHz sampling rates.
var model = await NeuralCodecs.CreateSNACAsync(modelPath, SNACConfig.SNAC24Khz);
Using IModelLoader instance with default config
Allows the use of custom loader implementations
// Load model with default config from IModelLoader instance
var torchLoader = NeuralCodecs.CreateTorchLoader();
var model = await torchLoader.LoadModelAsync<SNAC, SNACConfig>("model.pt");
Using IModelLoader instance with custom config:
var config = new SNACConfig { /* ... */ };
var model = await torchLoader.LoadModelAsync<SNAC, SNACConfig>("model.pt", config);
Using factory method for custom models:
Allows the use of custom model implementations with built-in loaders
// Load custom model with factory method
var model = await torchLoader.LoadModelAsync<CustomModel, CustomConfig>(
"model.pt",
config => new CustomModel(config, ...),
config);
Encoding and Decoding Audio
There are two main ways to process audio:
- Using the simplified ProcessAudio method:
// Compress audio in one step
var processedAudio = model.ProcessAudio(audioData, sampleRate);
- Using separate encode and decode steps:
// Encode audio to compressed format
var codes = model.Encode(buffer);
// Decode back to audio
var processedAudio = model.Decode(codes);
Saving the processed audio
Use your preferred method to save WAV files
// using NAudio
await using var writer = new WaveFileWriter(
outputPath,
new WaveFormat(model.Config.SamplingRate, 1)
);
writer.WriteSamples(processedAudio, 0, processedAudio.Length);
Acknowledgments
- SNAC - Original SNAC implementation
- Descript Audio Codec - DAC reference
Contributing
Suggestions and contributions are welcome! Feel free to submit a pull request.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- TorchSharp (>= 0.103.1)
- TorchSharp.PyBridge (>= 1.4.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.