diff options
Diffstat (limited to 'assistant.py')
| -rw-r--r-- | assistant.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/assistant.py b/assistant.py index 16e6133..84f0dd8 100644 --- a/assistant.py +++ b/assistant.py @@ -275,6 +275,10 @@ def speaker(q): play.wait() play = None continue + if isinstance(item, float): # seconds of silence + if play: + play.stdin.write(bytes(int(sr * item) * 2)) + continue text, lang = item audio, sr = k.create(text, voice=voices[lang], lang=KLANG[lang]) if play is None: @@ -333,7 +337,9 @@ def reply(history, q): log(f"you ({lang}, {time.perf_counter() - t:.2f}s): {text}") history.append({"role": "user", "content": text}) # ponytail: last 20 messages, summarise if long sessions need memory - msgs = [{"role": "system", "content": CFG["system"]}] + history[-20:] + # The model has no clock: without the date it makes one up for tools. + now = time.strftime("It is %A %d %B %Y, %H:%M.") + msgs = [{"role": "system", "content": f"{CFG['system']} {now}"}] + history[-20:] t, said, voice, announced = time.perf_counter(), [], lang, False def say(s): @@ -364,6 +370,8 @@ def reply(history, q): if phrase: # The question's language: the reply has no text yet to follow. q.put((phrase, lang)) + # A beat after it: straight into the answer sounds rushed. + q.put(0.6) announced = True for c in calls.values(): result = run_tool(TOOLS, c["name"], c["arguments"]) |
