Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .workshop/spiel-snaps/hooks/setup-base
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,29 @@
set -euo pipefail

# Build/test dependencies
apt-get update
apt-get install --yes --no-install-recommends bc jq make pulseaudio pulseaudio-utils yq
apt-get -o Acquire::Retries=3 --error-on=any update
apt-get -o Acquire::Retries=3 install --yes --no-install-recommends bc dbus-bin jq make pulseaudio pulseaudio-utils yq

# Set up snapd
systemctl start snapd.socket
systemctl enable snapd.socket
systemctl start snapd
snap wait system seed.loaded
# Enable feature flag needed for speech-provider-* snaps to run as user daemons
snap set system experimental.user-daemons=true
# Install some large base snaps to avoid downloading them during the test
snap install snapd core26
# Install some large base snaps to avoid downloading them during the test.
# snapd gives up on the store after under a minute of retries, so retry for
# longer to ride out a brief outage, logging what failed each time. Snaps a
# failed attempt did install are skipped by the next one.
attempts=5
for ((attempt = 1; ; attempt++)); do
snap install snapd core26 && break
echo "setup-base: snap install failed (attempt $attempt of $attempts)" >&2
snap debug connectivity >&2 || true
getent ahosts api.snapcraft.io >&2 || echo "setup-base: cannot resolve api.snapcraft.io" >&2
((attempt < attempts)) || exit 1
sleep 30
done

# Environment variables needed for spiel to find the dbus and pulseaudio
# sockets. Snaps run with a snap-specific XDG_RUNTIME_DIR one level below
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Build and install spiel-enabled orca and the piper speech provider (which bundle
make SNAPS="speech-provider-piper orca-spiel" build
workshop launch audible
workshop connect audible/spiel-snaps:pulse-native audible/system:pulse-native
workshop run audible install speech-provider-piper orca-spiel
workshop run audible speak en_GB-alan-medium fr_FR-siwis-medium
workshop run --env PIPER_VOICES="en_GB-alan-medium fr_FR-siwis-medium" audible test
```

Snap names are the directories containing a `snapcraft.yaml` file; make's build and clean targets, and every workshop action that takes snap names, act on all of them when none are given.
Expand All @@ -41,7 +40,11 @@ host: `snapcraft login`).

## Testing

End-to-end validation runs inside one of the project's [Canonical Workshops](https://github.com/canonical/workshop) (`.workshop/`): Ubuntu 26.04 LXD containers whose base image -- snapd, the base snaps, and the build tools -- is set up once by the SDK's `setup-base` hook and then reused by Workshop on every test run. Both workshops run the same test (it installs the snaps from `output/snaps`, connects the interfaces, and speaks with every piper voice); they differ only in where the audio goes.
End-to-end validation runs inside one of the project's [Canonical Workshops](https://github.com/canonical/workshop) (`.workshop/`): Ubuntu 26.04 LXD containers whose base image -- snapd, the base snaps, and the build tools -- is set up once by the SDK's `setup-base` hook and then reused by Workshop on every test run. Both workshops run the same test (it installs the snaps from `output/snaps`, connects the interfaces, and speaks with every Piper voice), verifying the requested voice reaches Piper. The silent workshop also captures the null-sink output and checks that it contains audio; the audible workshop plays through the host without recording it.

Each Piper speech command has a five-minute timeout, allowing time for cold
startup and model loading. A timeout fails the test and stops Spiel, the D-Bus
monitor, and (in silent mode) the recorder.

### silent

Expand All @@ -63,7 +66,7 @@ make SNAPS="speech-provider-piper orca-spiel" build
workshop run audible test
```

Run `workshop refresh <name>` after changing the workshop definitions or the SDK's hooks, and `workshop restore <name>` to reset a workshop to its freshly-set-up base state. Inside a workshop shell, the actions' scripts live in `tasks/`.
Run `workshop refresh <name>` after changing the workshop definitions or the SDK's hooks (for example, to install `dbus-bin`), and `workshop restore <name>` to reset a workshop to its freshly-set-up base state. Inside a workshop shell, the actions' scripts live in `tasks/`.

### Speaking voices

Expand Down
8 changes: 4 additions & 4 deletions orca-spiel/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugs:

apps:
orca:
command: bin/orca-launch
command: usr/bin/orca-launch
environment:
LD_LIBRARY_PATH: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/pulseaudio:$LD_LIBRARY_PATH
PULSE_SERVER: unix:$XDG_RUNTIME_DIR/../pulse/native
Expand Down Expand Up @@ -59,12 +59,12 @@ parts:
orca-launcher:
plugin: nil
override-build: |
install -d "$CRAFT_PART_INSTALL/bin"
cat > "$CRAFT_PART_INSTALL/bin/orca-launch" << 'EOF'
install -d "$CRAFT_PART_INSTALL/usr/bin"
cat > "$CRAFT_PART_INSTALL/usr/bin/orca-launch" << 'EOF'
#!/bin/sh
exec "$SNAP/usr/bin/python3" "$SNAP/usr/bin/orca" "$@"
EOF
chmod 0755 "$CRAFT_PART_INSTALL/bin/orca-launch"
chmod 0755 "$CRAFT_PART_INSTALL/usr/bin/orca-launch"

orca:
plugin: meson
Expand Down
9 changes: 4 additions & 5 deletions tasks/check_piper_manifest.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env bash
#
# Checks that the committed Piper snap manifest is up to date: runs the
# manifest generator's unit tests, regenerates the manifest from the current
# voices.yaml, and diffs it against the committed
# speech-provider-piper/snapcraft.yaml.
# Checks the Piper speech tests and that the committed snap manifest is up to
# date with voices.yaml.
#
# Runs inside one of the project's Canonical Workshops (see .workshop/),
# which provide yq:
Expand All @@ -17,7 +15,8 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR/.."

python3 tasks/test_generate_snapcraft.py
python3 -B tasks/test_generate_snapcraft.py
python3 -B tasks/test_piper_speech.py

temp_dir="$(mktemp -d)"
trap 'rm -rf "$temp_dir"' EXIT
Expand Down
Loading
Loading