added BotSpeakingFrame

This commit is contained in:
Aleix Conchillo Flaqué
2024-07-01 14:57:18 -07:00
parent c5298f78cb
commit d7c3e380a5
3 changed files with 16 additions and 0 deletions

View File

@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Added new frame `BotSpeakingFrame`. This frame will be continuously pushed
upstream while the bot is talking.
- Added `XTTSService`. This is a local Text-To-Speech service. - Added `XTTSService`. This is a local Text-To-Speech service.
See https://github.com/coqui-ai/TTS See https://github.com/coqui-ai/TTS

View File

@@ -240,6 +240,17 @@ class StopInterruptionFrame(SystemFrame):
pass pass
@dataclass
class BotSpeakingFrame(SystemFrame):
"""Emitted by transport outputs while the bot is still speaking. This can be
used, for example, to detect when a user is idle. That is, while the bot is
speaking we don't want to trigger any user idle timeout since the user might
be listening.
"""
pass
@dataclass @dataclass
class MetricsFrame(SystemFrame): class MetricsFrame(SystemFrame):
"""Emitted by processor that can compute metrics like latencies. """Emitted by processor that can compute metrics like latencies.

View File

@@ -14,6 +14,7 @@ from typing import List
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
from pipecat.frames.frames import ( from pipecat.frames.frames import (
AudioRawFrame, AudioRawFrame,
BotSpeakingFrame,
CancelFrame, CancelFrame,
MetricsFrame, MetricsFrame,
SpriteFrame, SpriteFrame,
@@ -263,4 +264,5 @@ class BaseOutputTransport(FrameProcessor):
if len(buffer) >= self._audio_chunk_size: if len(buffer) >= self._audio_chunk_size:
await self.write_raw_audio_frames(bytes(buffer[:self._audio_chunk_size])) await self.write_raw_audio_frames(bytes(buffer[:self._audio_chunk_size]))
buffer = buffer[self._audio_chunk_size:] buffer = buffer[self._audio_chunk_size:]
await self.push_frame(BotSpeakingFrame(), FrameDirection.UPSTREAM)
return buffer return buffer