|
1 | | -# Copyright 2023 Deepgram SDK contributors. All Rights Reserved. |
| 1 | +# Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. |
2 | 2 | # Use of this source code is governed by a MIT license that can be found in the LICENSE file. |
3 | 3 | # SPDX-License-Identifier: MIT |
4 | 4 |
|
|
8 | 8 | import logging, verboselogs |
9 | 9 |
|
10 | 10 | from ...abstract_async_client import AbstractAsyncRestClient |
11 | | -from ..errors import DeepgramTypeError |
| 11 | +from ..errors import DeepgramError, DeepgramTypeError |
12 | 12 | from ..helpers import is_buffer_source, is_readstream_source, is_url_source |
13 | 13 | from ..source import UrlSource, FileSource |
14 | 14 |
|
@@ -68,6 +68,11 @@ async def transcribe_url( |
68 | 68 | self.logger.debug("PreRecordedClient.transcribe_url LEAVE") |
69 | 69 | raise DeepgramTypeError("Unknown transcription source type") |
70 | 70 |
|
| 71 | + if options is not None and not options.check(): |
| 72 | + self.logger.error("options.check failed") |
| 73 | + self.logger.debug("PreRecordedClient.transcribe_url LEAVE") |
| 74 | + raise DeepgramError("Fatal transcription options error") |
| 75 | + |
71 | 76 | self.logger.info("url: %s", url) |
72 | 77 | self.logger.info("source: %s", source) |
73 | 78 | if isinstance(options, PrerecordedOptions): |
@@ -123,6 +128,11 @@ async def transcribe_url_callback( |
123 | 128 | self.logger.debug("PreRecordedClient.transcribe_url_callback LEAVE") |
124 | 129 | raise DeepgramTypeError("Unknown transcription source type") |
125 | 130 |
|
| 131 | + if options is not None and not options.check(): |
| 132 | + self.logger.error("options.check failed") |
| 133 | + self.logger.debug("PreRecordedClient.transcribe_url_callback LEAVE") |
| 134 | + raise DeepgramError("Fatal transcription options error") |
| 135 | + |
126 | 136 | self.logger.info("url: %s", url) |
127 | 137 | self.logger.info("source: %s", source) |
128 | 138 | if isinstance(options, PrerecordedOptions): |
@@ -181,6 +191,11 @@ async def transcribe_file( |
181 | 191 | self.logger.debug("PreRecordedClient.transcribe_file LEAVE") |
182 | 192 | raise DeepgramTypeError("Unknown transcription source type") |
183 | 193 |
|
| 194 | + if options is not None and not options.check(): |
| 195 | + self.logger.error("options.check failed") |
| 196 | + self.logger.debug("PreRecordedClient.transcribe_file LEAVE") |
| 197 | + raise DeepgramError("Fatal transcription options error") |
| 198 | + |
184 | 199 | self.logger.info("url: %s", url) |
185 | 200 | if isinstance(options, PrerecordedOptions): |
186 | 201 | self.logger.info("PrerecordedOptions switching class -> json") |
@@ -237,6 +252,11 @@ async def transcribe_file_callback( |
237 | 252 | self.logger.debug("PreRecordedClient.transcribe_file_callback LEAVE") |
238 | 253 | raise DeepgramTypeError("Unknown transcription source type") |
239 | 254 |
|
| 255 | + if options is not None and not options.check(): |
| 256 | + self.logger.error("options.check failed") |
| 257 | + self.logger.debug("PreRecordedClient.transcribe_file_callback LEAVE") |
| 258 | + raise DeepgramError("Fatal transcription options error") |
| 259 | + |
240 | 260 | self.logger.info("url: %s", url) |
241 | 261 | if isinstance(options, PrerecordedOptions): |
242 | 262 | self.logger.info("PrerecordedOptions switching class -> json") |
|
0 commit comments