processors(realtime-ai): add silero vad to the transport
This commit is contained in:
@@ -13,6 +13,7 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask
|
|||||||
from pipecat.pipeline.runner import PipelineRunner
|
from pipecat.pipeline.runner import PipelineRunner
|
||||||
from pipecat.processors.frameworks.realtimeai import RealtimeAIProcessor
|
from pipecat.processors.frameworks.realtimeai import RealtimeAIProcessor
|
||||||
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
||||||
|
from pipecat.vad.silero import SileroVADAnalyzer
|
||||||
|
|
||||||
from runner import configure
|
from runner import configure
|
||||||
|
|
||||||
@@ -31,9 +32,10 @@ async def main(room_url, token):
|
|||||||
token,
|
token,
|
||||||
"Realtime AI",
|
"Realtime AI",
|
||||||
DailyParams(
|
DailyParams(
|
||||||
audio_in_enabled=True,
|
|
||||||
audio_out_enabled=True,
|
audio_out_enabled=True,
|
||||||
transcription_enabled=True,
|
transcription_enabled=True,
|
||||||
|
vad_enabled=True,
|
||||||
|
vad_analyzer=SileroVADAnalyzer()
|
||||||
))
|
))
|
||||||
|
|
||||||
rtai = RealtimeAIProcessor(
|
rtai = RealtimeAIProcessor(
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ from pipecat.services.ai_services import AIService
|
|||||||
from pipecat.services.cartesia import CartesiaTTSService
|
from pipecat.services.cartesia import CartesiaTTSService
|
||||||
from pipecat.services.openai import OpenAILLMService
|
from pipecat.services.openai import OpenAILLMService
|
||||||
from pipecat.transports.base_transport import BaseTransport
|
from pipecat.transports.base_transport import BaseTransport
|
||||||
from pipecat.vad.silero import SileroVAD
|
|
||||||
|
|
||||||
DEFAULT_MESSAGES = [
|
DEFAULT_MESSAGES = [
|
||||||
{
|
{
|
||||||
@@ -141,8 +140,6 @@ class RealtimeAIProcessor(FrameProcessor):
|
|||||||
|
|
||||||
async def _handle_setup(self, setup: RealtimeAISetup | None):
|
async def _handle_setup(self, setup: RealtimeAISetup | None):
|
||||||
try:
|
try:
|
||||||
vad = SileroVAD()
|
|
||||||
|
|
||||||
model = DEFAULT_MODEL
|
model = DEFAULT_MODEL
|
||||||
if setup and setup.config and setup.config.llm and setup.config.llm.model:
|
if setup and setup.config and setup.config.llm and setup.config.llm.model:
|
||||||
model = setup.config.llm.model
|
model = setup.config.llm.model
|
||||||
@@ -166,7 +163,6 @@ class RealtimeAIProcessor(FrameProcessor):
|
|||||||
self._tts = self._tts_cls(api_key=self._tts_api_key, voice_id=voice)
|
self._tts = self._tts_cls(api_key=self._tts_api_key, voice_id=voice)
|
||||||
|
|
||||||
pipeline = Pipeline([
|
pipeline = Pipeline([
|
||||||
vad,
|
|
||||||
self._tma_in,
|
self._tma_in,
|
||||||
self._llm,
|
self._llm,
|
||||||
self._tts,
|
self._tts,
|
||||||
@@ -220,8 +216,7 @@ class RealtimeAIProcessor(FrameProcessor):
|
|||||||
# send any messages. So, we setup a super basic pipeline with just the
|
# send any messages. So, we setup a super basic pipeline with just the
|
||||||
# output transport so we can send messages.
|
# output transport so we can send messages.
|
||||||
if not self._pipeline:
|
if not self._pipeline:
|
||||||
# We add the SilerVAD() so the audio doesn't go through.
|
pipeline = Pipeline([self._transport.output()])
|
||||||
pipeline = Pipeline([SileroVAD(), self._transport.output()])
|
|
||||||
self._pipeline = pipeline
|
self._pipeline = pipeline
|
||||||
|
|
||||||
parent = self.get_parent()
|
parent = self.get_parent()
|
||||||
|
|||||||
Reference in New Issue
Block a user