Alina Lozovskaya commited on
Commit
94a21b7
·
1 Parent(s): 19fc9f5

Enhance typing

Browse files
src/reachy_mini_conversation_demo/audio/head_wobbler.py CHANGED
@@ -5,7 +5,7 @@ import queue
5
  import base64
6
  import logging
7
  import threading
8
- from typing import Any
9
  from collections.abc import Callable
10
 
11
  import numpy as np
@@ -22,13 +22,13 @@ logger = logging.getLogger(__name__)
22
  class HeadWobbler:
23
  """Converts audio deltas (base64) into head movement offsets."""
24
 
25
- def __init__(self, set_speech_offsets: Callable[[tuple[float, float, float, float, float, float]], None]) -> None:
26
  """Initialize the head wobbler."""
27
  self._apply_offsets = set_speech_offsets
28
  self._base_ts: float | None = None
29
  self._hops_done: int = 0
30
 
31
- self.audio_queue: queue.Queue[tuple[int, int, NDArray[Any]]] = queue.Queue()
32
  self.sway = SwayRollRT()
33
 
34
  # Synchronization primitives
 
5
  import base64
6
  import logging
7
  import threading
8
+ from typing import Tuple
9
  from collections.abc import Callable
10
 
11
  import numpy as np
 
22
  class HeadWobbler:
23
  """Converts audio deltas (base64) into head movement offsets."""
24
 
25
+ def __init__(self, set_speech_offsets: Callable[[Tuple[float, float, float, float, float, float]], None]) -> None:
26
  """Initialize the head wobbler."""
27
  self._apply_offsets = set_speech_offsets
28
  self._base_ts: float | None = None
29
  self._hops_done: int = 0
30
 
31
+ self.audio_queue: "queue.Queue[Tuple[int, int, NDArray[np.int16]]]" = queue.Queue()
32
  self.sway = SwayRollRT()
33
 
34
  # Synchronization primitives
src/reachy_mini_conversation_demo/moves.py CHANGED
@@ -665,7 +665,7 @@ class MovementManager:
665
  stats.min_freq = min(stats.min_freq, stats.last_freq)
666
  return stats
667
 
668
- def _schedule_next_tick(self, loop_start: float, stats: LoopFrequencyStats) -> tuple[float, LoopFrequencyStats]:
669
  """Compute sleep time to maintain target frequency and update potential freq."""
670
  computation_time = self._now() - loop_start
671
  stats.potential_freq = 1.0 / computation_time if computation_time > 0 else float("inf")
 
665
  stats.min_freq = min(stats.min_freq, stats.last_freq)
666
  return stats
667
 
668
+ def _schedule_next_tick(self, loop_start: float, stats: LoopFrequencyStats) -> Tuple[float, LoopFrequencyStats]:
669
  """Compute sleep time to maintain target frequency and update potential freq."""
670
  computation_time = self._now() - loop_start
671
  stats.potential_freq = 1.0 / computation_time if computation_time > 0 else float("inf")
src/reachy_mini_conversation_demo/utils.py CHANGED
@@ -1,7 +1,7 @@
1
  import logging
2
  import argparse
3
  import warnings
4
- from typing import Any
5
 
6
  from reachy_mini import ReachyMini
7
  from reachy_mini_conversation_demo.camera_worker import CameraWorker
@@ -28,7 +28,7 @@ def parse_args() -> argparse.Namespace:
28
  return parser.parse_args()
29
 
30
 
31
- def handle_vision_stuff(args: argparse.Namespace, current_robot: ReachyMini) -> tuple[CameraWorker | None, Any, Any]:
32
  """Initialize camera, head tracker, camera worker, and vision manager.
33
 
34
  By default, vision is handled by gpt-realtime model when camera tool is used.
 
1
  import logging
2
  import argparse
3
  import warnings
4
+ from typing import Any, Tuple
5
 
6
  from reachy_mini import ReachyMini
7
  from reachy_mini_conversation_demo.camera_worker import CameraWorker
 
28
  return parser.parse_args()
29
 
30
 
31
+ def handle_vision_stuff(args: argparse.Namespace, current_robot: ReachyMini) -> Tuple[CameraWorker | None, Any, Any]:
32
  """Initialize camera, head tracker, camera worker, and vision manager.
