Skip to content
/ sonant Public

Sonant is a simple C++ wrapper for recording audio with ALSA and transcribing with Whisper.cpp library.

License

Notifications You must be signed in to change notification settings

lulkien/sonant

Repository files navigation

Sonant

Sonant is a simple C++ wrapper for recording audio with ALSA and transcribing with Whisper.cpp library.

Dependencies

  • ALSA
  • Whisper.cpp
  • CMake

System Requirements

  • Linux-based operating system (tested on Ubuntu and Arch Linux)
  • C++14 or later

Installation

Install ALSA Library

Ubuntu

sudo apt-get install libasound2-dev

Arch Linux

sudo pacman -S alsa-lib

Install Whisper.cpp from Source

git clone https://github.com/ggerganov/whisper.cpp.git
cd whisper.cpp
mkdir build
cd build
cmake ..
make -j
sudo make install

Install Sonant from Source

git clone https://github.com/lulkien/sonant.git
cd sonant
mkdir build
cd build
cmake ..
make -j
sudo make install

How to use

Include the header file, create a Sonant object, initialize it with your Whisper model, start the recorder, and handle the transcription in your callback.

#include <iostream>
#include <sonant.h>

int main() {
    Sonant sonant;

    if (!sonant.initialize("/path/to/your/whisper/model")) {
        std::cerr << "Failed to initialize Sonant" << std::endl;
        return -1;
    }

    sonant.setTranscriptionCallback([](const std::string& transcription) {
        std::cout << "Transcription: " << transcription << std::endl;
    });

    if (!sonant.startRecorder()) {
        std::cerr << "Failed to start recording" << std::endl;
        return -1;
    }

    // Your application logic here

    sonant.terminate();
    return 0;
}

Note:

Always call terminate() before your application exits to ensure proper cleanup.

License

This project is released into the public domain under the Unlicense.

About

Sonant is a simple C++ wrapper for recording audio with ALSA and transcribing with Whisper.cpp library.

Resources

License

Stars

Watchers

Forks