# Tutorial 4: Build Your Own Voice Assistant

**Difficulty:** Beginner  
**Estimated hands-on time:** 45–75 min  
**Purpose:** Speak or type commands, hear replies.  
**Safety:** Educational only. No connection to real plant control systems, restricted datasets, or operational decision making.

## What you will build

A standalone demonstration tool you can run on your own computer, understand, modify, and show to peers. The default data and responses are synthetic or predefined.

## Prerequisites

- Python 3.10+ (64-bit recommended); Chrome or Edge for the interface.
- Internet connection only for installing Python packages (where required). Voice recognition may additionally require browser internet access.
- An editor such as VS Code, or any text editor.

## Step-by-step

1. Extract the AIMPACT ZIP, then open a terminal in `build_lab/04_voice_assistant`.
2. No third-party Python packages required for the basic voice tutorial.
3. Run `python server.py`.
4. Open `http://localhost:8765` in Chrome/Edge and allow microphone access if prompted.
5. Try typing `help`, `pump`, `safety`, and `schedule`. Next try the microphone and Stop button.
6. Switch to Hindi and test a supported command. Hindi recognition and voice quality depend on your browser.
7. Edit one response, label, threshold or chart title in the source, save, and rerun or refresh.
8. Capture a screenshot, describe what you changed, and propose a pull request to AIMPACT.

## How it works

The browser SpeechRecognition API converts speech to text where supported. A transparent JavaScript command router matches words such as pump, safety and schedule. SpeechSynthesis reads the predefined response aloud. No LLM, hidden APMS components or server-side storage are used.

## Mini-challenges for contributors

- Add one engineering-relevant input or command and explain its meaning.
- Improve accessibility and provide a screenshot of the result.
- Add basic input validation or a clear failure message.
- Write a short limitations section explaining what would be needed for real deployment.

## Suggested evidence for a community submission

Include a screenshot, the exact Python/browser version, sample input, observed output, and known limitations. Never include internal site data, passwords, personal records or proprietary APMS code.

## Troubleshooting

- If `streamlit` is not found, activate the environment where you installed requirements and rerun the installation.
- If the default port is occupied, close the other server or change the port.
- For voice recognition, use Chrome/Edge on localhost and check microphone permission. Typed commands are a fallback.
- If you are offline, package installation and some browser speech-recognition engines may not work.

## Responsible use

Models are demonstration baselines. Do not interpret outputs as certified condition monitoring, project forecasts, or safety inspections. Validate on authorized data with domain experts before any real-world use.