33
 
34
  By default, vision is handled by gpt-realtime model when camera tool is used.
src/reachy_mini_conversation_demo/vision/yolo_head_tracker.py CHANGED
@@ -1,6 +1,6 @@
1
  from __future__ import annotations
2
  import logging
3
- from typing import Any
4
 
5
  import numpy as np
6
 
@@ -105,7 +105,7 @@ class HeadTracker:
105
 
106
  return np.array([norm_x, norm_y], dtype=np.float32)
107
 
108
- def get_head_position(self, img: np.ndarray[Any, Any]) -> tuple[np.ndarray[Any, Any] | None, float | None]:
109
  """Get head position from face detection.
110
 
111
  Args:
 
1
  from __future__ import annotations
2
  import logging
3
+ from typing import Any, Tuple
4
 
5
  import numpy as np
6
 
 
105
 
106
  return np.array([norm_x, norm_y], dtype=np.float32)
107
 
108
+ def get_head_position(self, img: np.ndarray[Any, Any]) -> Tuple[np.ndarray[Any, Any] | None, float | None]:
109
  """Get head position from face detection.
110
 
111
  Args:
uv.lock CHANGED
@@ -971,16 +971,16 @@ wheels = [
971
 
972
  [[package]]
973
  name = "fastapi"
974
- version = "0.119.0"
975
  source = { registry = "https://pypi.org/simple" }
976
  dependencies = [
977
  { name = "pydantic" },
978
  { name = "starlette" },
979
  { name = "typing-extensions" },
980
  ]
981
- sdist = { url = "https://files.pythonhosted.org/packages/0a/f9/5c5bcce82a7997cc0eb8c47b7800f862f6b56adc40486ed246e5010d443b/fastapi-0.119.0.tar.gz", hash = "sha256:451082403a2c1f0b99c6bd57c09110ed5463856804c8078d38e5a1f1035dbbb7", size = 336756, upload-time = "2025-10-11T17:13:40.53Z" }
982
  wheels = [
983
- { url = "https://files.pythonhosted.org/packages/ce/70/584c4d7cad80f5e833715c0a29962d7c93b4d18eed522a02981a6d1b6ee5/fastapi-0.119.0-py3-none-any.whl", hash = "sha256:90a2e49ed19515320abb864df570dd766be0662c5d577688f1600170f7f73cf2", size = 107095, upload-time = "2025-10-11T17:13:39.048Z" },
984
  ]
985
 
986
  [[package]]
 
971
 
972
  [[package]]
973
  name = "fastapi"
974
+ version = "0.119.1"
975
  source = { registry = "https://pypi.org/simple" }
976
  dependencies = [
977
  { name = "pydantic" },
978
  { name = "starlette" },
979
  { name = "typing-extensions" },
980
  ]
981
+ sdist = { url = "https://files.pythonhosted.org/packages/a6/f4/152127681182e6413e7a89684c434e19e7414ed7ac0c632999c3c6980640/fastapi-0.119.1.tar.gz", hash = "sha256:a5e3426edce3fe221af4e1992c6d79011b247e3b03cc57999d697fe76cbf8ae0", size = 338616, upload-time = "2025-10-20T11:30:27.734Z" }
982
  wheels = [
983
+ { url = "https://files.pythonhosted.org/packages/b1/26/e6d959b4ac959fdb3e9c4154656fc160794db6af8e64673d52759456bf07/fastapi-0.119.1-py3-none-any.whl", hash = "sha256:0b8c2a2cce853216e150e9bd4faaed88227f8eb37de21cb200771f491586a27f", size = 108123, upload-time = "2025-10-20T11:30:26.185Z" },
984
  ]
985
 
986
  [[package]]