Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,24 @@ def __init__(self):
def mute_pc(self, mute=True):
if sys.platform != 'win32': return

# --- NEW WAY: Hardware Virtual Keys ---
# 0xAD is VK_VOLUME_MUTE. We simulate a physical key press.
# This bypasses all library/COM/object errors because it's at the OS input level.
VK_VOLUME_MUTE = 0xAD

try:
# We use keybd_event to send the MUTE command directly to the Windows shell
# This is exactly what happens when you press the 'Mute' button on your keyboard.
ctypes.windll.user32.keybd_event(VK_VOLUME_MUTE, 0, 0, 0) # Press
ctypes.windll.user32.keybd_event(VK_VOLUME_MUTE, 0, 2, 0) # Release
CoInitialize()
speakers = AudioUtilities.GetSpeakers()
if speakers:
volume = speakers.EndpointVolume
# Absolute mute
volume.SetMute(1 if mute else 0, None)
# state = "ON" if mute else "OFF"
# print(f"DEBUG: Absolute Mute (pycaw): {state}", file=sys.stderr)

if mute:
print("DEBUG: Hardware Mute Toggled (ON)", file=sys.stderr)
else:
print("DEBUG: Hardware Mute Toggled (OFF)", file=sys.stderr)
# Clean up COM
CoUninitialize()
except Exception as e:
print(f"DEBUG: Hardware Mute failed: {e}", file=sys.stderr)
print(f"DEBUG: Absolute Mute failed: {e}", file=sys.stderr)
# Fallback to older toggle way if pycaw fails
VK_VOLUME_MUTE = 0xAD
ctypes.windll.user32.keybd_event(VK_VOLUME_MUTE, 0, 0, 0)
ctypes.windll.user32.keybd_event(VK_VOLUME_MUTE, 0, 2, 0)

def _load_model(self):
self.log("status", {"text": f"Pace AI Warming Up ({self.model_size})..."})
Expand Down
11 changes: 9 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,13 @@ function startPythonEngine() {
console.error(`Python Engine Error: ${data}`);
});

let stdoutBuffer = '';
pythonProcess.stdout.on('data', (data) => {
data.toString().split('\n').forEach(line => {
stdoutBuffer += data.toString();
let lines = stdoutBuffer.split('\n');
stdoutBuffer = lines.pop(); // Keep the last incomplete line

lines.forEach(line => {
if (!line.trim()) return;
try {
const json = JSON.parse(line);
Expand All @@ -235,7 +240,9 @@ function startPythonEngine() {
}

if (mainWindow) mainWindow.webContents.send('engine-msg', json);
} catch (e) {}
} catch (e) {
console.error('JSON Parse Error:', e, 'on line:', line);
}
});
});

Expand Down
60 changes: 46 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ PyAudio
numpy
keyboard
pygame
pyperclip