Skip to content

Commit e43507e

Browse files
authored
REVAI-3918 Split NlpModel to have separate enums for Translation and Summarization (revdotcom#107)
* REVAI-3918: Split NlpModel to have separate enums for Translation and Summarization https://revinc.atlassian.net/browse/REVAI-3918
1 parent f6c0b38 commit e43507e

13 files changed

+33
-43
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ job = client.submit_job_url("https://example.com/file-to-transcribe.mp3",
7575
language='en',
7676
translation_config=TranslationOptions(
7777
target_languages: [
78-
TranslationLanguageOptions("es", NlpModel.PREMIUM),
78+
TranslationLanguageOptions("es", TranslationModel.PREMIUM),
7979
TranslationLanguageOptions("de")
8080
]
8181
));

examples/async_summarize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# delete_after_seconds=2592000,
3232
# language='en',
3333
# summarization_config=SummarizationOptions(
34-
# model=NlpModel.PREMIUM
34+
# model=SummarizationModel.PREMIUM
3535
# ))
3636

3737

@@ -41,7 +41,7 @@
4141
job = client.submit_job_url(media_url=url,
4242
delete_after_seconds=2592000,
4343
language='en',
44-
summarization_config=SummarizationOptions(model=NlpModel.PREMIUM))
44+
summarization_config=SummarizationOptions(model=SummarizationModel.PREMIUM))
4545

4646
print("Submitted Job")
4747
print("Job Status : {}".format(job.status))

examples/async_translate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from rev_ai.models.asynchronous.translation_job_status import TranslationJobStatus
1919
from rev_ai.models.asynchronous.translation_language_options import TranslationLanguageOptions
2020
from rev_ai.models.asynchronous.translation_options import TranslationOptions
21-
from rev_ai.models.nlp_model import NlpModel
21+
from rev_ai.models.asynchronous.translation_model import TranslationModel
2222

2323
# String containing your access token
2424
access_token = "<your_access_token>"
@@ -33,7 +33,7 @@
3333
# language='en',
3434
# translation_config=TranslationOptions(
3535
# target_languages=[
36-
# TranslationLanguageOptions("es", NlpModel.PREMIUM)
36+
# TranslationLanguageOptions("es", TranslationModel.PREMIUM)
3737
# ]
3838
# ))
3939

@@ -45,7 +45,7 @@
4545
language='en',
4646
translation_config=TranslationOptions(
4747
target_languages=[
48-
TranslationLanguageOptions("es", NlpModel.PREMIUM)
48+
TranslationLanguageOptions("es", TranslationModel.PREMIUM)
4949
]
5050
))
5151

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.19.0
2+
current_version = 2.19.1
33
commit = True
44
tag = True
55

src/rev_ai/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""Top-level package for rev_ai"""
33

4-
__version__ = '2.19.1'
4+
__version__ = '2.19.2'
55

66
from .models import Job, JobStatus, Account, Transcript, Monologue, Element, MediaConfig, \
77
CaptionType, CustomVocabulary, TopicExtractionJob, TopicExtractionResult, Topic, Informant, \

src/rev_ai/apiclient.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,23 +413,21 @@ def get_captions(self, id_, content_type=CaptionType.SRT, channel_id=None):
413413

414414
return response.text
415415

416-
def get_translated_captions(self, id_, language, content_type=CaptionType.SRT, channel_id=None):
416+
def get_translated_captions(self, id_, language, content_type=CaptionType.SRT):
417417
"""Get the captions output of a specific job and return it as plain text
418418
419419
:param id_: id of job to be requested
420420
:param content_type: caption type which should be returned. Defaults to SRT
421-
:param channel_id: id of speaker channel to be captioned, only matters for multichannel jobs
422421
:returns: caption data as text
423422
:raises: HTTPError
424423
"""
425424
if not id_:
426425
raise ValueError('id_ must be provided')
427-
query = self._create_captions_query(channel_id)
428426

429427
response = self._make_http_request(
430428
"GET",
431429
urljoin(self.base_url,
432-
'jobs/{0}/captions/translation/{1}{2}'.format(id_, language, query)),
430+
'jobs/{0}/captions/translation/{1}'.format(id_, language)),
433431
headers={'Accept': content_type.value}
434432
)
435433

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from enum import Enum
2+
3+
4+
class SummarizationModel(str, Enum):
5+
STANDARD = "standard"
6+
PREMIUM = "premium"

src/rev_ai/models/asynchronous/summarization_options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .summarization_formatting_options import SummarizationFormattingOptions
22
from .summarization_job_status import SummarizationJobStatus
3-
from ..nlp_model import NlpModel
3+
from .summarization_model import SummarizationModel
44

55

66
class SummarizationOptions:
@@ -9,7 +9,7 @@ class SummarizationOptions:
99
def __init__(
1010
self,
1111
prompt: str = None,
12-
model: NlpModel = None,
12+
model: SummarizationModel = None,
1313
formatting_type: SummarizationFormattingOptions = None):
1414
self.prompt = prompt
1515
self.model = model
@@ -35,7 +35,7 @@ class Summarization(SummarizationOptions):
3535
def __init__(
3636
self,
3737
prompt: str = None,
38-
model: NlpModel = None,
38+
model: SummarizationModel = None,
3939
formatting_type: SummarizationFormattingOptions = None,
4040
status: SummarizationJobStatus = None,
4141
completed_on: str = None,

src/rev_ai/models/asynchronous/translation_language_options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from .translation_job_status import TranslationJobStatus
2-
from ..nlp_model import NlpModel
2+
from .translation_model import TranslationModel
33

44

55
class TranslationLanguageOptions:
66
"""Translation language request options."""
77
def __init__(
88
self,
99
language: str = None,
10-
model: NlpModel = None):
10+
model: TranslationModel = None):
1111
self.language = language
1212
self.model = model
1313

@@ -28,7 +28,7 @@ class TranslationLanguage(TranslationLanguageOptions):
2828
def __init__(
2929
self,
3030
language: str = None,
31-
model: NlpModel = None,
31+
model: TranslationModel = None,
3232
status: TranslationJobStatus = None,
3333
failure: str = None):
3434
super().__init__(language, model)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from enum import Enum
22

33

4-
class NlpModel(str, Enum):
4+
class TranslationModel(str, Enum):
55
STANDARD = "standard"
66
PREMIUM = "premium"

0 commit comments

Comments
 (0)