generated from deepgram/oss-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6eb043a
commit 6c0dcad
Showing
41 changed files
with
2,257 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved. | ||
# Use of this source code is governed by a MIT license that can be found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
from .client import AnalyzeClient | ||
from .client import AsyncAnalyzeClient | ||
from .client import AnalyzeOptions | ||
from .client import Sentiment | ||
from .source import ( | ||
AnalyzeSource, | ||
TextSource, | ||
UrlSource, | ||
BufferSource, | ||
AnalyzeStreamSource, | ||
) | ||
from .client import AsyncAnalyzeResponse, AnalyzeResponse, SyncAnalyzeResponse | ||
|
||
from ...options import DeepgramClientOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. | ||
# Use of this source code is governed by a MIT license that can be found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
from .v1.client import AnalyzeClient as AnalyzeClientLatest | ||
from .v1.async_client import AsyncAnalyzeClient as AsyncAnalyzeClientLatest | ||
from .v1.options import AnalyzeOptions as AnalyzeOptionsLatest | ||
from .source import AnalyzeSource, TextSource, UrlSource | ||
from .v1.response import ( | ||
SyncAnalyzeResponse as SyncAnalyzeResponseLatest, | ||
AnalyzeResponse as AnalyzeResponseLatest, | ||
AsyncAnalyzeResponse as AsyncAnalyzeResponseLatest, | ||
) | ||
from .enums import Sentiment | ||
|
||
""" | ||
The client.py points to the current supported version in the SDK. | ||
Older versions are supported in the SDK for backwards compatibility. | ||
""" | ||
|
||
|
||
# input | ||
class AnalyzeOptions(AnalyzeOptionsLatest): | ||
""" | ||
Please see AnalyzeOptionsLatest for details | ||
""" | ||
|
||
pass | ||
|
||
|
||
class AsyncAnalyzeResponse(AsyncAnalyzeResponseLatest): | ||
""" | ||
Please see AnalyzeResponseLatest for details | ||
""" | ||
|
||
pass | ||
|
||
|
||
class AnalyzeResponse(AnalyzeResponseLatest): | ||
""" | ||
Please see AnalyzeResponseLatest for details | ||
""" | ||
|
||
pass | ||
|
||
|
||
class SyncAnalyzeResponse(SyncAnalyzeResponseLatest): | ||
""" | ||
Please see AnalyzeResponseLatest for details | ||
""" | ||
|
||
pass | ||
|
||
|
||
# clients | ||
class AnalyzeClient(AnalyzeClientLatest): | ||
""" | ||
Please see AnalyzeClientLatest for details | ||
""" | ||
|
||
def __init__(self, config): | ||
self.config = config | ||
super().__init__(config) | ||
|
||
|
||
class AsyncAnalyzeClient(AsyncAnalyzeClientLatest): | ||
""" | ||
Please see AsyncAnalyzeClientLatest for details | ||
""" | ||
|
||
def __init__(self, config): | ||
super().__init__(config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. | ||
# Use of this source code is governed by a MIT license that can be found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
from enum import Enum | ||
|
||
""" | ||
Constants mapping to events from the Deepgram API | ||
""" | ||
|
||
|
||
class Sentiment(Enum): | ||
UNKNOWN = "" | ||
NEGATIVE = "negative" | ||
NEUTRAL = "neutral" | ||
POSITIVE = "positive" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. | ||
# Use of this source code is governed by a MIT license that can be found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
|
||
class DeepgramError(Exception): | ||
""" | ||
Exception raised for unknown errors related to the Deepgram API. | ||
Attributes: | ||
message (str): The error message describing the exception. | ||
""" | ||
|
||
def __init__(self, message: str): | ||
super().__init__(message) | ||
self.name = "DeepgramError" | ||
self.message = message | ||
|
||
def __str__(self): | ||
return f"{self.name}: {self.message}" | ||
|
||
|
||
class DeepgramTypeError(Exception): | ||
""" | ||
Exception raised for unknown errors related to unknown Types for Transcription. | ||
Attributes: | ||
message (str): The error message describing the exception. | ||
""" | ||
|
||
def __init__(self, message: str): | ||
super().__init__(message) | ||
self.name = "DeepgramTypeError" | ||
self.message = message | ||
|
||
def __str__(self): | ||
return f"{self.name}: {self.message}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved. | ||
# Use of this source code is governed by a MIT license that can be found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
from .source import AnalyzeSource | ||
|
||
|
||
def is_buffer_source(provided_source: AnalyzeSource) -> bool: | ||
return "buffer" in provided_source | ||
|
||
|
||
def is_readstream_source(provided_source: AnalyzeSource) -> bool: | ||
return "stream" in provided_source | ||
|
||
|
||
def is_url_source(provided_source: AnalyzeSource) -> bool: | ||
return "url" in provided_source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved. | ||
# Use of this source code is governed by a MIT license that can be found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
from typing import Union | ||
from io import BufferedReader | ||
from typing_extensions import TypedDict | ||
|
||
|
||
class AnalyzeStreamSource(TypedDict): | ||
""" | ||
Represents a data source for reading binary data from a stream-like source. | ||
This class is used to specify a source of binary data that can be read from | ||
a stream, such as an audio file in .wav format. | ||
Attributes: | ||
stream (BufferedReader): A BufferedReader object for reading binary data. | ||
""" | ||
|
||
stream: BufferedReader | ||
|
||
|
||
class UrlSource(TypedDict): | ||
""" | ||
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. | ||
""" | ||
|
||
url: str | ||
|
||
|
||
class BufferSource(TypedDict): | ||
""" | ||
Represents a data source for handling raw binary data. | ||
This class is used to specify raw binary data, such as audio data in its | ||
binary form, which can be captured from a microphone or generated synthetically. | ||
Attributes: | ||
buffer (bytes): The binary data. | ||
""" | ||
|
||
buffer: bytes | ||
|
||
|
||
AnalyzeSource = Union[UrlSource, BufferSource, AnalyzeStreamSource] | ||
TextSource = Union[BufferSource, AnalyzeStreamSource] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. | ||
# Use of this source code is governed by a MIT license that can be found in the LICENSE file. | ||
# SPDX-License-Identifier: MIT | ||
|
||
from .client import AnalyzeClient | ||
from .async_client import AsyncAnalyzeClient | ||
from .options import AnalyzeOptions | ||
from ....options import DeepgramClientOptions | ||
from .response import AsyncAnalyzeResponse, AnalyzeResponse | ||
from ..enums import Sentiment |
Oops, something went wrong.