Source objects
Wordcab API Source object.
AssemblyAISource
dataclass
Bases: BaseSource
AssemblyAI source object using a local or remote AssemblyAI JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
Union[str, Path]
|
The path to the local file. |
field(default=None, repr=False)
|
url |
str
|
The URL to the remote file. |
field(default=None, repr=False)
|
Raises:
Type | Description |
---|---|
ValueError
|
If the file format is not valid. |
Examples:
>>> assemblyai_source = AssemblyAISource(filepath="path/to/assemblyai/file.json")
>>> assemblyai_source
AssemblyAISource(...)
>>> assemblyai_source.source
'assembly_ai'
Returns:
Type | Description |
---|---|
AssemblyAISource
|
The AssemblyAI source object. |
Source code in src/wordcab/core_objects/source.py
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
prepare_headers()
prepare_payload()
AudioSource
dataclass
Bases: BaseSource
The AudioSource object is required to create a job that uses an audio file as input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
Union[str, Path]
|
The path to the local file. |
field(default=None, repr=False)
|
url |
str
|
The URL to the remote file. |
field(default=None, repr=False)
|
Raises:
Type | Description |
---|---|
ValueError
|
If the file format is not supported. |
ValueError
|
If both |
TypeError
|
If the path is not a string or a Path object. |
FileNotFoundError
|
If the file does not exist or is not accessible. |
Examples:
Returns:
Type | Description |
---|---|
AudioSource
|
The audio source object. |
Source code in src/wordcab/core_objects/source.py
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
prepare_headers()
BaseSource
dataclass
Base class for AudioSource and GenericSource objects. It is not meant to be used directly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
Optional[Union[str, Path]]
|
Path to the local file, by default None. |
field(default=None, repr=False)
|
url |
Optional[str]
|
URL to the remote file, by default None. |
field(default=None, repr=False)
|
url_headers |
Optional[Dict[str, str]]
|
Headers to retrieve the file from the URL, by default None. Useful if the file requires authentication to be retrieved. |
field(default=None, repr=False)
|
Raises:
Type | Description |
---|---|
ValueError
|
If neither |
ValueError
|
If both |
TypeError
|
If |
FileNotFoundError
|
If |
Attributes:
Name | Type | Description |
---|---|---|
source |
str
|
The source type. |
source_type |
str
|
The source type. |
_stem |
str
|
The stem of the file. |
_suffix |
str
|
The suffix of the file. |
Returns:
Type | Description |
---|---|
BaseSource
|
The source object. |
Source code in src/wordcab/core_objects/source.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
prepare_headers()
DeepgramSource
dataclass
Bases: BaseSource
Deepgram source object using a local or remote Deepgram JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
Union[str, Path]
|
The path to the local file. |
field(default=None, repr=False)
|
url |
str
|
The URL to the remote file. |
field(default=None, repr=False)
|
Raises:
Type | Description |
---|---|
ValueError
|
If the file format is not valid. |
Examples:
>>> deepgram_source = DeepgramSource(filepath="path/to/deepgram/file.json")
>>> deepgram_source
DeepgramSource(...)
>>> deepgram_source.source
'deepgram'
Returns:
Type | Description |
---|---|
DeepgramSource
|
The Deepgram source object. |
Source code in src/wordcab/core_objects/source.py
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
prepare_headers()
prepare_payload()
GenericSource
dataclass
Bases: BaseSource
Generic source object.
The GenericSource object is required to create a job that uses a generic file as input,
such as .txt
or .json
file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
Union[str, Path]
|
The path to the local file. |
field(default=None, repr=False)
|
url |
str
|
The URL to the remote file. |
field(default=None, repr=False)
|
Raises:
Type | Description |
---|---|
ValueError
|
If the file format is not supported. |
ValueError
|
If both |
TypeError
|
If the path is not a string or a Path object. |
FileNotFoundError
|
If the file does not exist or is not accessible. |
Examples:
>>> generic_source = GenericSource(filepath="path/to/generic/file.txt")
>>> generic_source
GenericSource(...)
>>> generic_source.file_object
b'Hello, world!'
>>> generic_source.source_type
'local'
>>> generic_source._suffix
'.txt'
>>> generic_source._stem
'file'
Returns:
Type | Description |
---|---|
GenericSource
|
The generic source object. |
Source code in src/wordcab/core_objects/source.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
prepare_headers()
prepare_payload()
Prepare payload for API request.
Source code in src/wordcab/core_objects/source.py
InMemorySource
dataclass
In-memory source object.
The in-memory source object is a special case of the generic source object. It is used to pass a pre-processed transcript to the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
Union[Dict[str, List[str]], List[str]]
|
The in-memory object. It can be a list of strings or a dict with a |
field(default=None, repr=False)
|
Raises:
Type | Description |
---|---|
ValueError
|
If the in-memory object does not have a |
TypeError
|
If the in-memory object does not have a list as value for the |
TypeError
|
If the in-memory object is not a list or a dict. |
Examples:
>>> transcript = {"transcript": ["SPEAKER A: Hello.", "SPEAKER B: Hi."]}
>>> in_memory_source = InMemorySource(obj=transcript)
>>> in_memory_source
InMemorySource(...)
>>> in_memory_source.obj
Returns:
Type | Description |
---|---|
InMemorySource
|
The in-memory source object. |
Source code in src/wordcab/core_objects/source.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
prepare_headers()
RevSource
dataclass
Bases: BaseSource
Rev.ai source object using a local or remote Rev.ai JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
Union[str, Path]
|
The path to the local file. |
field(default=None, repr=False)
|
url |
str
|
The URL to the remote file. |
field(default=None, repr=False)
|
Raises:
Type | Description |
---|---|
ValueError
|
If the file format is not valid. |
Examples:
>>> rev_source = RevSource(filepath="path/to/rev/file.json")
>>> rev_source
RevSource(...)
>>> rev_source.source
'rev_ai'
Returns:
Type | Description |
---|---|
RevSource
|
The Rev.ai source object. |
Source code in src/wordcab/core_objects/source.py
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
prepare_headers()
VTTSource
dataclass
Bases: BaseSource
VTT source object using a local or remote VTT file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
Union[str, Path]
|
The path to the local file. |
field(default=None, repr=False)
|
url |
str
|
The URL to the remote file. |
field(default=None, repr=False)
|
Raises:
Type | Description |
---|---|
ValueError
|
If the file format is not valid. |
Examples:
>>> vtt_source = VTTSource(filepath="path/to/vtt/file.vtt")
>>> vtt_source
VTTSource(...)
>>> vtt_source.source
'vtt'
Returns:
Type | Description |
---|---|
VTTSource
|
The VTT source object. |
Source code in src/wordcab/core_objects/source.py
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
prepare_headers()
WordcabTranscriptSource
dataclass
Wordcab transcript source object using a Wordcab transcript ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transcript_id |
str
|
The Wordcab transcript ID to use as input. |
field(default=None)
|
Raises:
Type | Description |
---|---|
ValueError
|
If the |
Examples:
>>> wordcab_transcript_source = WordcabTranscriptSource(transcript_id="transcript_12345")
>>> wordcab_transcript_source
WordcabTranscriptSource(transcript_id=transcript_12345)
Returns:
Type | Description |
---|---|
WordcabTranscriptSource
|
The Wordcab transcript source object. |
Source code in src/wordcab/core_objects/source.py
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
__repr__()
prepare_headers()
YoutubeSource
dataclass
Youtube source object using a Youtube video url.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The Youtube video url to use as input. |
field(default=None)
|
Examples:
>>> youtube_source = YoutubeSource(url="https://www.youtube.com/watch?v=12345")
>>> youtube_source
YoutubeSource(url='https://www.youtube.com/watch?v=12345')
Returns:
Type | Description |
---|---|
YoutubeSource
|
The Youtube source object. |
Source code in src/wordcab/core_objects/source.py
__post_init__()
Post-init method.
Source code in src/wordcab/core_objects/source.py
Created: 2023-09-25