Update prewarm; fix issues with recent commits
This commit is contained in:
+9
-5
@@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
from livekit import rtc
|
||||||
from livekit.agents import (
|
from livekit.agents import (
|
||||||
Agent,
|
Agent,
|
||||||
AgentServer,
|
AgentServer,
|
||||||
@@ -46,13 +47,14 @@ class Assistant(Agent):
|
|||||||
# return "sunny with a temperature of 70 degrees."
|
# return "sunny with a temperature of 70 degrees."
|
||||||
|
|
||||||
|
|
||||||
|
server = AgentServer()
|
||||||
|
|
||||||
|
|
||||||
def prewarm(proc: JobProcess):
|
def prewarm(proc: JobProcess):
|
||||||
proc.userdata["vad"] = silero.VAD.load()
|
proc.userdata["vad"] = silero.VAD.load()
|
||||||
|
|
||||||
|
|
||||||
server = AgentServer(
|
server.setup_fnc = prewarm
|
||||||
setup_fnc = prewarm,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@server.rtc_session()
|
@server.rtc_session()
|
||||||
@@ -107,9 +109,11 @@ async def my_agent(ctx: JobContext):
|
|||||||
await session.start(
|
await session.start(
|
||||||
agent=Assistant(),
|
agent=Assistant(),
|
||||||
room=ctx.room,
|
room=ctx.room,
|
||||||
room_options=room_io.RoomOptions(
|
room_options=room_io.RoomOptions(
|
||||||
audio_input=room_io.AudioInputOptions(
|
audio_input=room_io.AudioInputOptions(
|
||||||
noise_cancellation=lambda params: noise_cancellation.BVCTelephony() if params.participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP else noise_cancellation.BVC(),
|
noise_cancellation=lambda params: noise_cancellation.BVCTelephony()
|
||||||
|
if params.participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP
|
||||||
|
else noise_cancellation.BVC(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user