Windows and Linux quick start
The C library for Windows and Linux: how to build it, where the key goes, and the quick start.
The native SDK is a C API for desktop apps and servers on x86-64, on Windows and Linux. There are no prebuilt binaries: the library is built from its release tag with CMake. The source is at github.com/Quran-Lab/tajweedformer-c.
Install
git clone --recurse-submodules --branch 3.1.4 https://github.com/Quran-Lab/tajweedformer-c
cd tajweedformer-c
cmake --preset linux && cmake --build --preset linuxgit clone --recurse-submodules --branch 3.1.4 https://github.com/Quran-Lab/tajweedformer-c
cd tajweedformer-c
cmake --preset windows-clang
cmake --build --preset windows-clangThe key
Use a desktop key. A Windows app is identified by its package family name or AppUserModelID, a Linux app by its reverse-DNS app id. Never compile the key into shared source:
# the environment, or your app's config file
QURANLAB_KEY=qlk_v1_...Client, model, session, read
The C library has no microphone: your app, or the system's recorder, pushes audio in.
#include <stdio.h>
#include "tajweedformer.h"
static void on_chunk(void *user, const TfChunk *chunk) {
(void)user, puts(chunk->decoded->text); /* what the model heard so far */
}
static int recite(const char *key) {
TfClient *client = tf_client_create(
&(TfClientOptions){.key = key, .app_id = "com.example.quickstart"});
TfModel *model = tf_client_model(client, NULL); /* downloaded once, verified, opened */
TfSession *session = tf_session_create(
model, &(TfSessionOptions){.on_chunk = on_chunk, .end_on_silence_ms = 1500});
float samples[1600]; /* mono float, 100 ms at 16 kHz */
size_t n;
while ((n = fread(samples, sizeof *samples, 1600, stdin)) > 0)
if (tf_session_push(session, samples, (int)n) < 0) break;
return tf_session_finish(session);
}Pipe the microphone in as raw mono float samples at 16 kHz. On Windows, run the line in Command Prompt: Windows PowerShell changes raw bytes on their way through a pipe.
arecord -q -f FLOAT_LE -r 16000 -c 1 -t raw | ./quickstart qlk_v1_...ffmpeg -f dshow -i audio="<your microphone>" -ac 1 -ar 16000 -f f32le - | quickstart.exe qlk_v1_...- Options. Every options struct may be
NULLor zeroed; zero is the default of every field. - Errors. A function returns
NULLor a negative code.tf_last_error()is the message,tf_last_error_fix()what to do about it, and the codes are the ones in Errors. - Without a microphone.
tf_session_listenruns one of the sample clips that come with the model through the same path.
What comes back
chunk->decoded is the take so far (the text, each token with its times and confidence), and tf_session_heads(session) gives the take's raw outputs after tf_session_finish. Build your own feedback says what each of them is.
The exact names for your SDK version are in the repository's README and in tajweedformer.h.