deepgram.clients.prerecorded.v1.client
1# Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. 2# Use of this source code is governed by a MIT license that can be found in the LICENSE file. 3# SPDX-License-Identifier: MIT 4 5from ...listen import PreRecordedClient as PreRecordedClientLatest 6from ...listen import AsyncPreRecordedClient as AsyncPreRecordedClientLatest 7from ...listen import ( 8 PrerecordedOptions as PrerecordedOptionsLatest, 9 UrlSource as UrlSourceLatest, 10 FileSource as FileSourceLatest, 11 PreRecordedStreamSource as PreRecordedStreamSourceLatest, 12 PrerecordedSource as PrerecordedSourceLatest, 13) 14from ...listen import ( 15 AsyncPrerecordedResponse as AsyncPrerecordedResponseLatest, 16 PrerecordedResponse as PrerecordedResponseLatest, 17 SyncPrerecordedResponse as SyncPrerecordedResponseLatest, 18) 19 20 21# input 22PrerecordedOptions = PrerecordedOptionsLatest 23PreRecordedStreamSource = PreRecordedStreamSourceLatest 24UrlSource = UrlSourceLatest 25FileSource = FileSourceLatest 26PrerecordedSource = PrerecordedSourceLatest 27 28 29# output 30AsyncPrerecordedResponse = AsyncPrerecordedResponseLatest 31PrerecordedResponse = PrerecordedResponseLatest 32SyncPrerecordedResponse = SyncPrerecordedResponseLatest 33 34 35# clients 36PreRecordedClient = PreRecordedClientLatest 37AsyncPreRecordedClient = AsyncPreRecordedClientLatest
23@dataclass 24class PrerecordedOptions(BaseResponse): # pylint: disable=too-many-instance-attributes 25 """ 26 Contains all the options for the PrerecordedClient. 27 28 Reference: 29 https://developers.deepgram.com/reference/pre-recorded 30 """ 31 32 alternatives: Optional[int] = field( 33 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 34 ) 35 channels: Optional[int] = field( 36 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 37 ) 38 callback: Optional[str] = field( 39 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 40 ) 41 callback_method: Optional[str] = field( 42 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 43 ) 44 custom_intent: Optional[Union[List[str], str]] = field( 45 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 46 ) 47 custom_intent_mode: Optional[str] = field( 48 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 49 ) 50 custom_topic: Optional[Union[List[str], str]] = field( 51 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 52 ) 53 custom_topic_mode: Optional[str] = field( 54 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 55 ) 56 detect_entities: Optional[bool] = field( 57 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 58 ) 59 detect_language: Optional[bool] = field( 60 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 61 ) 62 detect_topics: Optional[bool] = field( 63 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 64 ) 65 diarize: Optional[bool] = field( 66 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 67 ) 68 diarize_version: Optional[str] = field( 69 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 70 ) 71 dictation: Optional[bool] = field( 72 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 73 ) 74 encoding: Optional[str] = field( 75 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 76 ) 77 extra: Optional[Union[List[str], str]] = field( 78 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 79 ) 80 filler_words: Optional[bool] = field( 81 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 82 ) 83 intents: Optional[bool] = field( 84 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 85 ) 86 keyterm: Optional[List[str]] = field( 87 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 88 ) 89 keywords: Optional[Union[List[str], str]] = field( 90 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 91 ) 92 language: Optional[str] = field( 93 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 94 ) 95 measurements: Optional[bool] = field( 96 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 97 ) 98 model: Optional[str] = field( 99 default="None", metadata=dataclass_config(exclude=lambda f: f is None) 100 ) 101 multichannel: Optional[bool] = field( 102 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 103 ) 104 numerals: Optional[bool] = field( 105 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 106 ) 107 paragraphs: Optional[bool] = field( 108 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 109 ) 110 profanity_filter: Optional[bool] = field( 111 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 112 ) 113 punctuate: Optional[bool] = field( 114 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 115 ) 116 redact: Optional[Union[List[str], bool, str]] = field( 117 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 118 ) 119 replace: Optional[Union[List[str], str]] = field( 120 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 121 ) 122 sample_rate: Optional[int] = field( 123 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 124 ) 125 search: Optional[Union[List[str], str]] = field( 126 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 127 ) 128 sentiment: Optional[bool] = field( 129 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 130 ) 131 smart_format: Optional[bool] = field( 132 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 133 ) 134 summarize: Optional[Union[bool, str]] = field( 135 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 136 ) 137 tag: Optional[List[str]] = field( 138 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 139 ) 140 tier: Optional[str] = field( 141 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 142 ) 143 topics: Optional[bool] = field( 144 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 145 ) 146 utt_split: Optional[float] = field( 147 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 148 ) 149 utterances: Optional[bool] = field( 150 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 151 ) 152 version: Optional[str] = field( 153 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 154 ) 155 156 def check(self): 157 """ 158 Check the options for any deprecated fields or values. 159 """ 160 logger = verboselogs.VerboseLogger(__name__) 161 logger.addHandler(logging.StreamHandler()) 162 prev = logger.level 163 logger.setLevel(verboselogs.ERROR) 164 165 if self.tier: 166 logger.error( 167 "WARNING: Tier is deprecated. Will be removed in a future version." 168 ) 169 170 logger.setLevel(prev) 171 172 return True
Contains all the options for the PrerecordedClient.
Reference: https://developers.deepgram.com/reference/pre-recorded
PrerecordedOptions( alternatives: Optional[int] = None, channels: Optional[int] = None, callback: Optional[str] = None, callback_method: Optional[str] = None, custom_intent: Union[List[str], str, NoneType] = None, custom_intent_mode: Optional[str] = None, custom_topic: Union[List[str], str, NoneType] = None, custom_topic_mode: Optional[str] = None, detect_entities: Optional[bool] = None, detect_language: Optional[bool] = None, detect_topics: Optional[bool] = None, diarize: Optional[bool] = None, diarize_version: Optional[str] = None, dictation: Optional[bool] = None, encoding: Optional[str] = None, extra: Union[List[str], str, NoneType] = None, filler_words: Optional[bool] = None, intents: Optional[bool] = None, keyterm: Optional[List[str]] = None, keywords: Union[List[str], str, NoneType] = None, language: Optional[str] = None, measurements: Optional[bool] = None, model: Optional[str] = 'None', multichannel: Optional[bool] = None, numerals: Optional[bool] = None, paragraphs: Optional[bool] = None, profanity_filter: Optional[bool] = None, punctuate: Optional[bool] = None, redact: Union[List[str], bool, str, NoneType] = None, replace: Union[List[str], str, NoneType] = None, sample_rate: Optional[int] = None, search: Union[List[str], str, NoneType] = None, sentiment: Optional[bool] = None, smart_format: Optional[bool] = None, summarize: Union[bool, str, NoneType] = None, tag: Optional[List[str]] = None, tier: Optional[str] = None, topics: Optional[bool] = None, utt_split: Optional[float] = None, utterances: Optional[bool] = None, version: Optional[str] = None)
def
check(self):
156 def check(self): 157 """ 158 Check the options for any deprecated fields or values. 159 """ 160 logger = verboselogs.VerboseLogger(__name__) 161 logger.addHandler(logging.StreamHandler()) 162 prev = logger.level 163 logger.setLevel(verboselogs.ERROR) 164 165 if self.tier: 166 logger.error( 167 "WARNING: Tier is deprecated. Will be removed in a future version." 168 ) 169 170 logger.setLevel(prev) 171 172 return True
Check the options for any deprecated fields or values.
Inherited Members
PreRecordedStreamSource =
<class 'deepgram.clients.common.StreamSource'>
class
UrlSource(typing_extensions.TypedDict):
25class UrlSource(TypedDict): 26 """ 27 Represents a data source for specifying the location of a file via a URL. 28 29 This class is used to specify a hosted file URL, typically pointing to an 30 externally hosted file, such as an audio file hosted on a server or the internet. 31 32 Attributes: 33 url (str): The URL pointing to the hosted file. 34 """ 35 36 url: str
Represents a data source for specifying the location of a file via a URL.
This class is used to specify a hosted file URL, typically pointing to an externally hosted file, such as an audio file hosted on a server or the internet.
Attributes: url (str): The URL pointing to the hosted file.
FileSource =
typing.Union[deepgram.clients.common.TextSource, deepgram.clients.common.BufferSource, deepgram.clients.common.StreamSource]
PrerecordedSource =
typing.Union[UrlSource, deepgram.clients.common.TextSource, deepgram.clients.common.BufferSource, deepgram.clients.common.StreamSource]
38@dataclass 39class AsyncPrerecordedResponse(BaseResponse): 40 """ 41 The response object for the async prerecorded API. 42 """ 43 44 request_id: str = ""
The response object for the async prerecorded API.
Inherited Members
449@dataclass 450class PrerecordedResponse(BaseResponse): 451 """ 452 The response object for the prerecorded API. 453 """ 454 455 metadata: Optional[Metadata] = field( 456 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 457 ) 458 results: Optional[Results] = field( 459 default=None, metadata=dataclass_config(exclude=lambda f: f is None) 460 ) 461 462 def __getitem__(self, key): 463 _dict = self.to_dict() 464 if "metadata" in _dict: 465 _dict["metadata"] = Metadata.from_dict(_dict["metadata"]) 466 if "results" in _dict: 467 _dict["results"] = Results.from_dict(_dict["results"]) 468 return _dict[key]
The response object for the prerecorded API.
PrerecordedResponse( metadata: Optional[deepgram.clients.listen.v1.rest.response.Metadata] = None, results: Optional[deepgram.clients.listen.v1.rest.response.Results] = None)
Inherited Members
SyncPrerecordedResponse =
<class 'PrerecordedResponse'>
PreRecordedClient =
<class 'deepgram.clients.listen.v1.rest.client.ListenRESTClient'>
AsyncPreRecordedClient =
<class 'deepgram.clients.listen.v1.rest.async_client.AsyncListenRESTClient'>