dv-pipecat-ai 0.0.82.dev69__py3-none-any.whl → 0.0.82.dev70__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dv-pipecat-ai might be problematic. Click here for more details.
- {dv_pipecat_ai-0.0.82.dev69.dist-info → dv_pipecat_ai-0.0.82.dev70.dist-info}/METADATA +1 -1
- {dv_pipecat_ai-0.0.82.dev69.dist-info → dv_pipecat_ai-0.0.82.dev70.dist-info}/RECORD +9 -9
- pipecat/frames/frames.py +15 -1
- pipecat/processors/dtmf_aggregator.py +128 -87
- pipecat/processors/filters/stt_mute_filter.py +15 -0
- pipecat/processors/user_idle_processor.py +16 -4
- {dv_pipecat_ai-0.0.82.dev69.dist-info → dv_pipecat_ai-0.0.82.dev70.dist-info}/WHEEL +0 -0
- {dv_pipecat_ai-0.0.82.dev69.dist-info → dv_pipecat_ai-0.0.82.dev70.dist-info}/licenses/LICENSE +0 -0
- {dv_pipecat_ai-0.0.82.dev69.dist-info → dv_pipecat_ai-0.0.82.dev70.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
dv_pipecat_ai-0.0.82.
|
|
1
|
+
dv_pipecat_ai-0.0.82.dev70.dist-info/licenses/LICENSE,sha256=DWY2QGf2eMCFhuu2ChairtT6CB7BEFffNVhXWc4Od08,1301
|
|
2
2
|
pipecat/__init__.py,sha256=j0Xm6adxHhd7D06dIyyPV_GlBYLlBnTAERVvD_jAARQ,861
|
|
3
3
|
pipecat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
pipecat/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -74,7 +74,7 @@ pipecat/extensions/voicemail/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
|
|
|
74
74
|
pipecat/extensions/voicemail/voicemail_detector.py,sha256=g3L1m3cPJzsadeB5a8WRC9klH0D8m7xfPgB2YEaL6Do,29983
|
|
75
75
|
pipecat/frames/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
76
76
|
pipecat/frames/frames.proto,sha256=JXZm3VXLR8zMOUcOuhVoe2mhM3MQIQGMJXLopdJO_5Y,839
|
|
77
|
-
pipecat/frames/frames.py,sha256=
|
|
77
|
+
pipecat/frames/frames.py,sha256=oqoo7p-uJOqak50mxhCGq7S0TusM0I4qp3QAftKHQnw,45428
|
|
78
78
|
pipecat/frames/protobufs/frames_pb2.py,sha256=VHgGV_W7qQ4sfQK6RHb5_DggLm3PiSYMr6aBZ8_p1cQ,2590
|
|
79
79
|
pipecat/metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
80
80
|
pipecat/metrics/metrics.py,sha256=bdZNciEtLTtA-xgoKDz2RJAy6fKrXkTwz3pryVHzc2M,2713
|
|
@@ -102,7 +102,7 @@ pipecat/pipeline/to_be_updated/merge_pipeline.py,sha256=jLEWdufIW3z1xZhdoLowdJ_S
|
|
|
102
102
|
pipecat/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
103
103
|
pipecat/processors/async_generator.py,sha256=qPOZxk5eOad_NrF_Z06vWZ6deXIxb9AKZKYO2e5pkJs,2385
|
|
104
104
|
pipecat/processors/consumer_processor.py,sha256=DrWCKnfblknZJ0bLmR_unIeJ1axQw4IPUn2IB3KLGGA,3228
|
|
105
|
-
pipecat/processors/dtmf_aggregator.py,sha256=
|
|
105
|
+
pipecat/processors/dtmf_aggregator.py,sha256=mo_IXUlsnVl-_Xn8sbTGnRF4Lkts0h6E3uauGbeFyWs,10204
|
|
106
106
|
pipecat/processors/frame_processor.py,sha256=VlU1h01FUilQ9UGzn7uuXELtNaASwbiMQxPChySJ7_g,29727
|
|
107
107
|
pipecat/processors/idle_frame_processor.py,sha256=z8AuhGap61lA5K35P6XCaOpn4kkmK_9NZNppbpQxheU,3124
|
|
108
108
|
pipecat/processors/logger.py,sha256=VGNwxQSc_F0rS3KBmfqas7f5aFyRQKfeljozOxfGXk4,2393
|
|
@@ -110,7 +110,7 @@ pipecat/processors/producer_processor.py,sha256=iIIOHZd77APvUGP7JqFbznAHUnCULcq_
|
|
|
110
110
|
pipecat/processors/text_transformer.py,sha256=LnfWJYzntJhZhrQ1lgSSY4D4VbHtrQJgrC227M69ZYU,1718
|
|
111
111
|
pipecat/processors/transcript_processor.py,sha256=CG9yej6WOiy_HhagNXjxkISHkHii0JDfK_V6opseC2E,11740
|
|
112
112
|
pipecat/processors/two_stage_user_idle_processor.py,sha256=uf2aZh_lfW-eMxmFogP3R4taAJ1yXOSqjKsR7oXtD0Y,2938
|
|
113
|
-
pipecat/processors/user_idle_processor.py,sha256=
|
|
113
|
+
pipecat/processors/user_idle_processor.py,sha256=qRBDzbXBQp07qV7Uh_p4-349BE2Un6hg2iqIAmNGcT0,8562
|
|
114
114
|
pipecat/processors/aggregators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
115
115
|
pipecat/processors/aggregators/dtmf_aggregator.py,sha256=nngjLiaOtcZtuCNpYPyfUVLtUBUC6USuvS0tSdA9_zo,5054
|
|
116
116
|
pipecat/processors/aggregators/gated.py,sha256=tii0sRrBkRW6y9Xq5iTWPnqlOEejU4VqPIPtdOa61pc,3073
|
|
@@ -129,7 +129,7 @@ pipecat/processors/filters/frame_filter.py,sha256=ZPtHToASfbbtwAdrnQH8POKIvT8hF0
|
|
|
129
129
|
pipecat/processors/filters/function_filter.py,sha256=QNQZBIe1gzSPNI_4Zg2fgyeUhX-AmbIMp7r_XWNhwjU,2400
|
|
130
130
|
pipecat/processors/filters/identity_filter.py,sha256=YNQWNNnuHivNwJa71Gc7A6ZHHq5Zw_kvuNrq9LUKK44,1418
|
|
131
131
|
pipecat/processors/filters/null_filter.py,sha256=CourFfNXyhaesksiBuXxv5-mFSDpy6e9bOJ04p3iK40,1467
|
|
132
|
-
pipecat/processors/filters/stt_mute_filter.py,sha256=
|
|
132
|
+
pipecat/processors/filters/stt_mute_filter.py,sha256=a9Pgp-z1pNQtDIKBtzdP4yFLf-3EhAoQAd0XSXWLpsQ,10147
|
|
133
133
|
pipecat/processors/filters/wake_check_filter.py,sha256=EKOuw_DCK4EWJ794xS8Xza-QQImD-pjgWYp0wdyvHjI,5099
|
|
134
134
|
pipecat/processors/filters/wake_notifier_filter.py,sha256=1yV3Tw8OROCS97nuZNs4igcNvRQyYu1RG2gNvYMWxKc,2077
|
|
135
135
|
pipecat/processors/frameworks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -378,7 +378,7 @@ pipecat/utils/tracing/service_decorators.py,sha256=HwDCqLGijhYD3F8nxDuQmEw-YkRw0
|
|
|
378
378
|
pipecat/utils/tracing/setup.py,sha256=7TEgPNpq6M8lww8OQvf0P9FzYc5A30xICGklVA-fua0,2892
|
|
379
379
|
pipecat/utils/tracing/turn_context_provider.py,sha256=ikon3plFOx0XbMrH6DdeHttNpb-U0gzMZIm3bWLc9eI,2485
|
|
380
380
|
pipecat/utils/tracing/turn_trace_observer.py,sha256=dma16SBJpYSOE58YDWy89QzHyQFc_9gQZszKeWixuwc,9725
|
|
381
|
-
dv_pipecat_ai-0.0.82.
|
|
382
|
-
dv_pipecat_ai-0.0.82.
|
|
383
|
-
dv_pipecat_ai-0.0.82.
|
|
384
|
-
dv_pipecat_ai-0.0.82.
|
|
381
|
+
dv_pipecat_ai-0.0.82.dev70.dist-info/METADATA,sha256=YeEWgQg0UE5-naruvtBkTnRuW-3TemsWbGjDsSz-zl4,32692
|
|
382
|
+
dv_pipecat_ai-0.0.82.dev70.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
383
|
+
dv_pipecat_ai-0.0.82.dev70.dist-info/top_level.txt,sha256=kQzG20CxGf-nSsHmtXHx3hY2-8zHA3jYg8jk0TajqXc,8
|
|
384
|
+
dv_pipecat_ai-0.0.82.dev70.dist-info/RECORD,,
|
pipecat/frames/frames.py
CHANGED
|
@@ -1306,6 +1306,20 @@ class SpeechControlParamsFrame(SystemFrame):
|
|
|
1306
1306
|
turn_params: Optional[SmartTurnParams] = None
|
|
1307
1307
|
|
|
1308
1308
|
|
|
1309
|
+
@dataclass
|
|
1310
|
+
class StartDTMFCaptureFrame(SystemFrame):
|
|
1311
|
+
"""System frame indicating the bot is actively collecting DTMF input."""
|
|
1312
|
+
|
|
1313
|
+
pass
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
@dataclass
|
|
1317
|
+
class EndDTMFCaptureFrame(SystemFrame):
|
|
1318
|
+
"""System frame indicating DTMF collection has finished."""
|
|
1319
|
+
|
|
1320
|
+
pass
|
|
1321
|
+
|
|
1322
|
+
|
|
1309
1323
|
#
|
|
1310
1324
|
# Control frames
|
|
1311
1325
|
#
|
|
@@ -1476,7 +1490,7 @@ class STTUpdateSettingsFrame(ServiceUpdateSettingsFrame):
|
|
|
1476
1490
|
@dataclass
|
|
1477
1491
|
class DTMFUpdateSettingsFrame(ServiceUpdateSettingsFrame):
|
|
1478
1492
|
"""Frame for updating DTMF aggregator settings.
|
|
1479
|
-
|
|
1493
|
+
|
|
1480
1494
|
Updates DTMF configuration dynamically during conversation flow.
|
|
1481
1495
|
Settings can include: timeout, digits, end, reset parameters.
|
|
1482
1496
|
"""
|
|
@@ -4,15 +4,13 @@ from pipecat.frames.frames import (
|
|
|
4
4
|
BotSpeakingFrame,
|
|
5
5
|
CancelFrame,
|
|
6
6
|
DTMFUpdateSettingsFrame,
|
|
7
|
+
EndDTMFCaptureFrame,
|
|
7
8
|
EndFrame,
|
|
8
9
|
Frame,
|
|
9
10
|
InputDTMFFrame,
|
|
11
|
+
StartDTMFCaptureFrame,
|
|
10
12
|
StartInterruptionFrame,
|
|
11
|
-
StartUserIdleProcessorFrame,
|
|
12
|
-
StopUserIdleProcessorFrame,
|
|
13
13
|
TranscriptionFrame,
|
|
14
|
-
UserStartedSpeakingFrame,
|
|
15
|
-
UserStoppedSpeakingFrame,
|
|
16
14
|
WaitForDTMFFrame,
|
|
17
15
|
)
|
|
18
16
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
|
@@ -44,95 +42,78 @@ class DTMFAggregator(FrameProcessor):
|
|
|
44
42
|
self._idle_timeout = timeout
|
|
45
43
|
self._digits = digits
|
|
46
44
|
self._digit_event = asyncio.Event()
|
|
47
|
-
self.
|
|
45
|
+
self._aggregation_task = None
|
|
48
46
|
self._end_on = end_on if end_on else set()
|
|
49
47
|
self._reset_on = reset_on if reset_on else set()
|
|
50
|
-
self.
|
|
51
|
-
|
|
52
|
-
async def _start_idle_processor(self):
|
|
53
|
-
await self.push_frame(StartUserIdleProcessorFrame(), FrameDirection.UPSTREAM)
|
|
54
|
-
self._stopped_idle_processor = False
|
|
55
|
-
|
|
56
|
-
async def _stop_idle_processor(self):
|
|
57
|
-
await self.push_frame(StopUserIdleProcessorFrame(), FrameDirection.UPSTREAM)
|
|
58
|
-
self._stopped_idle_processor = True
|
|
48
|
+
self._dtmf_capture_active = False
|
|
59
49
|
|
|
60
50
|
async def process_frame(self, frame: Frame, direction: FrameDirection) -> None:
|
|
61
51
|
# Handle DTMF frames.
|
|
62
52
|
await super().process_frame(frame, direction)
|
|
63
|
-
await self.push_frame(frame, direction)
|
|
64
|
-
if isinstance(frame, InputDTMFFrame):
|
|
65
|
-
# Start the digit aggregation task if it's not running yet.
|
|
66
|
-
if self._digit_aggregate_task is None:
|
|
67
|
-
self._digit_aggregate_task = self.create_task(self._digit_agg_handler(direction))
|
|
68
|
-
|
|
69
|
-
# Append the incoming digit.
|
|
70
|
-
if frame.button.value in self._reset_on:
|
|
71
|
-
self._aggregation = ""
|
|
72
|
-
elif frame.button.value in self._end_on:
|
|
73
|
-
await self.flush_aggregation(direction)
|
|
74
|
-
self._aggregation = ""
|
|
75
|
-
else:
|
|
76
|
-
self._digit_event.set()
|
|
77
|
-
self._aggregation += frame.button.value
|
|
78
|
-
|
|
79
|
-
# Flush if the aggregated digits reach the specified length.
|
|
80
|
-
if self._digits and len(self._aggregation) == self._digits:
|
|
81
|
-
await self.flush_aggregation(direction)
|
|
82
|
-
self._aggregation = ""
|
|
83
|
-
if self._stopped_idle_processor:
|
|
84
|
-
await self._start_idle_processor()
|
|
85
53
|
|
|
54
|
+
if isinstance(frame, InputDTMFFrame):
|
|
55
|
+
# Push the DTMF frame downstream first
|
|
56
|
+
await self.push_frame(frame, direction)
|
|
57
|
+
# Then handle it for proper frame ordering
|
|
58
|
+
await self._handle_dtmf_frame(frame)
|
|
86
59
|
elif isinstance(frame, (EndFrame, CancelFrame)):
|
|
87
60
|
# For EndFrame, flush any pending aggregation and stop the digit aggregation task.
|
|
88
61
|
if self._aggregation:
|
|
89
|
-
await self.flush_aggregation(
|
|
90
|
-
if self.
|
|
91
|
-
await self.
|
|
62
|
+
await self.flush_aggregation()
|
|
63
|
+
if self._aggregation_task:
|
|
64
|
+
await self._stop_aggregation_task()
|
|
65
|
+
await self.push_frame(frame, direction)
|
|
92
66
|
elif isinstance(frame, WaitForDTMFFrame):
|
|
93
67
|
self.logger.debug("Received WaitForDTMFFrame: Waiting for DTMF input")
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
self._digit_event.set()
|
|
99
|
-
await self._stop_idle_processor()
|
|
68
|
+
self._create_aggregation_task(raise_timeout=True)
|
|
69
|
+
self._digit_event.set() # Trigger the timeout handler
|
|
70
|
+
await self._start_dtmf_capture()
|
|
71
|
+
await self.push_frame(frame, direction)
|
|
100
72
|
elif isinstance(frame, StartInterruptionFrame):
|
|
101
|
-
self.logger.debug("Received StartInterruptionFrame
|
|
102
|
-
if self._stopped_idle_processor:
|
|
103
|
-
await self._start_idle_processor()
|
|
73
|
+
self.logger.debug("Received StartInterruptionFrame")
|
|
104
74
|
if self._aggregation:
|
|
105
|
-
await self.flush_aggregation(
|
|
75
|
+
await self.flush_aggregation()
|
|
76
|
+
await self._end_dtmf_capture()
|
|
77
|
+
await self.push_frame(frame, direction)
|
|
106
78
|
elif isinstance(frame, BotSpeakingFrame):
|
|
107
|
-
|
|
79
|
+
# Signal the aggregation task to continue when bot speaks
|
|
80
|
+
if self._aggregation_task is not None:
|
|
108
81
|
self._digit_event.set()
|
|
82
|
+
await self.push_frame(frame, direction)
|
|
109
83
|
elif isinstance(frame, DTMFUpdateSettingsFrame):
|
|
110
84
|
await self._update_settings(frame.settings)
|
|
111
85
|
# Don't pass the settings frame downstream
|
|
86
|
+
else:
|
|
87
|
+
# Pass all other frames through
|
|
88
|
+
await self.push_frame(frame, direction)
|
|
112
89
|
|
|
113
90
|
async def _update_settings(self, settings: dict) -> None:
|
|
114
91
|
"""Update DTMF aggregator settings dynamically.
|
|
115
|
-
|
|
92
|
+
|
|
116
93
|
Args:
|
|
117
94
|
settings: Dictionary containing new DTMF settings
|
|
118
95
|
Supported keys: timeout, digits, end, reset
|
|
119
96
|
"""
|
|
120
97
|
settings_changed = False
|
|
121
|
-
|
|
98
|
+
|
|
122
99
|
if "timeout" in settings and settings["timeout"] is not None:
|
|
123
100
|
new_timeout = float(settings["timeout"])
|
|
124
101
|
if new_timeout != self._idle_timeout:
|
|
125
|
-
self.logger.debug(
|
|
102
|
+
self.logger.debug(
|
|
103
|
+
f"Updating DTMF timeout from {self._idle_timeout} to {new_timeout}"
|
|
104
|
+
)
|
|
126
105
|
self._idle_timeout = new_timeout
|
|
127
106
|
settings_changed = True
|
|
128
|
-
|
|
107
|
+
|
|
129
108
|
if "digits" in settings:
|
|
130
109
|
new_digits = settings["digits"]
|
|
131
110
|
if new_digits != self._digits:
|
|
132
|
-
self.logger.debug(
|
|
111
|
+
self.logger.debug(
|
|
112
|
+
f"Updating DTMF digits from {self._digits} to {new_digits}"
|
|
113
|
+
)
|
|
133
114
|
self._digits = new_digits
|
|
134
115
|
settings_changed = True
|
|
135
|
-
|
|
116
|
+
|
|
136
117
|
if "end" in settings:
|
|
137
118
|
# Convert single string to set if needed
|
|
138
119
|
end_value = settings["end"]
|
|
@@ -142,12 +123,14 @@ class DTMFAggregator(FrameProcessor):
|
|
|
142
123
|
new_end_on = {end_value} if end_value else set()
|
|
143
124
|
else:
|
|
144
125
|
new_end_on = set(end_value)
|
|
145
|
-
|
|
126
|
+
|
|
146
127
|
if new_end_on != self._end_on:
|
|
147
|
-
self.logger.debug(
|
|
128
|
+
self.logger.debug(
|
|
129
|
+
f"Updating DTMF end_on from {self._end_on} to {new_end_on}"
|
|
130
|
+
)
|
|
148
131
|
self._end_on = new_end_on
|
|
149
132
|
settings_changed = True
|
|
150
|
-
|
|
133
|
+
|
|
151
134
|
if "reset" in settings:
|
|
152
135
|
# Convert single string to set if needed
|
|
153
136
|
reset_value = settings["reset"]
|
|
@@ -157,58 +140,116 @@ class DTMFAggregator(FrameProcessor):
|
|
|
157
140
|
new_reset_on = {reset_value} if reset_value else set()
|
|
158
141
|
else:
|
|
159
142
|
new_reset_on = set(reset_value)
|
|
160
|
-
|
|
143
|
+
|
|
161
144
|
if new_reset_on != self._reset_on:
|
|
162
|
-
self.logger.debug(
|
|
145
|
+
self.logger.debug(
|
|
146
|
+
f"Updating DTMF reset_on from {self._reset_on} to {new_reset_on}"
|
|
147
|
+
)
|
|
163
148
|
self._reset_on = new_reset_on
|
|
164
149
|
settings_changed = True
|
|
165
|
-
|
|
150
|
+
|
|
166
151
|
if settings_changed:
|
|
167
152
|
self.logger.info(f"DTMF settings updated successfully")
|
|
168
153
|
|
|
169
|
-
async def
|
|
170
|
-
"""
|
|
171
|
-
|
|
172
|
-
|
|
154
|
+
async def _handle_dtmf_frame(self, frame: InputDTMFFrame):
|
|
155
|
+
"""Handle DTMF input frame processing."""
|
|
156
|
+
# Create aggregation task if needed
|
|
157
|
+
if self._aggregation_task is None:
|
|
158
|
+
self._create_aggregation_task()
|
|
159
|
+
|
|
160
|
+
digit_value = frame.button.value
|
|
161
|
+
|
|
162
|
+
# Handle reset digits
|
|
163
|
+
if digit_value in self._reset_on:
|
|
164
|
+
self._aggregation = ""
|
|
165
|
+
return
|
|
166
|
+
|
|
167
|
+
# Handle end digits
|
|
168
|
+
if digit_value in self._end_on:
|
|
169
|
+
if self._aggregation: # Only flush if we have aggregation
|
|
170
|
+
await self.flush_aggregation()
|
|
171
|
+
return
|
|
172
|
+
|
|
173
|
+
# Add digit to aggregation
|
|
174
|
+
self._aggregation += digit_value
|
|
175
|
+
|
|
176
|
+
# Signal the aggregation task that a digit was received
|
|
177
|
+
self._digit_event.set()
|
|
178
|
+
|
|
179
|
+
# Check if we reached the digit limit
|
|
180
|
+
if self._digits and len(self._aggregation) == self._digits:
|
|
181
|
+
await self.flush_aggregation()
|
|
182
|
+
|
|
183
|
+
def _create_aggregation_task(self, raise_timeout: bool = False) -> None:
|
|
184
|
+
"""Creates the aggregation task if it hasn't been created yet."""
|
|
185
|
+
if not self._aggregation_task:
|
|
186
|
+
self._aggregation_task = self.create_task(
|
|
187
|
+
self._aggregation_task_handler(raise_timeout)
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
async def _stop_aggregation_task(self) -> None:
|
|
191
|
+
"""Stops the aggregation task."""
|
|
192
|
+
if self._aggregation_task:
|
|
193
|
+
await self.cancel_task(self._aggregation_task)
|
|
194
|
+
self._aggregation_task = None
|
|
195
|
+
|
|
196
|
+
async def _aggregation_task_handler(self, raise_timeout=False):
|
|
197
|
+
"""Background task that handles timeout-based flushing."""
|
|
173
198
|
while True:
|
|
174
199
|
try:
|
|
175
200
|
# Wait for a new digit signal with a timeout.
|
|
176
|
-
await asyncio.wait_for(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
await self.flush_aggregation(direction, raise_timeout)
|
|
180
|
-
finally:
|
|
181
|
-
# Clear the event for the next cycle.
|
|
201
|
+
await asyncio.wait_for(
|
|
202
|
+
self._digit_event.wait(), timeout=self._idle_timeout
|
|
203
|
+
)
|
|
182
204
|
self._digit_event.clear()
|
|
205
|
+
except asyncio.TimeoutError:
|
|
206
|
+
# No new digit arrived within the timeout period; flush if needed
|
|
207
|
+
await self.flush_aggregation(raise_timeout=raise_timeout)
|
|
183
208
|
|
|
184
|
-
async def flush_aggregation(self,
|
|
209
|
+
async def flush_aggregation(self, *, raise_timeout: bool = False):
|
|
185
210
|
"""Flush the aggregated digits by emitting a TranscriptionFrame downstream."""
|
|
186
211
|
if self._aggregation:
|
|
187
|
-
#
|
|
212
|
+
# Create transcription frame
|
|
188
213
|
aggregated_frame = TranscriptionFrame(
|
|
189
214
|
f"User inputted: {self._aggregation}.", "", time_now_iso8601()
|
|
190
215
|
)
|
|
191
216
|
aggregated_frame.metadata["push_aggregation"] = True
|
|
192
|
-
|
|
193
|
-
|
|
217
|
+
|
|
218
|
+
# Send interruption frame (as per original design)
|
|
219
|
+
await self.push_frame(StartInterruptionFrame(), FrameDirection.DOWNSTREAM)
|
|
220
|
+
|
|
221
|
+
# Push the transcription frame
|
|
222
|
+
await self.push_frame(aggregated_frame, FrameDirection.DOWNSTREAM)
|
|
223
|
+
|
|
224
|
+
# Reset state
|
|
194
225
|
self._aggregation = ""
|
|
195
|
-
|
|
226
|
+
await self._end_dtmf_capture()
|
|
227
|
+
|
|
228
|
+
elif raise_timeout and not self._aggregation:
|
|
229
|
+
# Timeout with no aggregation (WaitForDTMFFrame case)
|
|
196
230
|
transcript_frame = TranscriptionFrame(
|
|
197
231
|
"User didn't press any digits on the keyboard.", "", time_now_iso8601()
|
|
198
232
|
)
|
|
199
233
|
transcript_frame.metadata["push_aggregation"] = True
|
|
200
|
-
await self.push_frame(transcript_frame)
|
|
201
|
-
|
|
202
|
-
|
|
234
|
+
await self.push_frame(transcript_frame, FrameDirection.DOWNSTREAM)
|
|
235
|
+
await self._end_dtmf_capture()
|
|
236
|
+
|
|
237
|
+
async def _start_dtmf_capture(self):
|
|
238
|
+
"""Signal the start of DTMF capture upstream."""
|
|
239
|
+
if self._dtmf_capture_active:
|
|
240
|
+
return
|
|
241
|
+
await self.push_frame(StartDTMFCaptureFrame(), FrameDirection.UPSTREAM)
|
|
242
|
+
self._dtmf_capture_active = True
|
|
203
243
|
|
|
204
|
-
async def
|
|
205
|
-
"""
|
|
206
|
-
if self.
|
|
207
|
-
|
|
208
|
-
|
|
244
|
+
async def _end_dtmf_capture(self):
|
|
245
|
+
"""Signal the end of DTMF capture upstream."""
|
|
246
|
+
if not self._dtmf_capture_active:
|
|
247
|
+
return
|
|
248
|
+
await self.push_frame(EndDTMFCaptureFrame(), FrameDirection.UPSTREAM)
|
|
249
|
+
self._dtmf_capture_active = False
|
|
209
250
|
|
|
210
251
|
async def cleanup(self) -> None:
|
|
211
252
|
"""Cleans up resources, ensuring that the digit aggregation task is cancelled."""
|
|
212
253
|
await super().cleanup()
|
|
213
|
-
if self.
|
|
214
|
-
await self.
|
|
254
|
+
if self._aggregation_task:
|
|
255
|
+
await self._stop_aggregation_task()
|
|
@@ -27,12 +27,14 @@ from pipecat.frames.frames import (
|
|
|
27
27
|
InterimTranscriptionFrame,
|
|
28
28
|
StartFrame,
|
|
29
29
|
StartInterruptionFrame,
|
|
30
|
+
StartDTMFCaptureFrame,
|
|
30
31
|
STTMuteFrame,
|
|
31
32
|
TranscriptionFrame,
|
|
32
33
|
UserStartedSpeakingFrame,
|
|
33
34
|
UserStoppedSpeakingFrame,
|
|
34
35
|
VADUserStartedSpeakingFrame,
|
|
35
36
|
VADUserStoppedSpeakingFrame,
|
|
37
|
+
EndDTMFCaptureFrame,
|
|
36
38
|
)
|
|
37
39
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
|
38
40
|
|
|
@@ -58,6 +60,7 @@ class STTMuteStrategy(Enum):
|
|
|
58
60
|
FUNCTION_CALL = "function_call"
|
|
59
61
|
ALWAYS = "always"
|
|
60
62
|
CUSTOM = "custom"
|
|
63
|
+
DTMF_CAPTURE = "dtmf_capture"
|
|
61
64
|
|
|
62
65
|
|
|
63
66
|
@dataclass
|
|
@@ -120,6 +123,7 @@ class STTMuteFilter(FrameProcessor):
|
|
|
120
123
|
self._function_call_in_progress = False
|
|
121
124
|
self._is_muted = False # Initialize as unmuted, will set state on StartFrame if needed
|
|
122
125
|
self._voicemail_detection_enabled = False # Default to False
|
|
126
|
+
self._dtmf_capture_active = False
|
|
123
127
|
|
|
124
128
|
@property
|
|
125
129
|
def is_muted(self) -> bool:
|
|
@@ -165,6 +169,10 @@ class STTMuteFilter(FrameProcessor):
|
|
|
165
169
|
if should_mute:
|
|
166
170
|
return True
|
|
167
171
|
|
|
172
|
+
case STTMuteStrategy.DTMF_CAPTURE:
|
|
173
|
+
if self._dtmf_capture_active:
|
|
174
|
+
return True
|
|
175
|
+
|
|
168
176
|
return False
|
|
169
177
|
|
|
170
178
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
|
@@ -205,7 +213,14 @@ class STTMuteFilter(FrameProcessor):
|
|
|
205
213
|
self._first_speech_handled = True
|
|
206
214
|
should_mute = await self._should_mute()
|
|
207
215
|
self.logger.debug(f"BotStoppedSpeaking: should mute={should_mute}")
|
|
216
|
+
elif isinstance(frame, StartDTMFCaptureFrame):
|
|
217
|
+
self._dtmf_capture_active = True
|
|
218
|
+
should_mute = await self._should_mute()
|
|
219
|
+
elif isinstance(frame, EndDTMFCaptureFrame):
|
|
220
|
+
self._dtmf_capture_active = False
|
|
221
|
+
should_mute = await self._should_mute()
|
|
208
222
|
elif isinstance(frame, STTMuteFrame):
|
|
223
|
+
# TODO: Duplication of frame is actually happening. We get this frame from the downstream and then we again push it downstream. Also we're psuhing is upstream and again push it upstream in _handle_mute_state.
|
|
209
224
|
should_mute = frame.mute
|
|
210
225
|
|
|
211
226
|
# Then push the original frame
|
|
@@ -15,17 +15,17 @@ from loguru import logger
|
|
|
15
15
|
from pipecat.frames.frames import (
|
|
16
16
|
BotSpeakingFrame,
|
|
17
17
|
CancelFrame,
|
|
18
|
+
EndDTMFCaptureFrame,
|
|
18
19
|
EndFrame,
|
|
19
20
|
Frame,
|
|
20
21
|
FunctionCallCancelFrame,
|
|
21
22
|
FunctionCallInProgressFrame,
|
|
22
23
|
FunctionCallResultFrame,
|
|
23
24
|
InputDTMFFrame,
|
|
25
|
+
StartDTMFCaptureFrame,
|
|
26
|
+
StartFrame,
|
|
24
27
|
StartUserIdleProcessorFrame,
|
|
25
28
|
StopUserIdleProcessorFrame,
|
|
26
|
-
FunctionCallInProgressFrame,
|
|
27
|
-
FunctionCallResultFrame,
|
|
28
|
-
StartFrame,
|
|
29
29
|
UserStartedSpeakingFrame,
|
|
30
30
|
UserStoppedSpeakingFrame,
|
|
31
31
|
)
|
|
@@ -83,6 +83,8 @@ class UserIdleProcessor(FrameProcessor):
|
|
|
83
83
|
self._timeout = timeout
|
|
84
84
|
self._retry_count = 0
|
|
85
85
|
self._interrupted = False
|
|
86
|
+
self._function_call_active = False
|
|
87
|
+
self._dtmf_capture_active = False
|
|
86
88
|
self._conversation_started = False
|
|
87
89
|
self._idle_task = None
|
|
88
90
|
self._idle_event = asyncio.Event()
|
|
@@ -180,10 +182,20 @@ class UserIdleProcessor(FrameProcessor):
|
|
|
180
182
|
self._idle_event.set()
|
|
181
183
|
elif isinstance(frame, FunctionCallInProgressFrame):
|
|
182
184
|
# Function calls can take longer than the timeout, so we want to prevent idle callbacks
|
|
185
|
+
self._function_call_active = True
|
|
183
186
|
self._interrupted = True
|
|
184
187
|
self._idle_event.set()
|
|
185
188
|
elif isinstance(frame, FunctionCallResultFrame):
|
|
186
|
-
self.
|
|
189
|
+
self._function_call_active = False
|
|
190
|
+
self._interrupted = self._dtmf_capture_active
|
|
191
|
+
self._idle_event.set()
|
|
192
|
+
elif isinstance(frame, StartDTMFCaptureFrame):
|
|
193
|
+
self._dtmf_capture_active = True
|
|
194
|
+
self._interrupted = True
|
|
195
|
+
self._idle_event.set()
|
|
196
|
+
elif isinstance(frame, EndDTMFCaptureFrame):
|
|
197
|
+
self._dtmf_capture_active = False
|
|
198
|
+
self._interrupted = self._function_call_active
|
|
187
199
|
self._idle_event.set()
|
|
188
200
|
elif isinstance(frame, StartUserIdleProcessorFrame):
|
|
189
201
|
if not self._idle_task:
|
|
File without changes
|
{dv_pipecat_ai-0.0.82.dev69.dist-info → dv_pipecat_ai-0.0.82.dev70.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|