deepgram
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 5# version 6__version__ = "0.0.0" 7 8# entry point for the deepgram python sdk 9import logging 10from .utils import VerboseLogger 11from .utils import ( 12 NOTICE, 13 SPAM, 14 SUCCESS, 15 VERBOSE, 16 WARNING, 17 ERROR, 18 FATAL, 19 CRITICAL, 20 INFO, 21 DEBUG, 22 NOTSET, 23) 24 25from .client import Deepgram, DeepgramClient 26from .client import DeepgramClientOptions, ClientOptionsFromEnv 27from .client import ( 28 DeepgramError, 29 DeepgramTypeError, 30 DeepgramModuleError, 31 DeepgramApiError, 32 DeepgramUnknownApiError, 33) 34from .errors import DeepgramApiKeyError 35 36# listen/read client 37from .client import ListenRouter, ReadRouter, SpeakRouter, AgentRouter 38 39# common 40from .client import ( 41 TextSource, 42 BufferSource, 43 StreamSource, 44 FileSource, 45 UrlSource, 46) 47from .client import BaseResponse 48from .client import ( 49 Average, 50 Intent, 51 Intents, 52 IntentsInfo, 53 Segment, 54 SentimentInfo, 55 Sentiment, 56 Sentiments, 57 SummaryInfo, 58 Topic, 59 Topics, 60 TopicsInfo, 61) 62from .client import ( 63 ModelInfo, 64 Hit, 65 Search, 66) 67from .client import ( 68 OpenResponse, 69 CloseResponse, 70 UnhandledResponse, 71 ErrorResponse, 72) 73 74# speect-to-text WS 75from .client import LiveClient, AsyncLiveClient # backward compat 76from .client import ListenWebSocketClient, AsyncListenWebSocketClient 77from .client import LiveTranscriptionEvents 78from .client import LiveOptions, ListenWebSocketOptions 79from .client import ( 80 #### top level 81 LiveResultResponse, 82 ListenWSMetadataResponse, 83 SpeechStartedResponse, 84 UtteranceEndResponse, 85 #### common websocket response 86 # OpenResponse, 87 # CloseResponse, 88 # UnhandledResponse, 89 # ErrorResponse, 90 #### unique 91 ListenWSMetadata, 92 ListenWSAlternative, 93 ListenWSChannel, 94 ListenWSWord, 95) 96 97# prerecorded 98from .client import PreRecordedClient, AsyncPreRecordedClient # backward compat 99from .client import ListenRESTClient, AsyncListenRESTClient 100from .client import ( 101 # common 102 # UrlSource, 103 # BufferSource, 104 # StreamSource, 105 # TextSource, 106 # FileSource, 107 # unique 108 PreRecordedStreamSource, 109 PrerecordedSource, 110 ListenRestSource, 111 SpeakRESTSource, 112) 113from .client import ( 114 ListenRESTOptions, 115 PrerecordedOptions, 116) 117from .client import ( 118 #### top level 119 AsyncPrerecordedResponse, 120 PrerecordedResponse, 121 SyncPrerecordedResponse, 122 #### shared 123 # Average, 124 # Alternative, 125 # Channel, 126 # Intent, 127 # Intents, 128 # IntentsInfo, 129 # Segment, 130 # SentimentInfo, 131 # Sentiment, 132 # Sentiments, 133 # SummaryInfo, 134 # Topic, 135 # Topics, 136 # TopicsInfo, 137 # Word, 138 #### unique 139 Entity, 140 Hit, 141 ListenRESTMetadata, 142 ModelInfo, 143 Paragraph, 144 Paragraphs, 145 ListenRESTResults, 146 Search, 147 Sentence, 148 Summaries, 149 SummaryV1, 150 SummaryV2, 151 Translation, 152 Utterance, 153 Warning, 154 ListenRESTAlternative, 155 ListenRESTChannel, 156 ListenRESTWord, 157) 158 159# read 160from .client import ReadClient, AsyncReadClient 161from .client import AnalyzeClient, AsyncAnalyzeClient 162from .client import ( 163 AnalyzeOptions, 164 AnalyzeStreamSource, 165 AnalyzeSource, 166) 167from .client import ( 168 #### top level 169 AsyncAnalyzeResponse, 170 SyncAnalyzeResponse, 171 AnalyzeResponse, 172 #### shared 173 # Average, 174 # Intent, 175 # Intents, 176 # IntentsInfo, 177 # Segment, 178 # SentimentInfo, 179 # Sentiment, 180 # Sentiments, 181 # SummaryInfo, 182 # Topic, 183 # Topics, 184 # TopicsInfo, 185 #### unique 186 AnalyzeMetadata, 187 AnalyzeResults, 188 AnalyzeSummary, 189) 190 191# speak 192## speak REST 193from .client import ( 194 #### top level 195 SpeakRESTOptions, 196 SpeakOptions, # backward compat 197 #### common 198 # TextSource, 199 # BufferSource, 200 # StreamSource, 201 # FileSource, 202 #### unique 203 SpeakSource, 204 SpeakRestSource, 205) 206 207from .client import ( 208 SpeakClient, # backward compat 209 SpeakRESTClient, 210 AsyncSpeakRESTClient, 211) 212 213from .client import ( 214 SpeakResponse, # backward compat 215 SpeakRESTResponse, 216) 217 218## speak WebSocket 219from .client import SpeakWebSocketEvents, SpeakWebSocketMessage 220 221from .client import ( 222 SpeakWSOptions, 223) 224 225from .client import ( 226 SpeakWebSocketClient, 227 AsyncSpeakWebSocketClient, 228 SpeakWSClient, 229 AsyncSpeakWSClient, 230) 231 232from .client import ( 233 #### top level 234 SpeakWSMetadataResponse, 235 FlushedResponse, 236 ClearedResponse, 237 WarningResponse, 238 #### common websocket response 239 # OpenResponse, 240 # CloseResponse, 241 # UnhandledResponse, 242 # ErrorResponse, 243) 244 245# manage 246from .client import ManageClient, AsyncManageClient 247from .client import ( 248 ProjectOptions, 249 KeyOptions, 250 ScopeOptions, 251 InviteOptions, 252 UsageRequestOptions, 253 UsageSummaryOptions, 254 UsageFieldsOptions, 255) 256 257# manage client responses 258from .client import ( 259 #### top level 260 Message, 261 ProjectsResponse, 262 ModelResponse, 263 ModelsResponse, 264 MembersResponse, 265 KeyResponse, 266 KeysResponse, 267 ScopesResponse, 268 InvitesResponse, 269 UsageRequest, 270 UsageResponse, 271 UsageRequestsResponse, 272 UsageSummaryResponse, 273 UsageFieldsResponse, 274 BalancesResponse, 275 #### shared 276 Project, 277 STTDetails, 278 TTSMetadata, 279 TTSDetails, 280 Member, 281 Key, 282 Invite, 283 Config, 284 STTUsageDetails, 285 Callback, 286 TokenDetail, 287 SpeechSegment, 288 TTSUsageDetails, 289 STTTokens, 290 TTSTokens, 291 UsageSummaryResults, 292 Resolution, 293 UsageModel, 294 Balance, 295) 296 297# selfhosted 298from .client import ( 299 OnPremClient, 300 AsyncOnPremClient, 301 SelfHostedClient, 302 AsyncSelfHostedClient, 303) 304 305 306# agent 307from .client import AgentWebSocketEvents 308 309# websocket 310from .client import ( 311 AgentWebSocketClient, 312 AsyncAgentWebSocketClient, 313) 314 315from .client import ( 316 #### common websocket response 317 # OpenResponse, 318 # CloseResponse, 319 # ErrorResponse, 320 # UnhandledResponse, 321 #### unique 322 WelcomeResponse, 323 SettingsAppliedResponse, 324 ConversationTextResponse, 325 UserStartedSpeakingResponse, 326 AgentThinkingResponse, 327 FunctionCalling, 328 FunctionCallRequest, 329 AgentStartedSpeakingResponse, 330 AgentAudioDoneResponse, 331 InjectionRefusedResponse, 332) 333 334from .client import ( 335 # top level 336 SettingsConfigurationOptions, 337 UpdateInstructionsOptions, 338 UpdateSpeakOptions, 339 InjectAgentMessageOptions, 340 FunctionCallResponse, 341 AgentKeepAlive, 342 # sub level 343 Listen, 344 Speak, 345 Header, 346 Item, 347 Properties, 348 Parameters, 349 Function, 350 Provider, 351 Think, 352 Agent, 353 Input, 354 Output, 355 Audio, 356 Context, 357) 358 359# utilities 360# pylint: disable=wrong-import-position 361from .audio import Microphone, DeepgramMicrophoneError 362from .audio import ( 363 INPUT_LOGGING, 364 INPUT_CHANNELS, 365 INPUT_RATE, 366 INPUT_CHUNK, 367) 368 369LOGGING = INPUT_LOGGING 370CHANNELS = INPUT_CHANNELS 371RATE = INPUT_RATE 372CHUNK = INPUT_CHUNK 373 374from .audio import Speaker 375from .audio import ( 376 OUTPUT_LOGGING, 377 OUTPUT_CHANNELS, 378 OUTPUT_RATE, 379 OUTPUT_CHUNK, 380) 381 382# pylint: enable=wrong-import-position
LOGGING =
30
CHANNELS =
1
RATE =
16000
CHUNK =
8194