add usage

This commit is contained in:
Emil Lerch 2025-10-07 14:14:05 -07:00
parent 6148c30dbc
commit 15522c41a8
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -323,9 +323,26 @@ pub fn main() !void {
var model_path: ?[]const u8 = null; var model_path: ?[]const u8 = null;
var exec_program: ?[]const u8 = null; var exec_program: ?[]const u8 = null;
// Parse --model and --exec arguments // Parse arguments
for (args[1..]) |arg| { for (args[1..]) |arg| {
if (std.mem.startsWith(u8, arg, "--model=")) { if (std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) {
_ = try stdout.writeAll("Real-time Speech Recognition\n\n");
_ = try stdout.writeAll("USAGE:\n");
_ = try stdout.writeAll(" stt [OPTIONS]\n\n");
_ = try stdout.writeAll("OPTIONS:\n");
_ = try stdout.writeAll(" --model=<path> Path to Vosk model directory\n");
_ = try stdout.writeAll(" --exec=<program> Program to execute with recognized text\n");
_ = try stdout.writeAll(" --help, -h Show this help message\n\n");
_ = try stdout.writeAll("EXAMPLES:\n");
_ = try stdout.writeAll(" stt\n");
_ = try stdout.writeAll(" stt --model=vosk-model-small-en-us-0.15\n");
_ = try stdout.writeAll(" stt --exec=echo\n\n");
_ = try stdout.writeAll("The application will search for models in these locations:\n");
_ = try stdout.writeAll(" vosk-model-small-en-us-0.15\n");
_ = try stdout.writeAll(" zig-out/bin/vosk-model-small-en-us-0.15\n");
_ = try stdout.writeAll(" /usr/share/vosk/models/vosk-model-small-en-us-0.15\n");
return;
} else if (std.mem.startsWith(u8, arg, "--model=")) {
model_path = arg[8..]; // Skip "--model=" model_path = arg[8..]; // Skip "--model="
} else if (std.mem.startsWith(u8, arg, "--exec=")) { } else if (std.mem.startsWith(u8, arg, "--exec=")) {
exec_program = arg[7..]; // Skip "--exec=" exec_program = arg[7..]; // Skip "--exec="