arun-mani-j / libmars

A simple library for audio chunking and processing using GStreamer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mars

A simple library for audio chunking and processing using GStreamer.

Getting Started

You need GStreamer for the usage. Meson can be used to build the project.

$ git clone git@github.com:arun-mani-j/libmars.git
$ cd libmars
$ meson setup _build/ # Setup build directory
$ meson compile -C _build/ # Compile the project

MarsChunker

Chunks the incoming audio stream by silence and duration.

Example

Suppose you want to chunk a file in data/sample.wav and save its output in /output directory, then you can use the following command.

$ mkdir -p output # Create the directory if it does not exist
$ _build/examples/chunker -i "data/sample.wav" -o "output/%02d.wav" -m "wavenc"

Pass "mic" to input, if you want to read from the default mic.

By default, the chunking happens if the audio segment size crosses 7 seconds.

Customization

Chunker relies on GStreamer to do all the heavy-lifting. To improve the output, you should try tweaking the properties of removesilence and splitmuxsink elements.

You can do the customization by modifying the properties of MarsChunker.

MarsCallbackSink

A sink that calls a given callback for every buffer it gets. Similarly, it can aggregate the buffers and call them when the stream ends.

Example

The following example prints the number of buffers the sink received.

$ _build/examples/callback-sink -i "data/sample.wav" -m "wavenc"

Pass "mic" to input, if you want to read from the default mic.

Library

You can use libmars.so in your application. See examples/ for a demonstration.

G-I Support

Mars supports GNOME Introspection. So you can use it in all the languages supported by G-I which includes Python, Rust, Vala etc.

See examples/chunker.py for an example.

References

  1. removesilence - GStreamer element to detect and remove silence.
  2. splitmuxsink - GStreamer element to split the files.

About

A simple library for audio chunking and processing using GStreamer.


Languages

Language:C 95.6%Language:Meson 4.4%