Skip to content

Instantly share code, notes, and snippets.

@yanyaoer
Last active January 20, 2025 09:08
Show Gist options
  • Save yanyaoer/752a73d2d6df5a2aa0de179a0f68e8a1 to your computer and use it in GitHub Desktop.
Save yanyaoer/752a73d2d6df5a2aa0de179a0f68e8a1 to your computer and use it in GitHub Desktop.
voice assistant with computer-use
#! /usr/bin/env -S uv run
# /// script
# requires-python = "==3.11.*"
# dependencies = ["RealtimeSTT==0.3.92", "open-interpreter"]
# ///
"""
# quickstart
$ DEEPSEEK_API_KEY=(pass deepseek_api) uv run soulseek.py
"""
import os
from openai import OpenAI
from RealtimeSTT import AudioToTextRecorder
from interpreter import interpreter
interpreter.llm.api_key = os.environ.get("DEEPSEEK_API_KEY")
interpreter.llm.model = "deepseek/deepseek-chat"
interpreter.auto_run = True
interpreter.safe_mode = 'off'
interpreter.anonymized_telemetry = False
def process_text(text):
print(text)
interpreter.chat(text)
if __name__ == '__main__':
print("Wait until it says 'speak now'")
# https://github.com/KoljaB/RealtimeSTT/blob/master/RealtimeSTT/audio_recorder.py#L301
with AudioToTextRecorder(
model="large-v3-turbo",
wake_words="alexa",
device="mps",
language = "zh",
initial_prompt = "以下是普通话的句子。",
wakeword_backend="oww",
wake_words_sensitivity=0.35,
wake_word_buffer_duration=1,
) as recorder:
recorder.text(process_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment