drenayaz commited on
Commit
c45c7ba
·
1 Parent(s): e4d90ee

fix volume for windows

Browse files
pyproject.toml CHANGED
@@ -12,8 +12,6 @@ requires-python = ">=3.10"
12
  dependencies = [
13
  "reachy-mini",
14
  "soundfile", # For audio recording
15
- 'pycaw; sys_platform == "win32"', # Windows volume control
16
- 'comtypes; sys_platform == "win32"', # Required by pycaw
17
  ]
18
  keywords = ["reachy-mini-app"]
19
 
 
12
  dependencies = [
13
  "reachy-mini",
14
  "soundfile", # For audio recording
 
 
15
  ]
16
  keywords = ["reachy-mini-app"]
17
 
wake_me_up/main.py CHANGED
@@ -450,45 +450,10 @@ class WakeMeUp(ReachyMiniApp):
450
  raise RuntimeError("Failed to read volume with amixer")
451
 
452
  def _get_volume_windows(self) -> float:
453
- """Get volume on Windows using pycaw"""
454
- try:
455
- from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
456
- from ctypes import cast, POINTER
457
- from comtypes import CLSCTX_ALL
458
-
459
- # Get default audio device
460
- speakers = AudioUtilities.GetSpeakers()
461
-
462
- # Try new API (AudioDevice with direct interface access)
463
- try:
464
- # New pycaw API: AudioDevice._volume
465
- if hasattr(speakers, '_volume'):
466
- volume_obj = speakers._volume
467
- else:
468
- # Fallback: Try to get the interface directly
469
- interface = speakers.Activate(
470
- IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
471
- volume_obj = cast(interface, POINTER(IAudioEndpointVolume))
472
- except AttributeError:
473
- # Old API: Use Activate() method
474
- interface = speakers.Activate(
475
- IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
476
- volume_obj = cast(interface, POINTER(IAudioEndpointVolume))
477
-
478
- # Get current volume level (0.0 to 1.0)
479
- current_volume = volume_obj.GetMasterVolumeLevelScalar()
480
- volume_percent = int(current_volume * 100)
481
- print(f"Current Windows volume: {volume_percent}%")
482
- return float(current_volume)
483
-
484
- except ImportError as e:
485
- print(f"pycaw not installed. Install with: pip install pycaw comtypes")
486
- raise
487
- except Exception as e:
488
- print(f"Failed to read Windows volume: {e}")
489
- import traceback
490
- traceback.print_exc()
491
- raise
492
 
493
  def _get_volume_macos(self) -> float:
494
  """Get volume on macOS using osascript"""
@@ -551,45 +516,11 @@ class WakeMeUp(ReachyMiniApp):
551
  return result1.returncode == 0
552
 
553
  def _set_volume_windows(self, volume: float) -> bool:
554
- """Set volume on Windows using pycaw"""
555
- try:
556
- from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
557
- from ctypes import cast, POINTER
558
- from comtypes import CLSCTX_ALL
559
-
560
- # Get default audio device
561
- speakers = AudioUtilities.GetSpeakers()
562
-
563
- # Try new API (AudioDevice with direct interface access)
564
- try:
565
- # New pycaw API: AudioDevice._volume
566
- if hasattr(speakers, '_volume'):
567
- volume_obj = speakers._volume
568
- else:
569
- # Fallback: Try to get the interface directly
570
- interface = speakers.Activate(
571
- IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
572
- volume_obj = cast(interface, POINTER(IAudioEndpointVolume))
573
- except AttributeError:
574
- # Old API: Use Activate() method
575
- interface = speakers.Activate(
576
- IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
577
- volume_obj = cast(interface, POINTER(IAudioEndpointVolume))
578
-
579
- # Set volume level (0.0 to 1.0)
580
- volume_obj.SetMasterVolumeLevelScalar(volume, None)
581
- volume_percent = int(volume * 100)
582
- print(f"Windows volume set to {volume_percent}%")
583
- return True
584
-
585
- except ImportError as e:
586
- print(f"pycaw not installed. Install with: pip install pycaw comtypes")
587
- return False
588
- except Exception as e:
589
- print(f"Failed to set Windows volume: {e}")
590
- import traceback
591
- traceback.print_exc()
592
- return False
593
 
594
  def _set_volume_macos(self, volume: float) -> bool:
595
  """Set volume on macOS using osascript"""
 
450
  raise RuntimeError("Failed to read volume with amixer")
451
 
452
  def _get_volume_windows(self) -> float:
453
+ """Get volume on Windows - currently not supported"""
454
+ print("Note: Volume control is not available on Windows")
455
+ print(" You can manually adjust volume in Windows settings")
456
+ return 0.5 # Default to 50%
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
 
458
  def _get_volume_macos(self) -> float:
459
  """Get volume on macOS using osascript"""
 
516
  return result1.returncode == 0
517
 
518
  def _set_volume_windows(self, volume: float) -> bool:
519
+ """Set volume on Windows - currently not supported"""
520
+ volume_percent = int(volume * 100)
521
+ print(f"Note: Volume control not available on Windows (requested: {volume_percent}%)")
522
+ print(f" Please adjust volume manually in Windows settings")
523
+ return False # Indicate volume was not actually set
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
524
 
525
  def _set_volume_macos(self, volume: float) -> bool:
526
  """Set volume on macOS using osascript"""
wake_me_up/static/index.html CHANGED
@@ -323,6 +323,13 @@
323
  <input type="range" id="volume-slider-debug" min="0" max="100" value="50">
324
  <span id="volume-value-debug">50%</span>
325
  </div>
 
 
 
 
 
 
 
326
  </div>
327
 
328
  <!-- Right column: Recording -->
 
323
  <input type="range" id="volume-slider-debug" min="0" max="100" value="50">
324
  <span id="volume-value-debug">50%</span>
325
  </div>
326
+
327
+ <!-- Windows volume control notice -->
328
+ <div id="windows-volume-notice" style="display: none; margin-top: 15px; padding: 12px; background: #fff3cd; border: 1px solid #ffc107; border-radius: 8px;">
329
+ <p style="margin: 0; font-size: 14px; color: #856404;">
330
+ <strong>ℹ️ Note:</strong> Volume control is not available on Windows.
331
+ </p>
332
+ </div>
333
  </div>
334
 
335
  <!-- Right column: Recording -->
wake_me_up/static/main.js CHANGED
@@ -9,6 +9,7 @@ document.addEventListener('DOMContentLoaded', () => {
9
  initWaveform();
10
  startPolling();
11
  setupVolumeSlider();
 
12
  });
13
 
14
  // Create waveform bars
@@ -1171,4 +1172,16 @@ async function goToPreviousStep() {
1171
  }
1172
  }
1173
 
 
 
 
 
 
 
 
 
 
 
 
 
1174
 
 
9
  initWaveform();
10
  startPolling();
11
  setupVolumeSlider();
12
+ checkWindowsPlatform();
13
  });
14
 
15
  // Create waveform bars
 
1172
  }
1173
  }
1174
 
1175
+ // Detect Windows platform and show volume control notice
1176
+ function checkWindowsPlatform() {
1177
+ const isWindows = navigator.platform.toLowerCase().includes('win') ||
1178
+ navigator.userAgent.toLowerCase().includes('windows');
1179
+
1180
+ if (isWindows) {
1181
+ const notice = document.getElementById('windows-volume-notice');
1182
+ if (notice) {
1183
+ notice.style.display = 'block';
1184
+ }
1185
+ }
1186
+ }
1187