diff --git a/CHANGELOG.md b/CHANGELOG.md index 870550b9c..e974f5eee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,9 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `GoogleSTTService`, `GoogleTTSService`, and `GoogleVertexLLMService`. - Added support for Smart Turn Detection via the `turn_analyzer` transport - parameter. You can now choose between `SmartTurnAnalyzer()` for remote - inference or `LocalCoreMLSmartTurnAnalyzer()` for on-device inference using - Core ML. + parameter. You can now choose between `HttpSmartTurnAnalyzer()` or + `FalSmartTurnAnalyzer()` for remote inference or + `LocalCoreMLSmartTurnAnalyzer()` for on-device inference using Core ML. - `DeepgramTTSService` accepts `base_url` argument again, allowing you to connect to an on-prem service. diff --git a/dot-env.template b/dot-env.template index 18ddbee0a..c5a34d708 100644 --- a/dot-env.template +++ b/dot-env.template @@ -95,5 +95,5 @@ OPENROUTER_API_KEY=... PIPER_BASE_URL=... # Smart turn -LOCAL_SMART_TURN_MODEL_PATH= -REMOTE_SMART_TURN_URL= \ No newline at end of file +LOCAL_SMART_TURN_MODEL_PATH=... +FAL_SMART_TURN_API_KEY=... diff --git a/examples/foundational/38-smart-turn.py b/examples/foundational/38-smart-turn-fal.py similarity index 93% rename from examples/foundational/38-smart-turn.py rename to examples/foundational/38-smart-turn-fal.py index ea32c69ed..9b22c63f6 100644 --- a/examples/foundational/38-smart-turn.py +++ b/examples/foundational/38-smart-turn-fal.py @@ -10,7 +10,7 @@ import aiohttp from dotenv import load_dotenv from loguru import logger -from pipecat.audio.turn.http_smart_turn import HttpSmartTurnAnalyzer +from pipecat.audio.turn.smart_turn.fal_smart_turn import FalSmartTurnAnalyzer from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.audio.vad.vad_analyzer import VADParams from pipecat.pipeline.pipeline import Pipeline @@ -30,8 +30,6 @@ load_dotenv(override=True) async def run_bot(webrtc_connection: SmallWebRTCConnection): logger.info(f"Starting bot") - remote_smart_turn_url = os.getenv("REMOTE_SMART_TURN_URL") - async with aiohttp.ClientSession() as session: transport = SmallWebRTCTransport( webrtc_connection=webrtc_connection, @@ -41,8 +39,8 @@ async def run_bot(webrtc_connection: SmallWebRTCConnection): vad_enabled=True, vad_analyzer=SileroVADAnalyzer(params=VADParams(stop_secs=0.2)), vad_audio_passthrough=True, - turn_analyzer=HttpSmartTurnAnalyzer( - url=remote_smart_turn_url, aiohttp_session=session + turn_analyzer=FalSmartTurnAnalyzer( + api_key=os.getenv("FAL_SMART_TURN_API_KEY"), aiohttp_session=session ), ), ) diff --git a/examples/foundational/38a-local-smart-turn.py b/examples/foundational/38a-smart-turn-local-coreml.py similarity index 96% rename from examples/foundational/38a-local-smart-turn.py rename to examples/foundational/38a-smart-turn-local-coreml.py index 856cc69b6..4fa889656 100644 --- a/examples/foundational/38a-local-smart-turn.py +++ b/examples/foundational/38a-smart-turn-local-coreml.py @@ -9,8 +9,8 @@ import os from dotenv import load_dotenv from loguru import logger -from pipecat.audio.turn.base_smart_turn import SmartTurnParams -from pipecat.audio.turn.local_coreml_smart_turn import LocalCoreMLSmartTurnAnalyzer +from pipecat.audio.turn.smart_turn.base_smart_turn import SmartTurnParams +from pipecat.audio.turn.smart_turn.local_coreml_smart_turn import LocalCoreMLSmartTurnAnalyzer from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.audio.vad.vad_analyzer import VADParams from pipecat.pipeline.pipeline import Pipeline diff --git a/src/pipecat/audio/turn/smart_turn/__init__.py b/src/pipecat/audio/turn/smart_turn/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/pipecat/audio/turn/base_smart_turn.py b/src/pipecat/audio/turn/smart_turn/base_smart_turn.py similarity index 100% rename from src/pipecat/audio/turn/base_smart_turn.py rename to src/pipecat/audio/turn/smart_turn/base_smart_turn.py diff --git a/src/pipecat/audio/turn/fal_smart_turn.py b/src/pipecat/audio/turn/smart_turn/fal_smart_turn.py similarity index 88% rename from src/pipecat/audio/turn/fal_smart_turn.py rename to src/pipecat/audio/turn/smart_turn/fal_smart_turn.py index 7e7974ed1..9e3a85b56 100644 --- a/src/pipecat/audio/turn/fal_smart_turn.py +++ b/src/pipecat/audio/turn/smart_turn/fal_smart_turn.py @@ -8,7 +8,7 @@ from typing import Optional import aiohttp -from pipecat.audio.turn.http_smart_turn import HttpSmartTurnAnalyzer +from pipecat.audio.turn.smart_turn.http_smart_turn import HttpSmartTurnAnalyzer class FalSmartTurnAnalyzer(HttpSmartTurnAnalyzer): diff --git a/src/pipecat/audio/turn/http_smart_turn.py b/src/pipecat/audio/turn/smart_turn/http_smart_turn.py similarity index 96% rename from src/pipecat/audio/turn/http_smart_turn.py rename to src/pipecat/audio/turn/smart_turn/http_smart_turn.py index 4c1fb8491..4f542f81d 100644 --- a/src/pipecat/audio/turn/http_smart_turn.py +++ b/src/pipecat/audio/turn/smart_turn/http_smart_turn.py @@ -12,7 +12,7 @@ import aiohttp import numpy as np from loguru import logger -from pipecat.audio.turn.base_smart_turn import BaseSmartTurn, SmartTurnTimeoutException +from pipecat.audio.turn.smart_turn.base_smart_turn import BaseSmartTurn, SmartTurnTimeoutException class HttpSmartTurnAnalyzer(BaseSmartTurn): diff --git a/src/pipecat/audio/turn/local_coreml_smart_turn.py b/src/pipecat/audio/turn/smart_turn/local_coreml_smart_turn.py similarity index 93% rename from src/pipecat/audio/turn/local_coreml_smart_turn.py rename to src/pipecat/audio/turn/smart_turn/local_coreml_smart_turn.py index 5e59f474a..88d6530bd 100644 --- a/src/pipecat/audio/turn/local_coreml_smart_turn.py +++ b/src/pipecat/audio/turn/smart_turn/local_coreml_smart_turn.py @@ -10,7 +10,7 @@ from typing import Any, Dict import numpy as np from loguru import logger -from pipecat.audio.turn.base_smart_turn import BaseSmartTurn +from pipecat.audio.turn.smart_turn.base_smart_turn import BaseSmartTurn try: import coremltools as ct @@ -25,7 +25,7 @@ except ModuleNotFoundError as e: class LocalCoreMLSmartTurnAnalyzer(BaseSmartTurn): - def __init__(self, smart_turn_model_path: str, **kwargs): + def __init__(self, *, smart_turn_model_path: str, **kwargs): super().__init__(**kwargs) if not smart_turn_model_path: