task: allow specifying heartbeat period

This commit is contained in:
Aleix Conchillo Flaqué
2025-01-21 11:43:21 -08:00
parent dd21b424d6
commit bd6f82cf94
2 changed files with 8 additions and 2 deletions

View File

@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Added
- It is now possible to specify the period of the `PipelineTask` heartbeat
frames with `heartbeats_period_secs`.
### Fixed ### Fixed
- Fixed a type error when using `voice_settings` in `ElevenLabsHttpTTSService`. - Fixed a type error when using `voice_settings` in `ElevenLabsHttpTTSService`.

View File

@@ -45,6 +45,7 @@ class PipelineParams(BaseModel):
send_initial_empty_metrics: bool = True send_initial_empty_metrics: bool = True
report_only_initial_ttfb: bool = False report_only_initial_ttfb: bool = False
observers: List[BaseObserver] = [] observers: List[BaseObserver] = []
heartbeats_period_secs: float = HEARTBEAT_SECONDS
class Source(FrameProcessor): class Source(FrameProcessor):
@@ -315,7 +316,7 @@ class PipelineTask:
async def _heartbeat_push_handler(self): async def _heartbeat_push_handler(self):
""" """
This tasks pushes a heartbeat frame every HEARTBEAT_SECONDS. This tasks pushes a heartbeat frame every heartbeat period.
""" """
while True: while True:
try: try:
@@ -323,7 +324,7 @@ class PipelineTask:
# task will just stop waiting for the pipeline to finish not # task will just stop waiting for the pipeline to finish not
# allowing more frames to be pushed. # allowing more frames to be pushed.
await self._source.queue_frame(HeartbeatFrame(timestamp=self._clock.get_time())) await self._source.queue_frame(HeartbeatFrame(timestamp=self._clock.get_time()))
await asyncio.sleep(HEARTBEAT_SECONDS) await asyncio.sleep(self._params.heartbeats_period_secs)
except asyncio.CancelledError: except asyncio.CancelledError:
break break