move pipecat.frames.frames.KeypadEntry to pipecat.audio.dtmf.types.KeypadEntry
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@@ -5,6 +5,18 @@ All notable changes to **Pipecat** will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
|
||||||
|
- `pipecat.frames.frames.KeypadEntry` is deprecated and has been moved to
|
||||||
|
`pipecat.audio.dtmf.types.KeypadEntry`.
|
||||||
|
|
||||||
|
## Deprecated
|
||||||
|
|
||||||
|
- `pipecat.frames.frames.KeypadEntry` is deprecated use
|
||||||
|
`pipecat.audio.dtmf.types.KeypadEntry` instead.
|
||||||
|
|
||||||
## [0.0.82] - 2025-08-28
|
## [0.0.82] - 2025-08-28
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
0
src/pipecat/audio/dtmf/__init__.py
Normal file
0
src/pipecat/audio/dtmf/__init__.py
Normal file
47
src/pipecat/audio/dtmf/types.py
Normal file
47
src/pipecat/audio/dtmf/types.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Copyright (c) 2024–2025, Daily
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD 2-Clause License
|
||||||
|
#
|
||||||
|
|
||||||
|
"""This module defines generic type for DTMS.
|
||||||
|
|
||||||
|
It defines the `KeypadEntry` enumeration, representing dual-tone multi-frequency
|
||||||
|
(DTMF) keypad entries for phone system integration. Each entry corresponds to a
|
||||||
|
key on the telephone keypad, facilitating the handling of input in
|
||||||
|
telecommunication applications.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class KeypadEntry(str, Enum):
|
||||||
|
"""DTMF keypad entries for phone system integration.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
ONE: Number key 1.
|
||||||
|
TWO: Number key 2.
|
||||||
|
THREE: Number key 3.
|
||||||
|
FOUR: Number key 4.
|
||||||
|
FIVE: Number key 5.
|
||||||
|
SIX: Number key 6.
|
||||||
|
SEVEN: Number key 7.
|
||||||
|
EIGHT: Number key 8.
|
||||||
|
NINE: Number key 9.
|
||||||
|
ZERO: Number key 0.
|
||||||
|
POUND: Pound/hash key (#).
|
||||||
|
STAR: Star/asterisk key (*).
|
||||||
|
"""
|
||||||
|
|
||||||
|
ONE = "1"
|
||||||
|
TWO = "2"
|
||||||
|
THREE = "3"
|
||||||
|
FOUR = "4"
|
||||||
|
FIVE = "5"
|
||||||
|
SIX = "6"
|
||||||
|
SEVEN = "7"
|
||||||
|
EIGHT = "8"
|
||||||
|
NINE = "9"
|
||||||
|
ZERO = "0"
|
||||||
|
|
||||||
|
POUND = "#"
|
||||||
|
STAR = "*"
|
||||||
@@ -12,7 +12,6 @@ and LLM processing.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from enum import Enum
|
|
||||||
from typing import (
|
from typing import (
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
Any,
|
Any,
|
||||||
@@ -28,6 +27,7 @@ from typing import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from pipecat.adapters.schemas.tools_schema import ToolsSchema
|
from pipecat.adapters.schemas.tools_schema import ToolsSchema
|
||||||
|
from pipecat.audio.dtmf.types import KeypadEntry as NewKeypadEntry
|
||||||
from pipecat.audio.interruptions.base_interruption_strategy import BaseInterruptionStrategy
|
from pipecat.audio.interruptions.base_interruption_strategy import BaseInterruptionStrategy
|
||||||
from pipecat.audio.turn.smart_turn.base_smart_turn import SmartTurnParams
|
from pipecat.audio.turn.smart_turn.base_smart_turn import SmartTurnParams
|
||||||
from pipecat.audio.vad.vad_analyzer import VADParams
|
from pipecat.audio.vad.vad_analyzer import VADParams
|
||||||
@@ -41,9 +41,13 @@ if TYPE_CHECKING:
|
|||||||
from pipecat.processors.frame_processor import FrameProcessor
|
from pipecat.processors.frame_processor import FrameProcessor
|
||||||
|
|
||||||
|
|
||||||
class KeypadEntry(str, Enum):
|
class DeprecatedKeypadEntry:
|
||||||
"""DTMF keypad entries for phone system integration.
|
"""DTMF keypad entries for phone system integration.
|
||||||
|
|
||||||
|
.. deprecated:: 0.0.82
|
||||||
|
This class is deprecated and will be removed in a future version.
|
||||||
|
Instead, use `audio.dtmf.types.KeypadEntry`.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
ONE: Number key 1.
|
ONE: Number key 1.
|
||||||
TWO: Number key 2.
|
TWO: Number key 2.
|
||||||
@@ -59,18 +63,38 @@ class KeypadEntry(str, Enum):
|
|||||||
STAR: Star/asterisk key (*).
|
STAR: Star/asterisk key (*).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ONE = "1"
|
_enum = NewKeypadEntry
|
||||||
TWO = "2"
|
|
||||||
THREE = "3"
|
@classmethod
|
||||||
FOUR = "4"
|
def _warn(cls):
|
||||||
FIVE = "5"
|
import warnings
|
||||||
SIX = "6"
|
|
||||||
SEVEN = "7"
|
with warnings.catch_warnings():
|
||||||
EIGHT = "8"
|
warnings.simplefilter("always")
|
||||||
NINE = "9"
|
warnings.warn(
|
||||||
ZERO = "0"
|
"`pipecat.frames.frames.KeypadEntry` is deprecated and will be removed in a future version. "
|
||||||
POUND = "#"
|
"Use `pipecat.audio.dtmf.types.KeypadEntry` instead.",
|
||||||
STAR = "*"
|
DeprecationWarning,
|
||||||
|
stacklevel=2,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __call__(self, *args: Any, **kwargs: Any) -> Any:
|
||||||
|
"""Allow the instance to be called as a function."""
|
||||||
|
self._warn()
|
||||||
|
return self._enum(*args, **kwargs)
|
||||||
|
|
||||||
|
def __getattr__(self, name):
|
||||||
|
"""Retrieve an attribute from the underlying enum."""
|
||||||
|
self._warn()
|
||||||
|
return getattr(self._enum, name)
|
||||||
|
|
||||||
|
def __getitem__(self, name):
|
||||||
|
"""Retrieve an item from the underlying enum."""
|
||||||
|
self._warn()
|
||||||
|
return self._enum[name]
|
||||||
|
|
||||||
|
|
||||||
|
KeypadEntry = DeprecatedKeypadEntry()
|
||||||
|
|
||||||
|
|
||||||
def format_pts(pts: Optional[int]):
|
def format_pts(pts: Optional[int]):
|
||||||
@@ -526,15 +550,16 @@ class LLMMessagesFrame(DataFrame):
|
|||||||
super().__post_init__()
|
super().__post_init__()
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
warnings.simplefilter("always")
|
with warnings.catch_warnings():
|
||||||
warnings.warn(
|
warnings.simplefilter("always")
|
||||||
"LLMMessagesFrame is deprecated and will be removed in a future version. "
|
warnings.warn(
|
||||||
"Instead, use either "
|
"LLMMessagesFrame is deprecated and will be removed in a future version. "
|
||||||
"`LLMMessagesUpdateFrame` with `run_llm=True`, or "
|
"Instead, use either "
|
||||||
"`OpenAILLMContextFrame` with desired messages in a new context",
|
"`LLMMessagesUpdateFrame` with `run_llm=True`, or "
|
||||||
DeprecationWarning,
|
"`OpenAILLMContextFrame` with desired messages in a new context",
|
||||||
stacklevel=2,
|
DeprecationWarning,
|
||||||
)
|
stacklevel=2,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -668,7 +693,7 @@ class DTMFFrame:
|
|||||||
button: The DTMF keypad entry that was pressed.
|
button: The DTMF keypad entry that was pressed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
button: KeypadEntry
|
button: NewKeypadEntry
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ for downstream processing by LLM context aggregators.
|
|||||||
import asyncio
|
import asyncio
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from pipecat.audio.dtmf.types import KeypadEntry
|
||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
BotInterruptionFrame,
|
BotInterruptionFrame,
|
||||||
CancelFrame,
|
CancelFrame,
|
||||||
EndFrame,
|
EndFrame,
|
||||||
Frame,
|
Frame,
|
||||||
InputDTMFFrame,
|
InputDTMFFrame,
|
||||||
KeypadEntry,
|
|
||||||
StartFrame,
|
StartFrame,
|
||||||
TranscriptionFrame,
|
TranscriptionFrame,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ from typing import Optional
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from pipecat.audio.dtmf.types import KeypadEntry
|
||||||
from pipecat.audio.utils import create_stream_resampler
|
from pipecat.audio.utils import create_stream_resampler
|
||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
AudioRawFrame,
|
AudioRawFrame,
|
||||||
Frame,
|
Frame,
|
||||||
InputAudioRawFrame,
|
InputAudioRawFrame,
|
||||||
InputDTMFFrame,
|
InputDTMFFrame,
|
||||||
KeypadEntry,
|
|
||||||
StartFrame,
|
StartFrame,
|
||||||
StartInterruptionFrame,
|
StartInterruptionFrame,
|
||||||
TransportMessageFrame,
|
TransportMessageFrame,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from typing import Optional
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from pipecat.audio.dtmf.types import KeypadEntry
|
||||||
from pipecat.audio.utils import create_stream_resampler, pcm_to_ulaw, ulaw_to_pcm
|
from pipecat.audio.utils import create_stream_resampler, pcm_to_ulaw, ulaw_to_pcm
|
||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
AudioRawFrame,
|
AudioRawFrame,
|
||||||
@@ -21,7 +22,6 @@ from pipecat.frames.frames import (
|
|||||||
Frame,
|
Frame,
|
||||||
InputAudioRawFrame,
|
InputAudioRawFrame,
|
||||||
InputDTMFFrame,
|
InputDTMFFrame,
|
||||||
KeypadEntry,
|
|
||||||
StartFrame,
|
StartFrame,
|
||||||
StartInterruptionFrame,
|
StartInterruptionFrame,
|
||||||
TransportMessageFrame,
|
TransportMessageFrame,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import aiohttp
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from pipecat.audio.dtmf.types import KeypadEntry
|
||||||
from pipecat.audio.utils import (
|
from pipecat.audio.utils import (
|
||||||
alaw_to_pcm,
|
alaw_to_pcm,
|
||||||
create_stream_resampler,
|
create_stream_resampler,
|
||||||
@@ -28,7 +29,6 @@ from pipecat.frames.frames import (
|
|||||||
Frame,
|
Frame,
|
||||||
InputAudioRawFrame,
|
InputAudioRawFrame,
|
||||||
InputDTMFFrame,
|
InputDTMFFrame,
|
||||||
KeypadEntry,
|
|
||||||
StartFrame,
|
StartFrame,
|
||||||
StartInterruptionFrame,
|
StartInterruptionFrame,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from typing import Optional
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from pipecat.audio.dtmf.types import KeypadEntry
|
||||||
from pipecat.audio.utils import create_stream_resampler, pcm_to_ulaw, ulaw_to_pcm
|
from pipecat.audio.utils import create_stream_resampler, pcm_to_ulaw, ulaw_to_pcm
|
||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
AudioRawFrame,
|
AudioRawFrame,
|
||||||
@@ -21,7 +22,6 @@ from pipecat.frames.frames import (
|
|||||||
Frame,
|
Frame,
|
||||||
InputAudioRawFrame,
|
InputAudioRawFrame,
|
||||||
InputDTMFFrame,
|
InputDTMFFrame,
|
||||||
KeypadEntry,
|
|
||||||
StartFrame,
|
StartFrame,
|
||||||
StartInterruptionFrame,
|
StartInterruptionFrame,
|
||||||
TransportMessageFrame,
|
TransportMessageFrame,
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from pipecat.audio.dtmf.types import KeypadEntry
|
||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
EndFrame,
|
EndFrame,
|
||||||
InputDTMFFrame,
|
InputDTMFFrame,
|
||||||
KeypadEntry,
|
|
||||||
TranscriptionFrame,
|
TranscriptionFrame,
|
||||||
)
|
)
|
||||||
from pipecat.processors.aggregators.dtmf_aggregator import DTMFAggregator
|
from pipecat.processors.aggregators.dtmf_aggregator import DTMFAggregator
|
||||||
|
|||||||
Reference in New Issue
Block a user