-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathjob.py
More file actions
135 lines (131 loc) · 5.99 KB
/
job.py
File metadata and controls
135 lines (131 loc) · 5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
# -*- coding: utf-8 -*-
"""Job model"""
from .summarization_options import Summarization
from .job_status import JobStatus
from .translation_options import Translation
class Job:
def __init__(
self, id_, created_on, status,
completed_on=None,
name=None,
callback_url=None,
metadata=None,
media_url=None,
failure=None,
failure_detail=None,
duration_seconds=None,
delete_after_seconds=None,
skip_diarization=None,
skip_punctuation=None,
remove_disfluencies=None,
filter_profanity=None,
custom_vocabulary_id=None,
speaker_channels_count=None,
language=None,
transcriber=None,
verbatim=None,
rush=None,
segments_to_transcribe=None,
remove_atmospherics=None,
speakers_count=None,
diarization_type=None,
summarization: Summarization = None,
translation: Translation = None):
"""
:param id_: unique id of job
:param created_on: date and time at which this job was started
:param status: current job status 'IN_PROGRESS', 'TRANSCRIBED',
or 'FAILED'
:param completed_on: date and time at which this job finished
being transcribed
:param name: name of submitted file if local file was used
:param callback_url: callback_url if provided
:param metadata: metadata if provided
:param media_url: url of transcribed media if job was submitted
this way
:param failure: type of failure if job has failed
:param failure_detail: more detailed failure message if job has failed
:param duration_seconds: duration of submitted file in seconds
:param delete_after_seconds: seconds before deletion if provided
:param skip_diarization: whether to skip diarization if provided
:param skip_punctuation: whether to skip punctuation if provided
:param remove_disfluencies: whether to remove disfluencies if provided
:param filter_profanity: whether to filter profanity if provided
:param custom_vocabulary_id: custom vocabulary id if provided
:param speaker_channels_count: speaker channels count if provided
:param language: language of job
:param transcriber: transcriber to use for job
:param verbatim: whether to transcribe verbatim if provided for human transcription
:param rush: whether to transcribe with rush if provided for human transcription
:param segments_to_transcribe: segments to transcribe if provided for human transcription
:param remove_atmospherics: Atmospherics such as <laugh>, <affirmative>, etc. will noT
appear in the transcript.
:param speakers_count: Use to specify the total number of unique speakers in the audio.
:param diarization_type: Use to specify diarization type.
"""
self.id = id_
self.created_on = created_on
self.status = status
self.completed_on = completed_on
self.name = name
self.callback_url = callback_url,
self.metadata = metadata
self.media_url = media_url
self.failure = failure
self.failure_detail = failure_detail
self.duration_seconds = duration_seconds
self.delete_after_seconds = delete_after_seconds
self.skip_diarization = skip_diarization
self.skip_punctuation = skip_punctuation
self.remove_disfluencies = remove_disfluencies
self.filter_profanity = filter_profanity
self.custom_vocabulary_id = custom_vocabulary_id
self.speaker_channels_count = speaker_channels_count
self.language = language
self.transcriber = transcriber
self.verbatim = verbatim
self.rush = rush
self.segments_to_transcribe = segments_to_transcribe
self.remove_atmospherics = remove_atmospherics
self.speakers_count = speakers_count
self.diarization_type = diarization_type
self.summarization = summarization
self.translation = translation
def __eq__(self, other):
"""Override default equality operator"""
if isinstance(other, self.__class__):
return self.__dict__ == other.__dict__
return False
@classmethod
def from_json(cls, json):
"""Alternate constructor used for parsing json"""
return cls(
json['id'],
json['created_on'],
JobStatus.from_string(json['status']),
completed_on=json.get('completed_on'),
name=json.get('name'),
callback_url=json.get('callback_url'),
metadata=json.get('metadata'),
media_url=json.get('media_url'),
failure=json.get('failure'),
failure_detail=json.get('failure_detail'),
duration_seconds=json.get('duration_seconds'),
delete_after_seconds=json.get('delete_after_seconds'),
skip_diarization=json.get('skip_diarization'),
skip_punctuation=json.get('skip_punctuation'),
remove_disfluencies=json.get('remove_disfluencies'),
filter_profanity=json.get('filter_profanity'),
custom_vocabulary_id=json.get('custom_vocabulary_id'),
speaker_channels_count=json.get('speaker_channels_count'),
language=json.get('language'),
transcriber=json.get('transcriber'),
verbatim=json.get('verbatim'),
rush=json.get('rush'),
segments_to_transcribe=json.get('segments_to_transcribe'),
remove_atmospherics=json.get('remove_atmospherics'),
speakers_count=json.get('speakers_count'),
diarization_type=json.get('diarization_type'),
summarization=Summarization.from_json(json.get('summarization')),
translation=Translation.from_json(json.get('translation'))
)