recognize_stream
Signature:
Speech.recognize_stream(
*,
on_result: Callable[[str], None] | None = None,
**kwargs: Any,
) -> TaskHandle[None]
Description:
Continuously perform streaming speech recognition using the robot's microphone.
Parameters:
Parameter | Type | Default | Description |
|---|---|---|---|
|
|
| Callback invoked when a non-empty recognition result is available. |
|
| - | Optional extension parameters; the current booster provider exposes no public extension parameters. |
Returns:
TaskHandle[None], see "Tasks and Subscriptions / TaskHandle"
Raises:
RuntimeError: Failed to start the streaming recognition task.
Example:
from boosteros.brain import Speech
from boosteros.robots.booster import BoosterRobot
robot = BoosterRobot()
speech = Speech(robot)
handle = speech.recognize_stream(
on_result=lambda text: print(f"Result: {text}", flush=True), # Example output: Result: What time is it now?
)
try:
print("Streaming speech recognition started. Press Ctrl+C to exit.")
status = handle.wait()
except KeyboardInterrupt:
print("\nStopping streaming speech recognition...")
handle.cancel()
handle.wait(timeout=5.0)