forked from genewildish/Mainline
fix(sensors): add inlet/outlet types to SensorStage
- Add DataType properties to SensorStage - Fix MicSensor import issues (remove conflicting TYPE_CHECKING) - Add numpy to main dependencies for type hints
This commit is contained in:
@@ -151,6 +151,7 @@ class SensorStage:
|
|||||||
"""Pipeline stage wrapper for sensors.
|
"""Pipeline stage wrapper for sensors.
|
||||||
|
|
||||||
Provides sensor data to the pipeline context.
|
Provides sensor data to the pipeline context.
|
||||||
|
Sensors don't transform data - they inject sensor values into context.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, sensor: Sensor, name: str | None = None):
|
def __init__(self, sensor: Sensor, name: str | None = None):
|
||||||
@@ -159,6 +160,22 @@ class SensorStage:
|
|||||||
self.category = "sensor"
|
self.category = "sensor"
|
||||||
self.optional = True
|
self.optional = True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def stage_type(self) -> str:
|
||||||
|
return "sensor"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def inlet_types(self) -> set:
|
||||||
|
from engine.pipeline.core import DataType
|
||||||
|
|
||||||
|
return {DataType.ANY}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def outlet_types(self) -> set:
|
||||||
|
from engine.pipeline.core import DataType
|
||||||
|
|
||||||
|
return {DataType.ANY}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def capabilities(self) -> set[str]:
|
def capabilities(self) -> set[str]:
|
||||||
return {f"sensor.{self.name}"}
|
return {f"sensor.{self.name}"}
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ try:
|
|||||||
|
|
||||||
_HAS_AUDIO = True
|
_HAS_AUDIO = True
|
||||||
except Exception:
|
except Exception:
|
||||||
_HAS_AUDIO = False
|
|
||||||
np = None # type: ignore
|
np = None # type: ignore
|
||||||
sd = None # type: ignore
|
sd = None # type: ignore
|
||||||
|
_HAS_AUDIO = False
|
||||||
|
|
||||||
|
|
||||||
from engine.events import MicLevelEvent
|
from engine.events import MicLevelEvent
|
||||||
@@ -58,7 +58,7 @@ class MicSensor(Sensor):
|
|||||||
|
|
||||||
def start(self) -> bool:
|
def start(self) -> bool:
|
||||||
"""Start the microphone stream."""
|
"""Start the microphone stream."""
|
||||||
if not _HAS_AUDIO:
|
if not _HAS_AUDIO or sd is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -84,9 +84,7 @@ class MicSensor(Sensor):
|
|||||||
pass
|
pass
|
||||||
self._stream = None
|
self._stream = None
|
||||||
|
|
||||||
def _audio_callback(
|
def _audio_callback(self, indata, frames, time_info, status) -> None:
|
||||||
self, indata: np.ndarray, frames: int, time_info: Any, status: Any
|
|
||||||
) -> None:
|
|
||||||
"""Process audio data from sounddevice."""
|
"""Process audio data from sounddevice."""
|
||||||
if not _HAS_AUDIO or np is None:
|
if not _HAS_AUDIO or np is None:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ dependencies = [
|
|||||||
"feedparser>=6.0.0",
|
"feedparser>=6.0.0",
|
||||||
"Pillow>=10.0.0",
|
"Pillow>=10.0.0",
|
||||||
"pyright>=1.1.408",
|
"pyright>=1.1.408",
|
||||||
|
"numpy>=1.24.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
|||||||
Reference in New Issue
Block a user