VoiceWake: send transcript via python/base64 instead of stdin
parent
98651c2a14
commit
71072f084e
|
|
@ -144,7 +144,10 @@ enum VoiceWakeForwarder {
|
||||||
} else {
|
} else {
|
||||||
cmdTemplate = config.commandTemplate
|
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])
|
args.append(contentsOf: ["sh", "-c", shellCommand])
|
||||||
|
|
||||||
let debugCmd = (["/usr/bin/ssh"] + args).joined(separator: " ")
|
let debugCmd = (["/usr/bin/ssh"] + args).joined(separator: " ")
|
||||||
|
|
@ -156,8 +159,6 @@ enum VoiceWakeForwarder {
|
||||||
process.executableURL = URL(fileURLWithPath: "/usr/bin/ssh")
|
process.executableURL = URL(fileURLWithPath: "/usr/bin/ssh")
|
||||||
process.arguments = args
|
process.arguments = args
|
||||||
|
|
||||||
let input = Pipe()
|
|
||||||
process.standardInput = input
|
|
||||||
let output = Pipe()
|
let output = Pipe()
|
||||||
process.standardOutput = output
|
process.standardOutput = output
|
||||||
process.standardError = output
|
process.standardError = output
|
||||||
|
|
@ -169,11 +170,6 @@ enum VoiceWakeForwarder {
|
||||||
return .failure(.launchFailed(error.localizedDescription))
|
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)
|
let out = await self.wait(process, timeout: config.timeout)
|
||||||
if process.terminationStatus == 0 {
|
if process.terminationStatus == 0 {
|
||||||
self.logger.info("voice wake forward ok host=\(userHost, privacy: .public)")
|
self.logger.info("voice wake forward ok host=\(userHost, privacy: .public)")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue