From 056f5860c66aa14f32027b8f3bd2b77cf0079104 Mon Sep 17 00:00:00 2001 From: Brian Barrow Date: Thu, 5 Jan 2023 11:38:42 -0700 Subject: [PATCH 1/3] added toggle function --- deepgram/transcription.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/deepgram/transcription.py b/deepgram/transcription.py index 62188aa8..b3f45700 100644 --- a/deepgram/transcription.py +++ b/deepgram/transcription.py @@ -296,6 +296,15 @@ def send(self, data: Union[bytes, str]) -> None: self._queue.put_nowait((False, data)) + def toggle_numerals(self, toggle: bool) -> None: + """Toggles whether or not numerals are included in the transcription.""" + self._queue.put_nowait((False, json.dumps({ + "type": "Configure", + "processors": { + "numerals": toggle + } + }))) + async def finish(self) -> None: """Closes the connection to the Deepgram endpoint, waiting until ASR is complete on all submitted data.""" From d7fff383b15afb1227a32643d275e65be95a3b3b Mon Sep 17 00:00:00 2001 From: Brian Barrow Date: Wed, 25 Jan 2023 13:18:46 -0700 Subject: [PATCH 2/3] updated function to take in a ToggleConfigOptions in order to expand the functionality in the future --- deepgram/_types.py | 2 ++ deepgram/transcription.py | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deepgram/_types.py b/deepgram/_types.py index 7fa08d2c..343f78fd 100644 --- a/deepgram/_types.py +++ b/deepgram/_types.py @@ -108,6 +108,8 @@ class LiveOptions(TranscriptionOptions, total=False): channels: int sample_rate: int +class ToggleConfigOptions(TypedDict): + numerals: bool class WordBase(TypedDict): word: str diff --git a/deepgram/transcription.py b/deepgram/transcription.py index b3f45700..5a73ba70 100644 --- a/deepgram/transcription.py +++ b/deepgram/transcription.py @@ -5,7 +5,7 @@ from enum import Enum from warnings import warn import websockets.client -from ._types import (Options, PrerecordedOptions, LiveOptions, +from ._types import (Options, PrerecordedOptions, LiveOptions, ToggleConfigOptions, TranscriptionSource, PrerecordedTranscriptionResponse, LiveTranscriptionResponse, Metadata, EventHandler) from ._enums import LiveTranscriptionEvent @@ -296,13 +296,11 @@ def send(self, data: Union[bytes, str]) -> None: self._queue.put_nowait((False, data)) - def toggle_numerals(self, toggle: bool) -> None: + def configure(self, config: ToggleConfigOptions) -> None: """Toggles whether or not numerals are included in the transcription.""" self._queue.put_nowait((False, json.dumps({ "type": "Configure", - "processors": { - "numerals": toggle - } + "processors": config }))) async def finish(self) -> None: From 98fd298e395765c5ae8b104f6d07cb9f34c6efb7 Mon Sep 17 00:00:00 2001 From: Brian Barrow Date: Mon, 30 Jan 2023 09:49:28 -0700 Subject: [PATCH 3/3] updated comment to indicate configure is not just for numerals --- deepgram/transcription.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepgram/transcription.py b/deepgram/transcription.py index 5a73ba70..e0930582 100644 --- a/deepgram/transcription.py +++ b/deepgram/transcription.py @@ -297,7 +297,7 @@ def send(self, data: Union[bytes, str]) -> None: self._queue.put_nowait((False, data)) def configure(self, config: ToggleConfigOptions) -> None: - """Toggles whether or not numerals are included in the transcription.""" + """Sends messages to configure transcription parameters mid-stream.""" self._queue.put_nowait((False, json.dumps({ "type": "Configure", "processors": config