Skip to content

Commit 1326c24

Browse files
committed
drop bargein base class
1 parent a785e42 commit 1326c24

File tree

9 files changed

+325
-360
lines changed

9 files changed

+325
-360
lines changed

examples/bargein_server.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
4747
class BargeinRequest(BaseModel):
4848
"""Request model for bargein detection."""
4949

50-
jobId: str = Field(..., description="Job ID from LiveKit")
51-
workerId: str = Field(..., description="Worker ID from LiveKit")
5250
waveform: str = Field(..., description="Base64-encoded audio waveform (float32)")
53-
agentId: str | None = Field(None, description="Optional agent ID")
5451
threshold: float = Field(0.95, description="Threshold for bargein detection")
5552
min_frames: int = Field(2, description="Minimum number of frames for bargein detection")
5653
created_at: float = Field(..., description="Timestamp of the audio waveform")
@@ -144,9 +141,6 @@ async def detect_bargein(request: BargeinRequest) -> BargeinResponse:
144141
Returns:
145142
BargeinResponse with detection result
146143
"""
147-
logger.info(
148-
f"Received bargein detection request for job={request.jobId}, worker={request.workerId}"
149-
)
150144

151145
if onnx_session is None:
152146
raise HTTPException(

examples/voice_agents/basic_agent.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
MetricsCollectedEvent,
1212
RunContext,
1313
cli,
14+
inference,
1415
metrics,
1516
room_io,
1617
)
17-
from livekit.agents.inference.bargein import BargeinDetector
1818
from livekit.agents.llm import function_tool
1919
from livekit.plugins import silero
2020
from livekit.plugins.turn_detector.multilingual import MultilingualModel
@@ -37,7 +37,7 @@ def __init__(self) -> None:
3737
"you will speak english to the user",
3838
)
3939

40-
async def on_enter(self):
40+
async def on_enter(self) -> None:
4141
# when the agent is added to the session, it'll generate a reply
4242
# according to its instructions
4343
self.session.generate_reply()
@@ -47,7 +47,7 @@ async def on_enter(self):
4747
@function_tool
4848
async def lookup_weather(
4949
self, context: RunContext, location: str, latitude: str, longitude: str
50-
):
50+
) -> str:
5151
"""Called when the user asks for weather related information.
5252
Ensure the user's location (city or region) is provided.
5353
When given a location, please estimate the latitude and longitude of the location and
@@ -67,20 +67,20 @@ async def lookup_weather(
6767
server = AgentServer()
6868

6969

70-
def prewarm(proc: JobProcess):
70+
def prewarm(proc: JobProcess) -> None:
7171
proc.userdata["vad"] = silero.VAD.load()
7272

7373

7474
server.setup_fnc = prewarm
7575

7676

7777
@server.rtc_session()
78-
async def entrypoint(ctx: JobContext):
78+
async def entrypoint(ctx: JobContext) -> None:
7979
# each log entry will include these fields
8080
ctx.log_context_fields = {
8181
"room": ctx.room.name,
8282
}
83-
session = AgentSession(
83+
session: AgentSession = AgentSession(
8484
# Speech-to-text (STT) is your agent's ears, turning the user's speech into text that the LLM can understand
8585
# See all available models at https://docs.livekit.io/agents/models/stt/
8686
stt="deepgram/nova-3",
@@ -94,7 +94,7 @@ async def entrypoint(ctx: JobContext):
9494
# See more at https://docs.livekit.io/agents/build/turns
9595
turn_detection=MultilingualModel(),
9696
vad=ctx.proc.userdata["vad"],
97-
bargein_detector=BargeinDetector(),
97+
bargein_detector=inference.BargeinDetector(),
9898
# allow the LLM to generate a response while waiting for the end of turn
9999
# See more at https://docs.livekit.io/agents/build/audio/#preemptive-generation
100100
preemptive_generation=True,
@@ -108,11 +108,11 @@ async def entrypoint(ctx: JobContext):
108108
usage_collector = metrics.UsageCollector()
109109

110110
@session.on("metrics_collected")
111-
def _on_metrics_collected(ev: MetricsCollectedEvent):
111+
def _on_metrics_collected(ev: MetricsCollectedEvent) -> None:
112112
metrics.log_metrics(ev.metrics)
113113
usage_collector.collect(ev.metrics)
114114

115-
async def log_usage():
115+
async def log_usage() -> None:
116116
summary = usage_collector.get_summary()
117117
logger.info(f"Usage: {summary}")
118118

livekit-agents/livekit/agents/bargein.py

Lines changed: 0 additions & 277 deletions
This file was deleted.

livekit-agents/livekit/agents/inference/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
from .bargein import (
2+
BargeinDetector,
3+
BargeinError,
4+
BargeinEvent,
5+
BargeinEventType,
6+
BargeinStreamBase,
7+
)
18
from .llm import LLM, LLMModels, LLMStream
29
from .stt import STT, STTModels
310
from .tts import TTS, TTSModels
@@ -10,4 +17,9 @@
1017
"STTModels",
1118
"TTSModels",
1219
"LLMModels",
20+
"BargeinDetector",
21+
"BargeinStreamBase",
22+
"BargeinEvent",
23+
"BargeinError",
24+
"BargeinEventType",
1325
]

0 commit comments

Comments
 (0)