RedisTextOverlayManager¶
redis_robot_comm.redis_text_overlay.RedisTextOverlayManager
¶
Verwaltet Text-Overlays für Roboter-Videoaufnahmen über Redis-Streams.
Manages text overlays for robot video recordings via Redis streams.
Publisher (MCP-Server): Veröffentlichen Benutzeraufgaben und Robotersprache. (Publish user tasks and robot speech). Consumer (Aufzeichnungsskript): Abonnieren, um Texte im Video anzuzeigen. (Subscribe to display texts in video).
Source code in redis_robot_comm/redis_text_overlay.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
Functions¶
__init__(host=None, port=None, stream_name='video_text_overlays', config=None)
¶
Initialisiert den Text-Overlay-Manager.
Initialize the text overlay manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
Optional[str]
|
Redis-Server-Host. (Redis server host). |
None
|
port
|
Optional[int]
|
Redis-Server-Port. (Redis server port). |
None
|
stream_name
|
str
|
Name des Redis-Streams für Text-Overlays. (Name of the Redis stream for text overlays). |
'video_text_overlays'
|
config
|
Optional[RedisConfig]
|
Optionale RedisConfig-Instanz. (Optional RedisConfig instance). |
None
|
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Wenn die Verbindung zu Redis fehlschlägt. (If connection to Redis fails). |
Source code in redis_robot_comm/redis_text_overlay.py
clear_stream()
¶
Löscht den Text-Overlay-Stream.
Clear the text overlay stream.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True bei Erfolg, False andernfalls. (True if successful, False otherwise). |
Source code in redis_robot_comm/redis_text_overlay.py
get_current_user_task(max_age_seconds=300.0)
¶
Ruft die aktuellste Benutzeraufgabe ab (falls noch relevant).
Get the most recent user task (if still relevant).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_age_seconds
|
float
|
Maximales Alter, um als aktuell zu gelten (Standard: 5 Minuten). (Maximum age to consider current (default: 5 minutes)). |
300.0
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: Aktuelle Benutzeraufgabe oder None. (Current user task or None). |
Raises:
| Type | Description |
|---|---|
RedisRetrievalError
|
Wenn der Abruf von Redis fehlschlägt. (If retrieval from Redis fails). |
Source code in redis_robot_comm/redis_text_overlay.py
get_latest_texts(max_age_seconds=10.0, text_type=None)
¶
Ruft aktuelle Text-Overlays ab.
Get recent text overlays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_age_seconds
|
float
|
Maximales Alter der abzurufenden Texte. (Maximum age of texts to retrieve). |
10.0
|
text_type
|
Optional[TextType]
|
Filtern nach Texttyp (None = alle Typen). (Filter by text type (None = all types)). |
None
|
Returns:
| Type | Description |
|---|---|
List[TextOverlayDict]
|
List[TextOverlayDict]: Liste von Text-Overlay-Dictionaries. (List of text overlay dictionaries). |
Raises:
| Type | Description |
|---|---|
RedisRetrievalError
|
Wenn der Abruf von Redis fehlschlägt. (If retrieval from Redis fails). |
Source code in redis_robot_comm/redis_text_overlay.py
get_stream_info()
¶
Ruft Stream-Statistiken ab.
Get stream statistics.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Stream-Informations-Dictionary. (Stream information dictionary). |
Source code in redis_robot_comm/redis_text_overlay.py
publish_robot_speech(speech, duration_seconds=4.0, metadata=None)
¶
Veröffentlicht eine Roboteraussage/-erklärung.
Publish robot speech/explanation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
speech
|
str
|
Was der Roboter sagt. (What the robot is saying). |
required |
duration_seconds
|
float
|
Wie lange der Text angezeigt werden soll. (How long to display the text). |
4.0
|
metadata
|
Optional[Dict[str, Any]]
|
Optionale Metadaten (z. B. tool_name, Priorität). (Optional metadata (e.g., tool_name, priority)). |
None
|
Returns:
| Type | Description |
|---|---|
Optional[StreamID]
|
Optional[StreamID]: Redis-Stream-Eintrags-ID oder None, falls die Veröffentlichung fehlschlägt. (Redis stream entry ID, or None if publishing fails). |
Source code in redis_robot_comm/redis_text_overlay.py
publish_system_message(message, duration_seconds=3.0, metadata=None)
¶
Veröffentlicht eine Systemnachricht (z. B. "Aufzeichnung gestartet").
Publish system message (e.g., "Recording started").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Text der Systemnachricht. (System message text). |
required |
duration_seconds
|
float
|
Wie lange die Nachricht angezeigt werden soll. (How long to display). |
3.0
|
metadata
|
Optional[Dict[str, Any]]
|
Optionale Metadaten. (Optional metadata). |
None
|
Returns:
| Type | Description |
|---|---|
Optional[StreamID]
|
Optional[StreamID]: Redis-Stream-Eintrags-ID oder None, falls die Veröffentlichung fehlschlägt. (Redis stream entry ID, or None if publishing fails). |
Source code in redis_robot_comm/redis_text_overlay.py
publish_user_task(task, metadata=None)
¶
Veröffentlicht eine Benutzeraufgabe/einen Benutzerbefehl.
Publish a user task/command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str
|
Die Aufgabe/der Befehl des Benutzers in natürlicher Sprache. (The user's natural language task/command). |
required |
metadata
|
Optional[Dict[str, Any]]
|
Optionale Metadaten (z. B. user_id, session_id). (Optional metadata (e.g., user_id, session_id)). |
None
|
Returns:
| Type | Description |
|---|---|
Optional[StreamID]
|
Optional[StreamID]: Redis-Stream-Eintrags-ID oder None, falls die Veröffentlichung fehlschlägt. (Redis stream entry ID, or None if publishing fails). |
Source code in redis_robot_comm/redis_text_overlay.py
subscribe_to_texts(callback, block_ms=1000, text_type=None)
¶
Abonniert Text-Overlays und ruft für jedes einen Callback auf.
Subscribe to text overlays and call callback for each one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[TextOverlayDict], None]
|
Funktion, die ein Textdaten-Dictionary erhält. (Function receiving text data dictionary). |
required |
block_ms
|
int
|
Blockier-Timeout in Millisekunden. (Blocking timeout in milliseconds). |
1000
|
text_type
|
Optional[TextType]
|
Filtern nach Texttyp (None = alle Typen). (Filter by text type (None = all types)). |
None
|
Raises:
| Type | Description |
|---|---|
RedisRetrievalError
|
Wenn das Abonnement fehlschlägt. (If subscription fails). |