Why Choose On-Device Voice AI for the Linux Assistant
Cloud-based voice applications introduce network latency, require constant internet connectivity and raise privacy concerns when your sensitive audio data is sent to remote servers. These limitations can be a bottleneck when building responsive, reliable, and secure applications.
In this tutorial, we will build a voice-powered Linux assistant with Python using Porcupine Wake Word and Rhino Speech-to-Intent. Choosing AI engines with edge-first architecture will make the Linux assistant responsive, private, and reliable, giving full control over the user experience.
Step 1: Create a Custom Wake Word for the Linux Assistant
The AI assistant uses a custom wake word that it can recognize. You can create this custom voice model on the Picovoice Console.
- Log in to the Picovoice Console.
- Go to the Porcupine Wake Word section and create a new wake word.
- Enter a custom phrase, such as "Hey Computer".
For tips on choosing an effective wake word, refer to the guide for choosing a wake word.
- Train the voice model and download it, choosing the Linux platform you're working on, e.g., Linux x86_64.
You will now find a folder in your downloads containing the .ppn keyword file.
Step 2: Create Voice Commands for The Linux Assistant
Once the voice assistant has a wake word, it needs a set of voice commands to understand the user's intent.
- In the Picovoice Console, go to the Rhino Speech-to-Intent tab and create a new Rhino context
- Click the "Import YAML" button in the top-right corner of the Console. Paste the YAML provided below to add the intents and expressions for the Linux assistant.
For detailed instructions, refer to the Rhino Syntax Cheat Sheet.
- Use the microphone button to test your context in-browser. This will save and build the context.
- Once built, download the file choosing the Linux platform.
You will now find a zipped folder in your downloads containing the .rhn context file.
YAML Context for the Linux Assistant:
Step 3: Demo Tools and Packages for the Linux Assistant
The following tools and packages are needed for the demo:
- A Linux machine with Python 3.9 or above, and a working microphone.
- The Rhino Speech-to-Intent Python SDK
pvrhino, the Porcupine Wake Word Python SDKpvporcupineand the Picovoice Python Recorder librarypvrecorder. Install them all with a single command:
- The libnotify-bin package to enable desktop notifications with the
notify-sendcommand:
Step 4: Write the Python Script for the Linux Assistant
With the setup complete, we can now write the code that powers the assistant.
Detect Wake Word and Process Voice Commands in Real Time
The main loop continuously processes audio. Porcupine listens for the wake word, and once detected, Rhino takes over to recognize the user's intent.
Map Recognized Voice Commands to Actions for the Linux Assistant
The handle_linux_action function maps Rhino's recognized intents and their slots into Linux assistant actions. We define an app_map dictionary to translate app names from voice commands into actual executable names on the system.
Add Notifications and Timer Control to the Linux Assistant
The notify function sends desktop notifications using the notify-send command to provide visual feedback to the user.
The TimerManager class encapsulates the timer-related functionality, managing timer state and operations.
Full Python Script for the Voice Powered Linux Assistant
Here's the complete Python script integrating all the components above into a working Linux Assistant:
Step 4: Run the Linux Voice Assistant
Run the Python script from your terminal with the following commands. Copy your AccessKey from the Picovoice Console and replace the placeholder values with your actual ACCESS_KEY, CONTEXT_FILE_PATH, and KEYWORD_FILE_PATH. The AUDIO_DEVICE_INDEX is optional and will use the default microphone if not specified.
How to Extend the Linux Voice Assistant with More Features
This example is just a starting point. You can build on this foundation to create a truly custom voice interface for Linux machine:
- Integrate with scripts: Map Rhino intents to custom scripts to automate tasks such as backing up files or running a build.
- Add spoken responses: Integrate an on-device text-to-speech engine like Orca Text-to-Speech for a full conversational voice loop.
- Run it in the background: Use a Systemd user service to have your Linux assistant launch automatically on startup.
Start Building an AI-Powered Voice Assistant on Linux
Ready to create your own voice-controlled Linux assistant? The Picovoice Console is the best place to start. You can create your custom wake word and speech-to-intent context for free in just a few clicks.
Start Free






