Skip to content
Merged
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
2 changes: 1 addition & 1 deletion examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rev-ai==2.19.4
rev-ai==2.19.5
pyaudio==0.2.11
six==1.12.0
2 changes: 1 addition & 1 deletion src/rev_ai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Top-level package for rev_ai"""

__version__ = '2.19.4'
__version__ = '2.19.5'

from .models import Job, JobStatus, Account, Transcript, Monologue, Element, MediaConfig, \
CaptionType, CustomVocabulary, TopicExtractionJob, TopicExtractionResult, Topic, Informant, \
Expand Down
74 changes: 55 additions & 19 deletions src/rev_ai/apiclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def submit_job_url(
skip_postprocessing=False,
remove_atmospherics=False,
speakers_count=None,
diarization_type=None,
summarization_config: SummarizationOptions = None,
translation_config: TranslationOptions = None):
"""Submit media given a URL for transcription.
Expand Down Expand Up @@ -122,21 +123,36 @@ 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.
:param summarization_config: Use to request transcript summary.
:param translation_config: Use to request transcript translation.
:returns: raw response data
:raises: HTTPError
"""
payload = self._create_job_options_payload(media_url, metadata, callback_url,
skip_diarization, skip_punctuation,
speaker_channels_count,
custom_vocabularies, filter_profanity,
remove_disfluencies, delete_after_seconds,
language, custom_vocabulary_id, transcriber,
verbatim, rush, test_mode,
segments_to_transcribe, speaker_names,
source_config, notification_config,
skip_postprocessing,
payload = self._create_job_options_payload(media_url=media_url,
metadata=metadata,
callback_url=callback_url,
skip_diarization=skip_diarization,
skip_punctuation=skip_punctuation,
speaker_channels_count=speaker_channels_count,
custom_vocabularies=custom_vocabularies,
filter_profanity=filter_profanity,
remove_disfluencies=remove_disfluencies,
delete_after_seconds=delete_after_seconds,
language=language,
custom_vocabulary_id=custom_vocabulary_id,
transcriber=transcriber,
verbatim=verbatim,
rush=rush,
test_mode=test_mode,
segments_to_transcribe=segments_to_transcribe,
speaker_names=speaker_names,
source_config=source_config,
notification_config=notification_config,
skip_postprocessing=skip_postprocessing,
remove_atmospherics=remove_atmospherics,
speakers_count=speakers_count,
diarization_type=diarization_type,
summarization_config=summarization_config,
translation_config=translation_config)

Expand Down Expand Up @@ -172,6 +188,7 @@ def submit_job_local_file(
skip_postprocessing=False,
remove_atmospherics=False,
speakers_count=None,
diarization_type=None,
summarization_config: SummarizationOptions = None,
translation_config: TranslationOptions = None):
"""Submit a local file for transcription.
Expand Down Expand Up @@ -220,6 +237,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.
:param summarization_config: Use to request transcript summary.
:param translation_config: Use to request transcript translation.
:returns: raw response data
Expand All @@ -228,15 +246,30 @@ def submit_job_local_file(
if not filename:
raise ValueError('filename must be provided')

payload = self._create_job_options_payload(None, metadata, callback_url,
skip_diarization, skip_punctuation,
speaker_channels_count,
custom_vocabularies, filter_profanity,
remove_disfluencies, delete_after_seconds,
language, custom_vocabulary_id, transcriber,
verbatim, rush, test_mode,
segments_to_transcribe, speaker_names, None,
notification_config, skip_postprocessing,
payload = self._create_job_options_payload(media_url=None,
metadata=metadata,
callback_url=callback_url,
skip_diarization=skip_diarization,
skip_punctuation=skip_punctuation,
speaker_channels_count=speaker_channels_count,
custom_vocabularies=custom_vocabularies,
filter_profanity=filter_profanity,
remove_disfluencies=remove_disfluencies,
delete_after_seconds=delete_after_seconds,
language=language,
custom_vocabulary_id=custom_vocabulary_id,
transcriber=transcriber,
verbatim=verbatim,
rush=rush,
test_mode=test_mode,
segments_to_transcribe=segments_to_transcribe,
speaker_names=speaker_names,
source_config=None,
notification_config=notification_config,
skip_postprocessing=skip_postprocessing,
remove_atmospherics=remove_atmospherics,
speakers_count=speakers_count,
diarization_type=diarization_type,
summarization_config=summarization_config,
translation_config=translation_config)

Expand Down Expand Up @@ -714,6 +747,7 @@ def _create_job_options_payload(
skip_postprocessing=False,
remove_atmospherics=None,
speakers_count=None,
diarization_type=None,
summarization_config: SummarizationOptions = None,
translation_config: TranslationOptions = None):
payload = {}
Expand Down Expand Up @@ -764,6 +798,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
if summarization_config:
payload['summarization_config'] = summarization_config.to_dict()
if translation_config:
Expand Down
4 changes: 4 additions & 0 deletions src/rev_ai/models/asynchronous/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
segments_to_transcribe=None,
remove_atmospherics=None,
speakers_count=None,
diarization_type=None,
summarization: Summarization = None,
translation: Translation = None):
"""
Expand Down Expand Up @@ -62,6 +63,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 @@ -88,6 +90,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
self.summarization = summarization
self.translation = translation

Expand Down Expand Up @@ -126,6 +129,7 @@ def from_json(cls, json):
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'))
)
45 changes: 37 additions & 8 deletions tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ def test_submit_job_url_with_success(self, mock_session, make_mock_response):
'delete_after_seconds': 0,
'language': LANGUAGE,
'transcriber': TRANSCRIBER,
'skip_postprocessing': True
'skip_postprocessing': True,
'remove_atmospherics': True,
'speakers_count': 123,
'diarization_type': "premium"
}
response = make_mock_response(url=JOB_ID_URL, json_data=data)
mock_session.request.return_value = response
Expand All @@ -130,7 +133,12 @@ def test_submit_job_url_with_success(self, mock_session, make_mock_response):
NOTIFICATION_URL, True,
True, 1, CUSTOM_VOCAB, True,
True, 0, LANGUAGE, CUSTOM_VOCAB_ID,
TRANSCRIBER, skip_postprocessing=True)
TRANSCRIBER,
skip_postprocessing=True,
remove_atmospherics=True,
speakers_count=123,
diarization_type="premium"
)

assert res == Job(JOB_ID,
CREATED_ON,
Expand All @@ -143,7 +151,11 @@ def test_submit_job_url_with_success(self, mock_session, make_mock_response):
remove_disfluencies=True,
delete_after_seconds=0,
language=LANGUAGE,
transcriber=TRANSCRIBER)
transcriber=TRANSCRIBER,
remove_atmospherics=True,
speakers_count=123,
diarization_type="premium"
)
mock_session.request.assert_called_once_with(
"POST",
JOBS_URL,
Expand All @@ -161,7 +173,10 @@ def test_submit_job_url_with_success(self, mock_session, make_mock_response):
'language': LANGUAGE,
'custom_vocabulary_id': CUSTOM_VOCAB_ID,
'transcriber': TRANSCRIBER,
'skip_postprocessing': True
'skip_postprocessing': True,
'remove_atmospherics': True,
'speakers_count': 123,
'diarization_type': "premium"
},
headers=client.default_headers)

Expand Down Expand Up @@ -283,7 +298,10 @@ def test_submit_job_local_file_with_success(self, mocker, mock_session, make_moc
'delete_after_seconds': 0,
'language': LANGUAGE,
'transcriber': TRANSCRIBER,
'skip_postprocessing': True
'skip_postprocessing': True,
'remove_atmospherics': True,
'speakers_count': 123,
'diarization_type': "premium"
}
response = make_mock_response(url=JOB_ID_URL, json_data=data)
mock_session.request.return_value = response
Expand All @@ -294,7 +312,11 @@ def test_submit_job_local_file_with_success(self, mocker, mock_session, make_moc
NOTIFICATION_URL, True,
True, 1, CUSTOM_VOCAB, True,
True, 0, LANGUAGE, CUSTOM_VOCAB_ID,
TRANSCRIBER, skip_postprocessing=True)
TRANSCRIBER, skip_postprocessing=True,
remove_atmospherics=True,
speakers_count=123,
diarization_type="premium"
)

assert res == Job(JOB_ID,
CREATED_ON,
Expand All @@ -308,7 +330,11 @@ def test_submit_job_local_file_with_success(self, mocker, mock_session, make_moc
remove_disfluencies=True,
delete_after_seconds=0,
language=LANGUAGE,
transcriber=TRANSCRIBER)
transcriber=TRANSCRIBER,
remove_atmospherics=True,
speakers_count=123,
diarization_type="premium"
)
mock_session.request.assert_called_once_with(
"POST",
JOBS_URL,
Expand All @@ -329,7 +355,10 @@ def test_submit_job_local_file_with_success(self, mocker, mock_session, make_moc
'language': LANGUAGE,
'custom_vocabulary_id': CUSTOM_VOCAB_ID,
'transcriber': TRANSCRIBER,
'skip_postprocessing': True
'skip_postprocessing': True,
'remove_atmospherics': True,
'speakers_count': 123,
'diarization_type': "premium"
}, sort_keys=True)
)
},
Expand Down