Skip to content

Commit 4b98b0a

Browse files
authored
REVAI-3919:Split NlpModel to have separate enums for Translation and Summarization (#63)
https://revinc.atlassian.net/browse/REVAI-3919
1 parent a8ca699 commit 4b98b0a

File tree

12 files changed

+63
-45
lines changed

12 files changed

+63
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ int channelId = 1;
207207
InputStream inputStream = apiClient.getCaptions(revAiJob.getJobId(), RevAiCaptionType.VTT, channelId);
208208
209209
// or if you requested transcript translation(s)
210-
InputStream inputStream = apiClient.getTranslatedCaptions(revAiJob.getJobId(), "es", RevAiCaptionType.VTT, channelId);
210+
InputStream inputStream = apiClient.getTranslatedCaptions(revAiJob.getJobId(), "es", RevAiCaptionType.VTT);
211211
```
212212

213213
### Getting transcript summary

examples/AsyncSummarizeMediaUrl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static void main(String[] args) {
2828
revAiJobOptions.setSourceConfig(mediaUrl, null);
2929
revAiJobOptions.setDeleteAfterSeconds(2592000); // 30 days in seconds
3030
revAiJobOptions.setLanguage("en");
31-
revAiJobOptions.setSummarizationOptions(new SummarizationOptions().setModel(NlpModel.STANDARD));
31+
revAiJobOptions.setSummarizationOptions(new SummarizationOptions().setModel(SummarizationModel.STANDARD));
3232

3333
RevAiJob submittedJob;
3434

examples/AsyncTranslateMediaUrl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static void main(String[] args) {
3030
revAiJobOptions.setLanguage("en");
3131
revAiJobOptions.setTranslationOptions(new TranslationOptions(Arrays.asList(
3232
new TranslationLanguageOptions("es")
33-
.setModel(NlpModel.PREMIUM),
33+
.setModel(TranslationModel.PREMIUM),
3434
new TranslationLanguageOptions("de"))
3535
));
3636

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<!-- groupId, artifactId, these namespaces should not be changed -->
66
<groupId>ai.rev</groupId>
77
<artifactId>revai-java-sdk</artifactId>
8-
<version>2.4.0</version>
8+
<version>2.4.1</version>
99
<name>Rev AI SDK for Java</name>
1010
<description>Java SDK for Rev AI API</description>
1111
<url>https://docs.rev.ai/</url>

src/main/java/ai/rev/speechtotext/ApiClient.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,23 +438,18 @@ public InputStream getCaptions(String id, RevAiCaptionType captionType, Integer
438438
* @param id The ID of the job to return captions for.
439439
* @param language requested translation language.
440440
* @param captionType An enumeration of the desired caption type. Default is SRT.
441-
* @param channelId Identifies the audio channel of the file to output captions for. Default is
442-
* null.
443441
* @return InputStream A stream of bytes that represents the caption output.
444442
* @throws IOException If the response has a status code > 399.
445443
* @throws IllegalArgumentException If the job ID provided is null.
446444
* @see <a
447445
* href="https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions">https://docs.rev.ai/api/asynchronous/reference/#operation/GetCaptions</a>
448446
*/
449-
public InputStream getTranslatedCaptions(String id, String language, RevAiCaptionType captionType, Integer channelId)
447+
public InputStream getTranslatedCaptions(String id, String language, RevAiCaptionType captionType)
450448
throws IOException {
451449
if (id == null) {
452450
throw new IllegalArgumentException("Job ID must be provided");
453451
}
454452
Map<String, String> query = new HashMap<>();
455-
if (channelId != null) {
456-
query.put("speaker_channel", channelId.toString());
457-
}
458453
if (captionType == null) {
459454
captionType = RevAiCaptionType.SRT;
460455
}

src/main/java/ai/rev/speechtotext/models/asynchronous/Summarization.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package ai.rev.speechtotext.models.asynchronous;
22

3-
import ai.rev.speechtotext.models.NlpModel;
43
import com.google.gson.annotations.SerializedName;
54

65
/**
@@ -15,10 +14,10 @@ public class Summarization {
1514
/**
1615
* Summarization model.
1716
*
18-
* @see NlpModel
17+
* @see TranslationModel
1918
*/
2019
@SerializedName("model")
21-
private NlpModel model;
20+
private TranslationModel model;
2221

2322
/** Formatting options. Default is Paragraph. */
2423
@SerializedName("type")
@@ -56,9 +55,9 @@ public String getPrompt() {
5655
* Returns backend model used for the summarization job.
5756
*
5857
* @return Backend model used for the summarization job.
59-
* @see NlpModel
58+
* @see TranslationModel
6059
*/
61-
public NlpModel getModel() {
60+
public TranslationModel getModel() {
6261
return model;
6362
}
6463

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package ai.rev.speechtotext.models.asynchronous;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
5+
/** Supported model types for summarization. */
6+
public enum SummarizationModel {
7+
8+
@SerializedName("standard")
9+
STANDARD("standard"),
10+
@SerializedName("premium")
11+
PREMIUM("premium");
12+
13+
private final String model;
14+
15+
SummarizationModel(String model) {
16+
this.model = model;
17+
}
18+
19+
/**
20+
* Returns the String value of the enumeration.
21+
*
22+
* @return The String value of the enumeration.
23+
*/
24+
public String getModel() { return model; }
25+
26+
@Override
27+
public String toString() {
28+
return "{" + "model='" + model + '\'' + '}';
29+
}
30+
}

src/main/java/ai/rev/speechtotext/models/asynchronous/SummarizationOptions.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package ai.rev.speechtotext.models.asynchronous;
22

3-
import ai.rev.speechtotext.models.NlpModel;
43
import com.google.gson.annotations.SerializedName;
54

65
/**
@@ -18,7 +17,7 @@ public class SummarizationOptions {
1817

1918
/** Standard or Premium AI backend. */
2019
@SerializedName("model")
21-
private NlpModel model;
20+
private SummarizationModel model;
2221

2322
/** Formatting options. Default is Paragraph. */
2423
@SerializedName("type")
@@ -47,19 +46,19 @@ public SummarizationOptions setPrompt(String prompt) {
4746
* Returns backend model used for the summarization job.
4847
*
4948
* @return Backend model used for the summarization job.
50-
* @see NlpModel
49+
* @see TranslationModel
5150
*/
52-
public NlpModel getModel() {
51+
public SummarizationModel getModel() {
5352
return model;
5453
}
5554

5655
/**
5756
* Sets backend model used for the summarization job.
5857
*
5958
* @param model Backend model used for the summarization job.
60-
* @see NlpModel
59+
* @see SummarizationModel
6160
*/
62-
public SummarizationOptions setModel(NlpModel model) {
61+
public SummarizationOptions setModel(SummarizationModel model) {
6362
this.model = model;
6463
return this;
6564
}

src/main/java/ai/rev/speechtotext/models/asynchronous/TranslationLanguage.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package ai.rev.speechtotext.models.asynchronous;
22

3-
import ai.rev.speechtotext.models.NlpModel;
43
import com.google.gson.annotations.SerializedName;
54

65
/**
@@ -11,7 +10,7 @@
1110
public class TranslationLanguage {
1211
/** Standard or Premium AI backend. */
1312
@SerializedName("model")
14-
private NlpModel model;
13+
private TranslationModel model;
1514

1615
@SerializedName("language")
1716
private String language;
@@ -26,9 +25,9 @@ public class TranslationLanguage {
2625
* Returns backend model used for the summarization job.
2726
*
2827
* @return Backend model used for the summarization job.
29-
* @see NlpModel
28+
* @see TranslationModel
3029
*/
31-
public NlpModel getModel() {
30+
public TranslationModel getModel() {
3231
return model;
3332
}
3433

src/main/java/ai/rev/speechtotext/models/asynchronous/TranslationLanguageOptions.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package ai.rev.speechtotext.models.asynchronous;
22

3-
import ai.rev.speechtotext.models.NlpModel;
43
import com.google.gson.annotations.SerializedName;
54

65
/**
@@ -13,7 +12,7 @@
1312
public class TranslationLanguageOptions {
1413
/** Standard or Premium AI backend. */
1514
@SerializedName("model")
16-
private NlpModel model;
15+
private TranslationModel model;
1716

1817
@SerializedName("language")
1918
private final String language;
@@ -22,19 +21,19 @@ public class TranslationLanguageOptions {
2221
* Returns backend model used for the summarization job.
2322
*
2423
* @return Backend model used for the summarization job.
25-
* @see NlpModel
24+
* @see TranslationModel
2625
*/
27-
public NlpModel getModel() {
26+
public TranslationModel getModel() {
2827
return model;
2928
}
3029

3130
/**
3231
* Sets backend model to use for the summarization job.
3332
*
3433
* @param model Backend model to use for the summarization job
35-
* @see NlpModel
34+
* @see TranslationModel
3635
*/
37-
public TranslationLanguageOptions setModel(NlpModel model) {
36+
public TranslationLanguageOptions setModel(TranslationModel model) {
3837
this.model = model;
3938
return this;
4039
}

0 commit comments

Comments
 (0)