Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ For unauthenticated local endpoints (e.g. Ollama):
- `chatTemplateKwargs` _(optional)_ - extra keyword arguments passed to the model's chat template (e.g. `{"enable_thinking": false}` for Qwen models to disable chain-of-thought)
- `retries` _(optional)_ - number of retry attempts for transient LLM failures
- `tmpDir` _(optional)_ - directory used for the temporary STT recording file (default `/tmp`)
- `trimSilence` _(optional)_ - whether to remove leading silence from recordings (default `true`). Set to `false` if your recordings are missing the first word or syllable

### Logging

Expand Down
7 changes: 4 additions & 3 deletions lib/stt.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function forceKillSox(logger) {
} catch {}
}

function startRecording(kv, toast, logger) {
function startRecording(kv, toast, logger, trimSilence = true) {
if (soxProc) {
logger?.log("STT", "Start recording skipped: sox already running", "debug");
return;
Expand All @@ -132,9 +132,10 @@ function startRecording(kv, toast, logger) {
const inputArgs = mic ? ["-t", "coreaudio", mic] : ["-d"];
logger?.log("STT", `Starting recording mic=${mic || "system default"}`, "debug");

const silenceArgs = trimSilence ? ["silence", "1", "0.1", "1%"] : [];
soxProc = spawn(
"sox",
[...inputArgs, "-r", "16000", "-c", "1", "-b", "16", wavFile, "silence", "1", "0.1", "1%"],
[...inputArgs, "-r", "16000", "-c", "1", "-b", "16", wavFile, ...silenceArgs],
{
stdio: ["ignore", "ignore", "pipe"],
detached: false,
Expand Down Expand Up @@ -517,7 +518,7 @@ export function registerSTT(api, kv, complete, prompts, opts, logger) {
toast("Stopping, transcribing...");
doTranscribePipeline(kv, complete, client, toast, systemPrompt, false, logger);
} else {
startRecording(kv, toast, logger);
startRecording(kv, toast, logger, opts.trimSilence);
if (recording) toast("Recording... press again to transcribe");
}
},
Expand Down