deepgram.clients.common.v1.options

 1# Copyright 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 io import BufferedReader
 6from typing import Union
 7from typing_extensions import TypedDict
 8
 9
10class StreamSource(TypedDict):
11    """
12    Represents a data source for reading binary data from a stream-like source.
13
14    This class is used to specify a source of binary data that can be read from
15    a stream, such as an audio file in .wav format.
16
17    Attributes:
18        stream (BufferedReader): A BufferedReader object for reading binary data.
19    """
20
21    stream: BufferedReader
22
23
24class UrlSource(TypedDict):
25    """
26    Represents a data source for specifying the location of a file via a URL.
27
28    This class is used to specify a hosted file URL, typically pointing to an
29    externally hosted file, such as an audio file hosted on a server or the internet.
30
31    Attributes:
32        url (str): The URL pointing to the hosted file.
33    """
34
35    url: str
36
37
38class BufferSource(TypedDict):
39    """
40    Represents a data source for handling raw binary data.
41
42    This class is used to specify raw binary data, such as audio data in its
43    binary form, which can be captured from a microphone or generated synthetically.
44
45    Attributes:
46        buffer (bytes): The binary data.
47    """
48
49    buffer: bytes
50
51
52class TextSource(TypedDict):
53    """
54    Represents a data source for reading binary data from a text-like source.
55
56    This class is used to specify a source of text data that can be read from.
57
58    Attributes:
59        text (str): A string for reading text data.
60    """
61
62    text: str
63
64
65FileSource = Union[TextSource, BufferSource, StreamSource]
class StreamSource(typing_extensions.TypedDict):
11class StreamSource(TypedDict):
12    """
13    Represents a data source for reading binary data from a stream-like source.
14
15    This class is used to specify a source of binary data that can be read from
16    a stream, such as an audio file in .wav format.
17
18    Attributes:
19        stream (BufferedReader): A BufferedReader object for reading binary data.
20    """
21
22    stream: BufferedReader

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: _io.BufferedReader
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.

url: str
class BufferSource(typing_extensions.TypedDict):
39class BufferSource(TypedDict):
40    """
41    Represents a data source for handling raw binary data.
42
43    This class is used to specify raw binary data, such as audio data in its
44    binary form, which can be captured from a microphone or generated synthetically.
45
46    Attributes:
47        buffer (bytes): The binary data.
48    """
49
50    buffer: bytes

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
class TextSource(typing_extensions.TypedDict):
53class TextSource(TypedDict):
54    """
55    Represents a data source for reading binary data from a text-like source.
56
57    This class is used to specify a source of text data that can be read from.
58
59    Attributes:
60        text (str): A string for reading text data.
61    """
62
63    text: str

Represents a data source for reading binary data from a text-like source.

This class is used to specify a source of text data that can be read from.

Attributes: text (str): A string for reading text data.

text: str
FileSource = typing.Union[TextSource, BufferSource, StreamSource]