Skip to content

Commit

Permalink
fixed codestyle and spellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
matt200-ok committed Dec 5, 2024
1 parent 72a96e9 commit 291f9bc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
39 changes: 31 additions & 8 deletions recipes/llm-voice-assistant/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ def handler(_, __) -> None:
porcupine_profiler.tock(pcm)
if wake_word_detected:
listening = True
main_queue.put({'command': Commands.PROFILE, 'text': f"[Porcupine RTF: {porcupine_profiler.rtf():.3f}]"})
main_queue.put({
'command': Commands.PROFILE,
'text': f"[Porcupine RTF: {porcupine_profiler.rtf():.3f}]"})
main_queue.put({'command': Commands.INTERRUPT})
else:
cheetah_profiler.tick()
Expand All @@ -171,8 +173,13 @@ def handler(_, __) -> None:
cheetah_profiler.tock(pcm)
user_request += remaining_transcript
main_queue.put({'command': Commands.TEXT, 'text': remaining_transcript})
main_queue.put({'command': Commands.GENERATE, 'text': user_request, 'utterance_end_sec': utterance_end_sec})
main_queue.put({'command': Commands.PROFILE, 'text': f"[Cheetah RTF: {cheetah_profiler.rtf():.3f}]"})
main_queue.put({
'command': Commands.GENERATE,
'text': user_request,
'utterance_end_sec': utterance_end_sec})
main_queue.put({
'command': Commands.PROFILE,
'text': f"[Cheetah RTF: {cheetah_profiler.rtf():.3f}]"})
user_request = ''
listening = False
finally:
Expand All @@ -181,7 +188,18 @@ def handler(_, __) -> None:
mic.delete()


def generate_worker(main_queue, generate_queue, access_key, picollm_model_path, picollm_device, picollm_completion_token_limit, picollm_presence_penalty, picollm_frequency_penalty, picollm_temperature, picollm_top_p, short_answers):
def generate_worker(
main_queue,
generate_queue,
access_key,
picollm_model_path,
picollm_device,
picollm_completion_token_limit,
picollm_presence_penalty,
picollm_frequency_penalty,
picollm_temperature,
picollm_top_p,
short_answers):
def handler(_, __) -> None:
main_queue.put({'command': Commands.CLOSE})

Expand Down Expand Up @@ -324,7 +342,9 @@ def handler(_, __) -> None:
orca_profiler.tick()
pcm = orca_stream.flush()
orca_profiler.tock(pcm)
main_queue.put({'command': Commands.PROFILE, 'text': f"[Orca RTF: {orca_profiler.rtf():.2f}]\n[Delay: {delay_sec:.2f} sec]"})
main_queue.put({
'command': Commands.PROFILE,
'text': f"[Orca RTF: {orca_profiler.rtf():.2f}]\n[Delay: {delay_sec:.2f} sec]"})
if speaking:
speaker.stop()
text_queue.clear()
Expand Down Expand Up @@ -352,7 +372,9 @@ def handler(_, __) -> None:
synthesizing = False
if pcm is not None:
pcm_queue.extend(pcm)
main_queue.put({'command': Commands.PROFILE, 'text': f"[Orca RTF: {orca_profiler.rtf():.2f}]\n[Delay: {delay_sec:.2f} sec]"})
main_queue.put({
'command': Commands.PROFILE,
'text': f"[Orca RTF: {orca_profiler.rtf():.2f}]\n[Delay: {delay_sec:.2f} sec]"})

if not speaking and len(pcm_queue) > warmup_size:
speaker.start()
Expand Down Expand Up @@ -546,7 +568,8 @@ def handler(_, __) -> None:
generate_queue.put(message)
listening = False
elif message['command'] == Commands.SYNTHESIZE_START:
print(f"LLM (say {'`Picovoice`' if keyword_model_path is None else 'the wake word'} to interrupt) > ", end='', flush=True)
wake_word = '`Picovoice`' if keyword_model_path is None else 'the wake word'
print(f"LLM (say {wake_word} to interrupt) > ", end='', flush=True)
speak_queue.put(message)
generating = True
elif message['command'] == Commands.SYNTHESIZE:
Expand All @@ -573,4 +596,4 @@ def handler(_, __) -> None:


if __name__ == '__main__':
main()
main()
1 change: 1 addition & 0 deletions res/.lint/spell-check/dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pico
picollm
picovoice
pllm
popleft
pvcheetah
pvorca
pvporcupine
Expand Down

0 comments on commit 291f9bc

Please sign in to comment.