fix for Deepgram settings not merging
This commit is contained in:
@@ -14,7 +14,7 @@ from pipecat.pipeline.pipeline import Pipeline
|
|||||||
from pipecat.pipeline.runner import PipelineRunner
|
from pipecat.pipeline.runner import PipelineRunner
|
||||||
from pipecat.pipeline.task import PipelineTask
|
from pipecat.pipeline.task import PipelineTask
|
||||||
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
||||||
from pipecat.services.deepgram import DeepgramSTTService
|
from pipecat.services.deepgram import DeepgramSTTService, LiveOptions, Language
|
||||||
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
||||||
|
|
||||||
from runner import configure
|
from runner import configure
|
||||||
@@ -45,7 +45,10 @@ async def main():
|
|||||||
room_url, None, "Transcription bot", DailyParams(audio_in_enabled=True)
|
room_url, None, "Transcription bot", DailyParams(audio_in_enabled=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
stt = DeepgramSTTService(
|
||||||
|
api_key=os.getenv("DEEPGRAM_API_KEY"),
|
||||||
|
# live_options=LiveOptions(language=Language.FR),
|
||||||
|
)
|
||||||
|
|
||||||
tl = TranscriptionLogger()
|
tl = TranscriptionLogger()
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ try:
|
|||||||
LiveResultResponse,
|
LiveResultResponse,
|
||||||
LiveTranscriptionEvents,
|
LiveTranscriptionEvents,
|
||||||
SpeakOptions,
|
SpeakOptions,
|
||||||
|
logging,
|
||||||
)
|
)
|
||||||
except ModuleNotFoundError as e:
|
except ModuleNotFoundError as e:
|
||||||
logger.error(f"Exception: {e}")
|
logger.error(f"Exception: {e}")
|
||||||
@@ -118,7 +119,11 @@ class DeepgramSTTService(STTService):
|
|||||||
*,
|
*,
|
||||||
api_key: str,
|
api_key: str,
|
||||||
url: str = "",
|
url: str = "",
|
||||||
live_options: LiveOptions = LiveOptions(
|
live_options: LiveOptions = None,
|
||||||
|
**kwargs,
|
||||||
|
):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
default_options = LiveOptions(
|
||||||
encoding="linear16",
|
encoding="linear16",
|
||||||
language=Language.EN,
|
language=Language.EN,
|
||||||
model="nova-2-conversationalai",
|
model="nova-2-conversationalai",
|
||||||
@@ -129,15 +134,19 @@ class DeepgramSTTService(STTService):
|
|||||||
punctuate=True,
|
punctuate=True,
|
||||||
profanity_filter=True,
|
profanity_filter=True,
|
||||||
vad_events=False,
|
vad_events=False,
|
||||||
),
|
)
|
||||||
**kwargs,
|
|
||||||
):
|
|
||||||
super().__init__(**kwargs)
|
|
||||||
|
|
||||||
self._settings = vars(live_options)
|
merged_options = default_options
|
||||||
|
if live_options:
|
||||||
|
merged_options = LiveOptions(**{**default_options.to_dict(), **live_options.to_dict()})
|
||||||
|
self._settings = merged_options
|
||||||
|
|
||||||
self._client = DeepgramClient(
|
self._client = DeepgramClient(
|
||||||
api_key, config=DeepgramClientOptions(url=url, options={"keepalive": "true"})
|
api_key,
|
||||||
|
config=DeepgramClientOptions(
|
||||||
|
url=url,
|
||||||
|
options={"keepalive": "true"}, # verbose=logging.DEBUG
|
||||||
|
),
|
||||||
)
|
)
|
||||||
self._connection: AsyncListenWebSocketClient = self._client.listen.asyncwebsocket.v("1")
|
self._connection: AsyncListenWebSocketClient = self._client.listen.asyncwebsocket.v("1")
|
||||||
self._connection.on(LiveTranscriptionEvents.Transcript, self._on_message)
|
self._connection.on(LiveTranscriptionEvents.Transcript, self._on_message)
|
||||||
|
|||||||
Reference in New Issue
Block a user