Skip to content

Commit bef7789

Browse files
committed
wip
1 parent 0192975 commit bef7789

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

recipes/llm-voice-assistant/python/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,30 @@
22

33
- Python 3.8+
44
- Runs on Linux (x86_64), macOS (arm64, x86_64), Windows (x86_64), and Raspberry Pi (5, 4, and 3).
5+
6+
## AccessKey
7+
8+
## picoLLM Model
9+
10+
## Custom Wake Word (Optional)
11+
12+
## Usage
13+
14+
```console
15+
pip install -r requirements.txt
16+
```
17+
18+
```console
19+
python3 main.py --access_key ${ACCESS_KEY} --picollm_model_path ${PICOLLM_MODEL_PATH}
20+
```
21+
22+
```console
23+
python main.py --help
24+
```
25+
26+
## Profiling
27+
28+
```console
29+
python3 main.py --access_key ${ACCESS_KEY} --picollm_model_path ${PICOLLM_MODEL_PATH} --profile
30+
```
31+

recipes/llm-voice-assistant/python/main.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ def main() -> None:
179179
parser.add_argument(
180180
'--picollm_model_path',
181181
required=True,
182-
help='Absolute path to the file containing LLM parameters.')
182+
help='Absolute path to the file containing LLM parameters (`.pllm`).')
183183
parser.add_argument(
184184
'--keyword-model_path',
185-
help='Absolute path to the keyword model file. If not set, `Picovoice` will be used as the wake phrase')
185+
help='Absolute path to the keyword model file (`.ppn`). If not set, `Picovoice` will be the wake phrase')
186186
parser.add_argument(
187187
'--cheetah_endpoint_duration_sec',
188188
type=float,
@@ -267,7 +267,7 @@ def main() -> None:
267267

268268
pllm = picollm.create(access_key=access_key, model_path=picollm_model_path, device=picollm_device)
269269
dialog = pllm.get_dialog()
270-
log.info(f"→ picoLLM V{pllm.version} {pllm.model}")
270+
log.info(f"→ picoLLM V{pllm.version} <{pllm.model}>")
271271

272272
main_connection, orca_process_connection = Pipe()
273273
orca_process = Process(target=orca_worker, args=(access_key, orca_process_connection, orca_warmup_sec))
@@ -289,7 +289,7 @@ def handler(_, __) -> None:
289289
signal.signal(signal.SIGINT, handler)
290290

291291
wake_word_detected = False
292-
human_request = ''
292+
user_request = ''
293293
endpoint_reached = False
294294
utterance_end_sec = 0
295295

@@ -308,24 +308,24 @@ def handler(_, __) -> None:
308308
if wake_word_detected:
309309
log.debug(f"[Porcupine RTF: {porcupine_profiler.rtf():.3f}]")
310310
log.info("$ Wake word detected, utter your request or question ...\n")
311-
log.info("human > ", end='')
311+
log.info("User > ", end='')
312312
elif not endpoint_reached:
313313
pcm = mic.read()
314314
cheetah_profiler.tick()
315315
partial_transcript, endpoint_reached = cheetah.process(pcm)
316316
cheetah_profiler.tock(pcm)
317317
log.info(partial_transcript, end='')
318-
human_request += partial_transcript
318+
user_request += partial_transcript
319319
if endpoint_reached:
320320
utterance_end_sec = time.time()
321321
cheetah_profiler.tick()
322322
remaining_transcript = cheetah.flush()
323323
cheetah_profiler.tock()
324-
human_request += remaining_transcript
324+
user_request += remaining_transcript
325325
log.info(remaining_transcript, end='\n\n')
326326
log.debug(f"[Cheetah RTF: {cheetah_profiler.rtf():.3f}]")
327327
else:
328-
dialog.add_human_request(human_request)
328+
dialog.add_human_request(user_request)
329329

330330
picollm_profiler = TPSProfiler()
331331

@@ -335,7 +335,7 @@ def llm_callback(text: str) -> None:
335335
{'command': 'synthesize', 'text': text, 'utterance_end_sec': utterance_end_sec})
336336
log.info(text, end='')
337337

338-
log.info("\nllm > ", end='')
338+
log.info("\nLLM > ", end='')
339339
res = pllm.generate(
340340
prompt=dialog.prompt(),
341341
completion_token_limit=picollm_completion_token_limit,
@@ -359,7 +359,7 @@ def llm_callback(text: str) -> None:
359359
assert main_connection.recv()['done']
360360

361361
wake_word_detected = False
362-
human_request = ''
362+
user_request = ''
363363
endpoint_reached = False
364364
log.info("\n$ Say `Picovoice` ...")
365365
finally:

0 commit comments

Comments
 (0)