A simple library for audio chunking and processing using GStreamer.
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
Chunks the incoming audio stream by silence and duration.
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.
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
.
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.
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.
You can use libmars.so
in your application. See examples/
for a demonstration.
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.
removesilence
- GStreamer element to detect and remove silence.splitmuxsink
- GStreamer element to split the files.