package asr import ( "bytes" "context" "os/exec" "syscall" ) // runFunc executes binary with args, feeding stdin, and returns // stdout/stderr. It's a seam so tests can substitute a fake process instead // of requiring the real qwen_asr binary and a multi-GB model on disk. type runFunc func(ctx context.Context, binary string, args []string, stdin []byte) (stdout, stderr []byte, err error) func runCommand(ctx context.Context, binary string, args []string, stdin []byte) ([]byte, []byte, error) { cmd := exec.CommandContext(ctx, binary, args...) cmd.Stdin = bytes.NewReader(stdin) var stdout, stderr bytes.Buffer cmd.Stdout = &stdout cmd.Stderr = &stderr // Run qwen_asr in its own process group so the terminal's Ctrl+C // (SIGINT to the whole foreground process group) doesn't kill an // in-flight transcription directly. It's still cancelable through ctx, // same as before — this only stops the shell from also signaling it. cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} err := cmd.Run() return stdout.Bytes(), stderr.Bytes(), err }