VoiceWake: send transcript via python/base64 instead of stdin
This commit is contained in:
@@ -144,7 +144,10 @@ enum VoiceWakeForwarder {
|
||||
} else {
|
||||
cmdTemplate = config.commandTemplate
|
||||
}
|
||||
let shellCommand = "CLAW_TEXT=$(cat); \(self.commandWithCliPath(cmdTemplate, target: destination))"
|
||||
|
||||
let b64 = transcript.data(using: .utf8)?.base64EncodedString() ?? ""
|
||||
let pythonDecode = "PYBIN=$(command -v python3 || command -v python || true); if [ -z \\\"$PYBIN\\\" ]; then echo 'python missing'; exit 127; fi; CLAW_TEXT=$($PYBIN -c \\\"import base64; print(base64.b64decode('" + b64 + "').decode('utf-8'), end='')\\\");"
|
||||
let shellCommand = "PATH=\(cliHelperSearchPaths.joined(separator: ":")); \(pythonDecode) \(self.commandWithCliPath(cmdTemplate, target: destination))"
|
||||
args.append(contentsOf: ["sh", "-c", shellCommand])
|
||||
|
||||
let debugCmd = (["/usr/bin/ssh"] + args).joined(separator: " ")
|
||||
@@ -156,8 +159,6 @@ enum VoiceWakeForwarder {
|
||||
process.executableURL = URL(fileURLWithPath: "/usr/bin/ssh")
|
||||
process.arguments = args
|
||||
|
||||
let input = Pipe()
|
||||
process.standardInput = input
|
||||
let output = Pipe()
|
||||
process.standardOutput = output
|
||||
process.standardError = output
|
||||
@@ -169,11 +170,6 @@ enum VoiceWakeForwarder {
|
||||
return .failure(.launchFailed(error.localizedDescription))
|
||||
}
|
||||
|
||||
if let data = transcript.data(using: .utf8) {
|
||||
input.fileHandleForWriting.write(data)
|
||||
}
|
||||
try? input.fileHandleForWriting.close()
|
||||
|
||||
let out = await self.wait(process, timeout: config.timeout)
|
||||
if process.terminationStatus == 0 {
|
||||
self.logger.info("voice wake forward ok host=\(userHost, privacy: .public)")
|
||||
|
||||
Reference in New Issue
Block a user