diff --git a/Core/PromptBuilder.cs b/Core/PromptBuilder.cs index 4e8077d..eafe4f0 100644 --- a/Core/PromptBuilder.cs +++ b/Core/PromptBuilder.cs @@ -22,6 +22,7 @@ public static class PromptBuilder sb.AppendLine("5. Output ONLY the finalized text. You must not include any introductory remarks, confirmations, explanations, apologies, leading/trailing quotes, metadata, or the tags themselves in your output."); sb.AppendLine(); sb.AppendLine("FORMATTING RULES:"); + sb.AppendLine("- CRITICAL: If the contains nothing, or very short gibberish, output NOTHING AT ALL (an empty string)."); diff --git a/Program.cs b/Program.cs index f4ecf7d..3eb41cc 100644 --- a/Program.cs +++ b/Program.cs @@ -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) {