You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Voice-based AI assistants are becoming essential in customer support, productivity tools, and embedded interfaces. For example, a retail kiosk might need to answer product-related questions verbally without relying on internet access. However, many of these systems depend heavily on cloud services for speech recognition and language understanding, raising concerns around latency, cost, and data privacy.
12
12
13
13
In addition, a healthcare terminal or legal consultation assistant may need to handle voice queries involving sensitive personal information, where sending audio data to the cloud would violate privacy requirements. Running your voice assistant entirely offline solves these problems.
14
14
15
15
You avoid unpredictable latency caused by network fluctuations, prevent sensitive voice data from leaving the local machine, and eliminate recurring API costs that make large-scale deployment expensive. It also boosts trust for on-device deployments and compliance-sensitive industries.
16
16
17
-
By combining local speech-to-text (STT) with a locally hosted large language model (LLM), you gain full control over the pipeline and eliminate API dependencies. This gives you full control to experiment, customize, and scale—without relying on external APIs.
17
+
By combining local speech-to-text (STT) with a locally hosted large language model (LLM), you gain complete control over the pipeline and eliminate API dependencies. You can experiment, customize, and scalewithout relying on external services.
18
18
19
-
## Common Development Challenges:
19
+
## What are some common development challenges?
20
20
21
-
While the benefits are clear, building a local voice assistant involves several engineering challenges:
21
+
While the benefits are clear, building a local voice assistant involves several engineering challenges.
22
22
23
-
- Managing audio stream segmentation and speech detection in real-time: It's hard to reliably identify when the user starts and stops speaking, especially with natural pauses and background noise.
24
-
25
-
- Avoiding latency or misfires in STT/LLM integration: Timing mismatches can cause delayed responses or repeated input, reducing the conversational quality.
26
-
27
-
- Keeping the pipeline responsive on local hardware without overloading resources: You need to carefully balance CPU/GPU workloads so that inference doesn't block audio capture or processing.
23
+
Real-time audio segmentation requires reliably identifying when users start and stop speaking, accounting for natural pauses and background noise. Timing mismatches between STT and LLM components can cause delayed responses or repeated input, reducing conversational quality. You also need to balance CPU/GPU workloads to keep the pipeline responsive without overloading resources or blocking audio capture.
28
24
29
25
## Why use Arm and DGX Spark?
30
26
31
-
Arm-powered platforms like [DGX Spark](https://www.nvidia.com/en-gb/products/workstations/dgx-spark/) allow efficient parallelism: use CPU cores for audio preprocessing and whisper inference, while offloading LLM reasoning to powerful GPUs. This architecture balances throughput and energy efficiency—ideal for private, on-prem AI workloads. Check this [learning path](https://learn.arm.com/learning-paths/laptops-and-desktops/dgx_spark_llamacpp/1_gb10_introduction/) to understand the CPU and GPU architecture of DGX Spark.
27
+
Arm-powered platforms like [DGX Spark](https://www.nvidia.com/en-gb/products/workstations/dgx-spark/) allow efficient parallelism: use CPU cores for audio preprocessing and whisper inference, while offloading LLM reasoning to powerful GPUs. This architecture balances throughput and energy efficiency—ideal for private, on-premises AI workloads. To understand the CPU and GPU architecture of DGX Spark, refer to [Unlock quantized LLM performance on Arm-based NVIDIA DGX Spark](/learning-paths/laptops-and-desktops/dgx_spark_llamacpp/).
32
28
33
-
DGX Spark also supports standard USB interfaces, making it easy to connect consumer-grade microphones for development or deployment. This makes it viable not just for data center use, but also for edge inference or desktop-style prototyping.
29
+
DGX Spark also supports standard USB interfaces, making it easy to connect consumer-grade microphones for development or deployment. This makes it viable for edge inference and desktop-style prototyping.
34
30
35
31
In this Learning Path, you’ll build a complete, offline voice chatbot prototype using PyAudio, faster-whisper, and vLLM on an Arm-based system—resulting in a fully functional assistant that runs entirely on local hardware with no internet dependency.
Copy file name to clipboardExpand all lines: content/learning-paths/laptops-and-desktops/dgx_spark_voicechatbot/2_setup.md
+56-45Lines changed: 56 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,48 +1,46 @@
1
1
---
2
-
title: Installing faster-whisper for Local Speech Recognition
2
+
title: Install faster-whisper for local speech recognition
3
3
weight: 3
4
4
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
7
7
---
8
8
9
-
## Installing faster-whisper for Local Speech Recognition
10
-
11
9
[Faster‑whisper](https://github.com/SYSTRAN/faster-whisper) is a high‑performance reimplementation of OpenAI Whisper, designed to significantly reduce transcription latency and memory usage. It is well suited for local and real‑time speech‑to‑text (STT) pipelines, especially when running on CPU‑only systems or hybrid CPU/GPU environments.
12
10
13
-
In this Learning Path, faster‑whisper serves as the STT engine that converts raw microphone input into structured text. At this stage, the goal is to install faster‑whisper correctly and verify that it can transcribe audio reliably. Detailed tuning and integration will be covered in later modules.
11
+
You'll use faster‑whisper as the STT engine to convert raw microphone input into structured text. At this stage, the goal is to install faster‑whisper correctly and verify that it can transcribe audio reliably. Detailed tuning and integration are covered in later sections.
14
12
15
13
### Install build dependencies
16
14
17
-
While some Python packages such as sounddevice and webrtcvad previously had compatibility issues with newer Python versions, these have been resolved. This Learning Path uses ***Python 3.12***, which has been tested and confirmed to work reliably with all required dependencies.
15
+
While some Python packages such as sounddevice and webrtcvad previously had compatibility issues with newer Python versions, these have been resolved. Use Python 3.12, which has been tested and confirmed to work reliably with all required dependencies.
In particular, [pyaudio](https://pypi.org/project/PyAudio/) (used for real-time microphone capture) depends on the PortAudio library and the Python C API. These must match the version of Python you're using.
30
28
31
29
Now that the system libraries are in place and audio input is verified, it's time to set up an isolated Python environment for your voice assistant project. This will prevent dependency conflicts and make your installation reproducible.
32
30
33
31
```bash
34
-
python3.12 -m venv voice_ass_env
35
-
sourcevoice_ass_env/bin/activate
32
+
python3.12 -m venv va_env
33
+
sourceva_env/bin/activate
36
34
python3 -m pip install --upgrade pip
37
35
```
38
36
39
-
Before install the package, it will be worst to check the Python version in your virtual environment.
37
+
Before installing the package, check the Python version in your virtual environment.
Once your system dependencies are installed, you can test that your audio hardware is functioning properly. This ensures that your audio input is accessible by Python through the sounddevice module.
75
73
76
-
Now plug in your USB microphone and run the following Python code to verify that it is detected and functioning correctly:
74
+
Now plug in your USB microphone and create a file named `microphone.py` with the following Python code to verify that it is detected and functioning correctly.
77
75
78
76
```python
79
77
import sounddevice as sd
@@ -93,21 +91,25 @@ sd.wait()
93
91
print(" Playback complete.")
94
92
```
95
93
94
+
Run the example code to check the microphone.
95
+
96
+
```console
97
+
python3 ./microphone.py
98
+
```
99
+
96
100
DGX Spark will record the audio for 5 seconds and immediately play back the captured audio.
101
+
97
102
If you do not hear any playback, check your USB connection and verify the installation steps above.
98
103
99
104
Once you’ve confirmed that your microphone is working and your environment is set up, you’re ready to test real-time transcription and move on to the next phase.
100
105
101
-
### Sample: Real-time Transcription with faster-whisper
106
+
### Sample: Real-time transcription with faster-whisper
107
+
108
+
Verify that your Whisper model works with live microphone input. This example records a 10-second audio clip using the system microphone, transcribes it using faster-whisper, and prints the transcribed text with timestamps.
102
109
103
-
Now let's verify that your Whisper model works with live microphone input. This example records a 10-second audio clip using the system microphone, transcribes it using faster-whisper, and prints the transcribed text with timestamps.
110
+
The code below records a fixed-duration mono audio clip using the sounddevice module and transcribes it using the faster-whisper model. The `record_audio()` function starts the microphone and records a 10-second audio segment, returning the data as a NumPy array. The `WhisperModel("small.en")` call loads the small English model from faster-whisper, using `compute_type="int8"` to ensure compatibility with CPU-only systems. The `transcribe_audio()` function processes the recorded audio and prints the transcription results along with start and end timestamps for each spoken segment. The while True loop continuously records and transcribes in real time until interrupted, allowing you to speak multiple utterances across iterations. The script continues running in 10-second cycles until stopped with Ctrl+C.
104
111
105
-
This script records a fixed-duration mono audio clip using the sounddevice module and transcribes it using the faster-whisper model. The overall flow includes several key steps:
106
-
- The `record_audio()` function starts the microphone and records a 10-second audio segment, returning the data as a NumPy array.
107
-
- The `WhisperModel("small.en")` call loads the ***small English model*** from faster-whisper, using `compute_type`=***"int8"*** to ensure compatibility with CPU-only systems.
108
-
- The `transcribe_audio()` function processes the recorded audio and prints the transcription results along with start and end timestamps for each spoken segment.
109
-
- The while True loop continuously records and transcribes in real time until interrupted, allowing the user to speak multiple utterances across iterations.
110
-
- The script will continue running in 10-second cycles until stopped with ***Ctrl+C***.
To stop the script, press ***Ctrl+C*** during any transcription loop.The current 10-second recording will complete and transcribe before the program exits cleanly.
147
-
Avoid using ***Ctrl+Z***, which suspends the process instead of terminating it.
164
+
To stop the script, press Ctrl+C during any transcription loop.The current 10-second recording completes and transcribes before the program exits cleanly.
165
+
Avoid using Ctrl+Z, which suspends the process instead of terminating it.
148
166
{{% /notice %}}
149
167
150
168
151
169
### Troubleshooting
152
170
153
171
This section lists common issues you may encounter when setting up local speech-to-text, along with clear checks and fixes.
154
172
155
-
***Problem 1: Callback-related errors with sounddevice***
173
+
**Problem 1: Callback-related errors with sounddevice**
156
174
157
175
If you encounter errors like:
158
176
159
177
```log
160
178
AttributeError: '_CallbackContext' object has no attribute 'data'
161
179
```
162
180
163
-
***Cause***
164
-
This is a known issue introduced in sounddevice==0.5.4, related to internal callback cleanup.
181
+
**Cause:** This is a known issue introduced in sounddevice==0.5.4, related to internal callback cleanup.
165
182
166
-
***Fix***
167
-
Use the stable version recommended in this Learning Path:
183
+
**Fix:** Use the stable version:
168
184
```bash
169
185
pip install sounddevice==0.5.3
170
186
```
171
187
172
-
***Problem 2: No sound playback after recording***
188
+
**Problem 2: No sound playback after recording**
173
189
174
190
You can record audio without errors, but nothing is played back.
175
191
176
-
***Check:***
177
-
- Verify that your USB microphone or headset is selected as the default input/output device.
178
-
- Ensure the system volume is not muted.
192
+
Verify that your USB microphone or headset is selected as the default input/output device. Also ensure the system volume is not muted.
179
193
180
-
***Fix***
181
-
List all available audio devices:
194
+
**Fix:** List all available audio devices:
182
195
183
196
```bash
184
197
python -m sounddevice
185
198
```
186
199
187
-
You should see an output similar to:
200
+
The output is similar to:
188
201
```log
189
202
0 NVIDIA: HDMI 0 (hw:0,3), ALSA (0 in, 8 out)
190
203
1 NVIDIA: HDMI 1 (hw:0,7), ALSA (0 in, 8 out)
@@ -201,18 +214,16 @@ If your microphone or headset is listed but not active, try explicitly selecting
201
214
202
215
```bash
203
216
import sounddevice as sd
204
-
205
-
sd.default.device = 4 # Set to your desired device index
217
+
sd.default.device = 4
206
218
```
207
219
208
-
Other fixes to try:
220
+
Other things to try:
209
221
- Increase system volume
210
-
-Replug the device
222
+
-Remove the device and plug it in again
211
223
- Reboot your system to refresh device mappings
212
224
213
-
214
-
### Next Module
225
+
## What you've accomplished and what's next
215
226
216
227
Once your transcription prints correctly in the terminal and playback works as expected, you’ve successfully completed the setup for local STT using faster-whisper.
217
228
218
-
In the next module, you’ll enhance this basic transcription loop by adding real-time audio segmentation, turn detection, and background threading to support natural voice interactions.
229
+
In the next section, you'll enhance this basic transcription loop by adding real-time audio segmentation, turn detection, and background threading to support natural voice interactions.
0 commit comments