# Speex encoder

Media Blocks SDK .Net

Speex: An open-source, patent-free audio codec designed specifically for compressing voice at low bit rates, commonly used in VoIP and audio streaming applications.

Speex encoder is used to encode files in OGG, WebM, MKV, and some other formats.

Use the SpeexEncoderSettings class to set the parameters.

# Block info

Name: SpeexEncoderBlock.

Pin direction Media type Pins count
Input PCM/IEEE 1
Output audio/x-speex 1

# The sample pipeline

graph LR;
    UniversalSourceBlock-->SpeexEncoderBlock;
    SpeexEncoderBlock-->OGGSinkBlock;

# Sample code

var pipeline = new MediaBlocksPipeline();

var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));

var speexEncoderBlock = new SpeexEncoderBlock(new SpeexEncoderSettings());
pipeline.Connect(fileSource.AudioOutput, speexEncoderBlock.Input);

var oggSinkBlock = new OGGSinkBlock(new OGGSinkSettings(@"output.ogg"));
pipeline.Connect(speexEncoderBlock.Output, oggSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio));

await pipeline.StartAsync();

# Platforms

Windows, macOS, Linux, iOS, Android.