Revert "Add is_local_development utility for a cleaner API to determine if running locally"
This reverts commit 471311b18f.
This commit is contained in:
@@ -30,7 +30,6 @@ from pipecat.runner.types import (
|
|||||||
DailyRunnerArguments,
|
DailyRunnerArguments,
|
||||||
SmallWebRTCRunnerArguments,
|
SmallWebRTCRunnerArguments,
|
||||||
WebSocketRunnerArguments,
|
WebSocketRunnerArguments,
|
||||||
is_local_development,
|
|
||||||
)
|
)
|
||||||
from pipecat.services.cartesia.tts import CartesiaTTSService
|
from pipecat.services.cartesia.tts import CartesiaTTSService
|
||||||
from pipecat.services.deepgram.stt import DeepgramSTTService
|
from pipecat.services.deepgram.stt import DeepgramSTTService
|
||||||
@@ -38,6 +37,9 @@ from pipecat.services.openai.llm import OpenAILLMService
|
|||||||
|
|
||||||
load_dotenv(override=True)
|
load_dotenv(override=True)
|
||||||
|
|
||||||
|
# Check if we're running locally
|
||||||
|
IS_LOCAL_RUN = os.environ.get("LOCAL_RUN", "0") == "1"
|
||||||
|
|
||||||
|
|
||||||
async def run_bot(transport):
|
async def run_bot(transport):
|
||||||
"""Main bot logic that works with any transport."""
|
"""Main bot logic that works with any transport."""
|
||||||
@@ -109,22 +111,18 @@ async def bot(
|
|||||||
if isinstance(session_args, DailyRunnerArguments):
|
if isinstance(session_args, DailyRunnerArguments):
|
||||||
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
||||||
|
|
||||||
is_local = is_local_development()
|
if not IS_LOCAL_RUN:
|
||||||
|
|
||||||
if not is_local:
|
|
||||||
from pipecat.audio.filters.krisp_filter import KrispFilter
|
from pipecat.audio.filters.krisp_filter import KrispFilter
|
||||||
|
|
||||||
krisp_filter = KrispFilter()
|
|
||||||
else:
|
|
||||||
krisp_filter = None
|
|
||||||
|
|
||||||
transport = DailyTransport(
|
transport = DailyTransport(
|
||||||
session_args.room_url,
|
session_args.room_url,
|
||||||
session_args.token,
|
session_args.token,
|
||||||
"Pipecat Bot",
|
"Pipecat Bot",
|
||||||
params=DailyParams(
|
params=DailyParams(
|
||||||
audio_in_enabled=True,
|
audio_in_enabled=True,
|
||||||
audio_in_filter=krisp_filter,
|
audio_in_filter=None
|
||||||
|
if IS_LOCAL_RUN
|
||||||
|
else KrispFilter(), # Only use Krisp in production
|
||||||
audio_out_enabled=True,
|
audio_out_enabled=True,
|
||||||
vad_analyzer=SileroVADAnalyzer(),
|
vad_analyzer=SileroVADAnalyzer(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ from pipecat.runner.types import (
|
|||||||
DailyRunnerArguments,
|
DailyRunnerArguments,
|
||||||
SmallWebRTCRunnerArguments,
|
SmallWebRTCRunnerArguments,
|
||||||
)
|
)
|
||||||
from pipecat.runner.utils import is_local_development
|
|
||||||
from pipecat.services.cartesia.tts import CartesiaTTSService
|
from pipecat.services.cartesia.tts import CartesiaTTSService
|
||||||
from pipecat.services.deepgram.stt import DeepgramSTTService
|
from pipecat.services.deepgram.stt import DeepgramSTTService
|
||||||
from pipecat.services.openai.llm import OpenAILLMService
|
from pipecat.services.openai.llm import OpenAILLMService
|
||||||
@@ -31,6 +30,10 @@ from pipecat.services.openai.llm import OpenAILLMService
|
|||||||
load_dotenv(override=True)
|
load_dotenv(override=True)
|
||||||
|
|
||||||
|
|
||||||
|
# Check if we're running locally
|
||||||
|
IS_LOCAL_RUN = os.environ.get("LOCAL_RUN", "0") == "1"
|
||||||
|
|
||||||
|
|
||||||
async def run_bot(transport):
|
async def run_bot(transport):
|
||||||
"""Main bot logic that works with any transport."""
|
"""Main bot logic that works with any transport."""
|
||||||
logger.info(f"Starting bot")
|
logger.info(f"Starting bot")
|
||||||
@@ -99,22 +102,18 @@ async def bot(session_args: DailyRunnerArguments | SmallWebRTCRunnerArguments):
|
|||||||
if isinstance(session_args, DailyRunnerArguments):
|
if isinstance(session_args, DailyRunnerArguments):
|
||||||
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
||||||
|
|
||||||
is_local = is_local_development()
|
if not IS_LOCAL_RUN:
|
||||||
|
|
||||||
if not is_local:
|
|
||||||
from pipecat.audio.filters.krisp_filter import KrispFilter
|
from pipecat.audio.filters.krisp_filter import KrispFilter
|
||||||
|
|
||||||
krisp_filter = KrispFilter()
|
|
||||||
else:
|
|
||||||
krisp_filter = None
|
|
||||||
|
|
||||||
transport = DailyTransport(
|
transport = DailyTransport(
|
||||||
session_args.room_url,
|
session_args.room_url,
|
||||||
session_args.token,
|
session_args.token,
|
||||||
"Pipecat Bot",
|
"Pipecat Bot",
|
||||||
params=DailyParams(
|
params=DailyParams(
|
||||||
audio_in_enabled=True,
|
audio_in_enabled=True,
|
||||||
audio_in_filter=krisp_filter,
|
audio_in_filter=None
|
||||||
|
if IS_LOCAL_RUN
|
||||||
|
else KrispFilter(), # Only use Krisp in production
|
||||||
audio_out_enabled=True,
|
audio_out_enabled=True,
|
||||||
vad_analyzer=SileroVADAnalyzer(),
|
vad_analyzer=SileroVADAnalyzer(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ except ImportError as e:
|
|||||||
|
|
||||||
|
|
||||||
load_dotenv(override=True)
|
load_dotenv(override=True)
|
||||||
|
os.environ["LOCAL_RUN"] = "1"
|
||||||
|
|
||||||
|
|
||||||
def _get_bot_module():
|
def _get_bot_module():
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ Example::
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from typing import Any, Callable, Dict, Optional
|
from typing import Any, Callable, Dict, Optional
|
||||||
|
|
||||||
from fastapi import WebSocket
|
from fastapi import WebSocket
|
||||||
@@ -480,13 +479,3 @@ async def create_transport(
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unsupported session arguments type: {type(session_args)}")
|
raise ValueError(f"Unsupported session arguments type: {type(session_args)}")
|
||||||
|
|
||||||
|
|
||||||
def is_local_development() -> bool:
|
|
||||||
"""Detect if running in local development environment.
|
|
||||||
|
|
||||||
Returns True if the pipecat development runner is being used.
|
|
||||||
This works by detecting if pipecat.runner.run has been imported,
|
|
||||||
which only happens when running locally via the development runner.
|
|
||||||
"""
|
|
||||||
return "pipecat.runner.run" in sys.modules
|
|
||||||
|
|||||||
Reference in New Issue
Block a user