Skip to content

Commit

Permalink
Merge pull request #70 from deepgram/toggle-numerals
Browse files Browse the repository at this point in the history
added toggle function
  • Loading branch information
briancbarrow authored Jan 30, 2023
2 parents fc4f363 + 98fd298 commit 9988b68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions deepgram/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class LiveOptions(TranscriptionOptions, total=False):
channels: int
sample_rate: int

class ToggleConfigOptions(TypedDict):
numerals: bool

class WordBase(TypedDict):
word: str
Expand Down
9 changes: 8 additions & 1 deletion deepgram/transcription.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -296,6 +296,13 @@ def send(self, data: Union[bytes, str]) -> None:

self._queue.put_nowait((False, data))

def configure(self, config: ToggleConfigOptions) -> None:
"""Sends messages to configure transcription parameters mid-stream."""
self._queue.put_nowait((False, json.dumps({
"type": "Configure",
"processors": config
})))

async def finish(self) -> None:
"""Closes the connection to the Deepgram endpoint,
waiting until ASR is complete on all submitted data."""
Expand Down

0 comments on commit 9988b68

Please sign in to comment.