Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for diarization_type, speakers_count, remove_atmospherics #104

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/rev_ai/apiclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def submit_job_url(
notification_config=None,
skip_postprocessing=False,
remove_atmospherics=False,
speakers_count=None):
speakers_count=None,
diarization_type=None):
"""Submit media given a URL for transcription.
The audio data is downloaded from the URL
:param media_url: web location of the media file
Expand Down Expand Up @@ -116,6 +117,7 @@ def submit_job_url(
: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.
:returns: raw response data
:raises: HTTPError
"""
Expand All @@ -128,7 +130,8 @@ def submit_job_url(
verbatim, rush, test_mode,
segments_to_transcribe, speaker_names,
source_config, notification_config,
skip_postprocessing)
skip_postprocessing, remove_atmospherics,
speakers_count, diarization_type)

response = self._make_http_request(
"POST",
Expand Down Expand Up @@ -161,7 +164,8 @@ def submit_job_local_file(
notification_config=None,
skip_postprocessing=False,
remove_atmospherics=False,
speakers_count=None):
speakers_count=None,
diarization_type=None):
"""Submit a local file for transcription.
Note that the content type is inferred if not provided.

Expand Down Expand Up @@ -208,6 +212,7 @@ def submit_job_local_file(
: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.
:returns: raw response data
:raises: HTTPError, ValueError
"""
Expand All @@ -222,7 +227,9 @@ def submit_job_local_file(
language, custom_vocabulary_id, transcriber,
verbatim, rush, test_mode,
segments_to_transcribe, speaker_names, None,
notification_config, skip_postprocessing)
notification_config, skip_postprocessing,
remove_atmospherics, speakers_count,
diarization_type)

with open(filename, 'rb') as f:
files = {
Expand Down Expand Up @@ -475,7 +482,8 @@ def _create_job_options_payload(
notification_config=None,
skip_postprocessing=False,
remove_atmospherics=None,
speakers_count=None):
speakers_count=None,
diarization_type=None):
payload = {}
if media_url:
payload['media_url'] = media_url
Expand Down Expand Up @@ -524,6 +532,8 @@ def _create_job_options_payload(
payload['remove_atmospherics'] = remove_atmospherics
if speakers_count:
payload['speakers_count'] = speakers_count
if diarization_type:
payload['diarization_type'] = diarization_type
return payload

def _create_captions_query(self, speaker_channel):
Expand Down
8 changes: 6 additions & 2 deletions src/rev_ai/models/asynchronous/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def __init__(
rush=None,
segments_to_transcribe=None,
remove_atmospherics=None,
speakers_count=None):
speakers_count=None,
diarization_type=None):
"""
:param id_: unique id of job
:param created_on: date and time at which this job was started
Expand Down Expand Up @@ -59,6 +60,7 @@ def __init__(
: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
Expand All @@ -85,6 +87,7 @@ def __init__(
self.segments_to_transcribe = segments_to_transcribe
self.remove_atmospherics = remove_atmospherics
self.speakers_count = speakers_count
self.diarization_type = diarization_type

def __eq__(self, other):
"""Override default equality operator"""
Expand Down Expand Up @@ -120,5 +123,6 @@ def from_json(cls, json):
rush=json.get('rush'),
segments_to_transcribe=json.get('segments_to_transcribe'),
remove_atmospherics=json.get('remove_atmospherics'),
speakers_count=json.get('speakers_count')
speakers_count=json.get('speakers_count'),
diarization_type=json.get('diarization_type')
)
Loading