Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: select published Piper archives by platform (#9807)

Adam Eivyd1d26db39e80
diff --git a/scripts/setup-voice.sh b/scripts/setup-voice.sh
index aff382b5ec..06fe72808d 100755
--- a/scripts/setup-voice.sh
+++ b/scripts/setup-voice.sh
@@ -93,9 +93,16 @@ PIPER_LIB="${PIPER_DIR}/lib"
if [[ "$TTS_ENGINE" == "piper" ]]; then
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
- [[ "$OS" == "darwin" ]] && OS="macos"
- [[ "$ARCH" == "arm64" ]] && ARCH="aarch64"
- [[ "$ARCH" == "x86_64" ]] && ARCH="x64"
+ case "$OS/$ARCH" in
+ darwin/x86_64) OS="macos"; ARCH="x64" ;;
+ darwin/arm64|darwin/aarch64) OS="macos"; ARCH="aarch64" ;;
+ linux/x86_64) ARCH="x86_64" ;;
+ linux/arm64|linux/aarch64) ARCH="aarch64" ;;
+ *)
+ echo "❌ Unsupported Piper platform: ${OS}/${ARCH}" >&2
+ exit 1
+ ;;
+ esac
if [[ ! -x "${PIPER_DIR}/piper" ]]; then
PIPER_VERSION="2023.11.14-2"
diff --git a/scripts/setup-voice.test.js b/scripts/setup-voice.test.js
index 6a2fa1ffd2..162917cc9f 100644
--- a/scripts/setup-voice.test.js
+++ b/scripts/setup-voice.test.js
@@ -29,6 +29,10 @@ if [[ $head == 1 ]]; then
printf 'HTTP/2 200\\r\\ncontent-length: %s\\r\\n\\r\\n' "$CURL_REMOTE_SIZE"
exit 0
fi
+if [[ -z "$dest" ]]; then
+ printf 'archive'
+ exit 0
+fi
if [[ -n "\${CURL_FAIL_MATCH:-}" && "$url" == *"\${CURL_FAIL_MATCH}"* ]]; then
printf 'partial' > "$dest"
exit 18
@@ -39,6 +43,32 @@ case "$url" in
*) printf 'whisper-%s' "\${CURL_TAG:-v1}" > "$dest" ;;
esac
`;
+const UNAME_STUB = `#!/usr/bin/env bash
+case "$1" in
+ -s) printf '%s\\n' "\${FAKE_UNAME_S:-Linux}" ;;
+ -m) printf '%s\\n' "\${FAKE_UNAME_M:-x86_64}" ;;
+ *) exit 2 ;;
+esac
+`;
+const TAR_STUB = `#!/usr/bin/env bash
+dest=""
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -C) dest="$2"; shift 2 ;;
+ *) shift ;;
+ esac
+done
+cat >/dev/null
+if [[ "$dest" == *"/.portos/voice" ]]; then
+ mkdir -p "$dest/piper"
+ printf '#!/bin/sh\\n' > "$dest/piper/piper"
+ chmod +x "$dest/piper/piper"
+else
+ mkdir -p "$dest/piper-phonemize/lib"
+ : > "$dest/piper-phonemize/lib/libpiper_phonemize.so"
+ : > "$dest/piper-phonemize/lib/libpiper_phonemize.dylib"
+fi
+`;
describe.skipIf(process.platform === 'win32')('setup-voice.sh model provisioning', () => {
let home;
@@ -72,6 +102,10 @@ describe.skipIf(process.platform === 'win32')('setup-voice.sh model provisioning
mkdirSync(stubDir);
writeFileSync(join(stubDir, 'curl'), CURL_STUB);
chmodSync(join(stubDir, 'curl'), 0o755);
+ writeFileSync(join(stubDir, 'uname'), UNAME_STUB);
+ chmodSync(join(stubDir, 'uname'), 0o755);
+ writeFileSync(join(stubDir, 'tar'), TAR_STUB);
+ chmodSync(join(stubDir, 'tar'), 0o755);
log = join(home, 'curl.log');
// Pretend the Piper binary and its libs are already installed.
const piper = join(home, '.portos/voice/piper');
@@ -98,6 +132,28 @@ describe.skipIf(process.platform === 'win32')('setup-voice.sh model provisioning
expect(inspectVoiceAsset('piper', onnx()).state).toBe('verified');
});
+ it.each([
+ ['Linux', 'x86_64', 'linux_x86_64'],
+ ['Darwin', 'x86_64', 'macos_x64'],
+ ['Linux', 'aarch64', 'linux_aarch64'],
+ ['Darwin', 'arm64', 'macos_aarch64'],
+ ])('selects published Piper and phonemize archives for %s/%s', (system, machine, suffix) => {
+ rmSync(join(home, '.portos/voice/piper'), { recursive: true, force: true });
+ const result = run({ FAKE_UNAME_S: system, FAKE_UNAME_M: machine });
+ expect(result.status, `${result.stdout}\n${result.stderr}`).toBe(0);
+ const urls = downloads().join('\n');
+ expect(urls).toContain(`piper_${suffix}.tar.gz`);
+ expect(urls).toContain(`piper-phonemize_${suffix}.tar.gz`);
+ });
+
+ it('rejects an unsupported platform before requesting an archive', () => {
+ rmSync(join(home, '.portos/voice/piper'), { recursive: true, force: true });
+ const result = run({ FAKE_UNAME_S: 'FreeBSD', FAKE_UNAME_M: 'x86_64' });
+ expect(result.status).not.toBe(0);
+ expect(result.stderr).toContain('Unsupported Piper platform: freebsd/x86_64');
+ expect(downloads()).toEqual([]);
+ });
+
it('repairs a poisoned ONNX with no sidecar instead of reporting ready', () => {
mkdirSync(voices, { recursive: true });
writeFileSync(onnx(), 'partial');