An audio converter api
Carubbi Audio Converter API is a modular and secure API built with ASP.NET Core to convert audio files between popular formats such as MP3, WAV, and OGG. The API ensures file validation, efficient processing, and extensibility for future formats.
.mp3
, .wav
, .ogg
).IConverter
interface.opusenc
and opusdec
for OGG encoding/decoding.NAudio
and NAudio.Lame
for MP3 and WAV processing.opusenc.exe
and opusdec.exe
available in the environment’s PATH (for OGG conversions).Clone the repository:
git clone https://github.com/rcarubbi/Carubbi-AudioConverter-Api.git
cd Carubbi-AudioConverter-Api
Install dependencies:
NAudio
and NAudio.Lame
packages are installed:
dotnet add package NAudio
dotnet add package NAudio.Lame
opusenc.exe
and opusdec.exe
binaries to your PATH environment variable.Run the API:
dotnet run
Access the Swagger UI:
https://localhost:<port>/swagger
to test the API endpoints interactively.Converts an uploaded audio file to the desired format.
to
: The desired output format (mp3
, wav
, or ogg
).source
: The audio file to convert.
curl -X POST "https://localhost:<port>/Conversion?to=ogg" \
-H "Content-Type: multipart/form-data" \
-F "source=@example.mp3" \
--output result.ogg
Each uploaded file goes through a validation process:
The API uses a modular pipeline approach for audio conversion. It determines the necessary converters based on input and output formats and chains them together when intermediate steps are needed (e.g., MP3 → WAV → OGG).
NAudio.Wave
).opusenc
).To add a new format:
Implement the IConverter
interface:
public class NewFormatConverter : IConverter
{
public string From => "existingFormat";
public string To => "newFormat";
public async Task<byte[]> ConvertAsync(byte[] content)
{
// Conversion logic here
}
}
Register the converter in Startup.cs
:
services.AddTransient<IConverter, NewFormatConverter>();
Contributions are welcome! Please fork the repository, create a new branch, and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
Check out the repository: Carubbi Audio Converter API