1
0

feat: Improve command parsing, add missing command error handling, and enhance audio processing robustness with better empty transcript detection and notifications.

This commit is contained in:
2026-02-26 22:17:08 +01:00
parent d60730c4bf
commit 4ee4bc5457
2 changed files with 16 additions and 4 deletions

View File

@@ -9,7 +9,11 @@ bool pipeToStdout = args.Contains("--pipe") || args.Contains("-p") || Console.Is
bool copyToClipboard = args.Contains("--copy");
string command = args.FirstOrDefault(a => !a.StartsWith("-")) ?? "";
string command = "";
if (args.Length > 0 && !args[0].StartsWith("-"))
{
command = args[0];
}
if (args.Contains("-h") || args.Contains("--help") || (string.IsNullOrEmpty(command) && args.Length == 0))
{
@@ -30,9 +34,9 @@ if (args.Contains("-h") || args.Contains("--help") || (string.IsNullOrEmpty(comm
if (string.IsNullOrEmpty(command))
{
command = "toggle";
Console.WriteLine("Error: Please specify a command (e.g. 'toggle'). Use 'toak --help' for usage.");
return;
}
if (command == "onboard")
{
var config = ConfigManager.LoadConfig();
@@ -268,9 +272,10 @@ if (command == "toggle")
// 1. STT
var transcript = await groq.TranscribeAsync(wavPath, config.WhisperLanguage, config.WhisperModel);
if (string.IsNullOrWhiteSpace(transcript))
{
if (!pipeToStdout) Notifications.Notify("Toak", "Could not transcribe audio.");
if (!pipeToStdout) Notifications.Notify("Toak", "No speech detected.");
return;
}
@@ -280,6 +285,12 @@ if (command == "toggle")
var systemPrompt = PromptBuilder.BuildPrompt(config);
finalText = await groq.RefineTextAsync(transcript, systemPrompt, config.LlmModel);
if (string.IsNullOrWhiteSpace(finalText))
{
if (!pipeToStdout) Notifications.Notify("Toak", "Dropped short or empty audio.");
return;
}
// 3. Output
if (pipeToStdout)
{