Skip to content

Commit 86123c5

Browse files
author
Kyle Bridburg
authored
AISDK-229: Add skip_postprocessing option (#56)
1 parent 8b819db commit 86123c5

File tree

10 files changed

+83
-11
lines changed

10 files changed

+83
-11
lines changed

examples/AsyncTranscribeLocalMediaFile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static void main(String[] args) {
3232
revAiJobOptions.setNotificationConfig("https://example.com");
3333
revAiJobOptions.setSkipPunctuation(false);
3434
revAiJobOptions.setSkipDiarization(false);
35+
revAiJobOptions.setSkipPostprocessing(false);
3536
revAiJobOptions.setFilterProfanity(true);
3637
revAiJobOptions.setRemoveDisfluencies(true);
3738
revAiJobOptions.setSpeakerChannelsCount(null);

examples/AsyncTranscribeMediaUrl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public static void main(String[] args) {
4747
revAiJobOptions.setNotificationConfig(callbackUrl, notificationAuth);
4848
revAiJobOptions.setSkipPunctuation(false);
4949
revAiJobOptions.setSkipDiarization(false);
50+
revAiJobOptions.setSkipPostprocessing(false);
5051
revAiJobOptions.setFilterProfanity(true);
5152
revAiJobOptions.setRemoveDisfluencies(true);
5253
revAiJobOptions.setSpeakerChannelsCount(null);

examples/StreamingFromLocalFile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static void main(String[] args) throws InterruptedException {
3939
sessionConfig.setStartTs(0.0);
4040
sessionConfig.setTranscriber("machine");
4141
sessionConfig.setLanguage("en");
42+
sessionConfig.setSkipPostprocessing(false);
4243

4344
// Initialize your client with your access token
4445
StreamingClient streamingClient = new StreamingClient(accessToken);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ private String buildURL(
217217
if (sessionConfig.getLanguage() != null) {
218218
urlBuilder.addQueryParameter("language", sessionConfig.getLanguage());
219219
}
220+
if (sessionConfig.getSkipPostprocessing() != null) {
221+
urlBuilder.addQueryParameter(
222+
"skip_postprocessing", String.valueOf(sessionConfig.getSkipPostprocessing()));
223+
}
220224
}
221225
return urlBuilder.build().toString()
222226
+ "&content_type="

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public class RevAiJobOptions {
4444
/** Optional parameter for the speech engine to skip punctuation. */
4545
@SerializedName("skip_punctuation")
4646
private Boolean skipPunctuation;
47+
48+
/** Optional parameter for the speech engine to skip all postprocessing */
49+
@SerializedName("skip_postprocessing")
50+
private Boolean skipPostprocessing;
4751

4852
/**
4953
* Optional parameter to process each audio channel separately. Account will be charged the file
@@ -273,6 +277,25 @@ public Boolean getSkipPunctuation() {
273277
public void setSkipPunctuation(Boolean skipPunctuation) {
274278
this.skipPunctuation = skipPunctuation;
275279
}
280+
281+
/**
282+
* Returns the value of the skip postprocessing Boolean.
283+
*
284+
* @return The skip postprocessing value.
285+
*/
286+
public Boolean getSkipPostprocessing() {
287+
return skipPostprocessing;
288+
}
289+
290+
/**
291+
* Specifies if all postprocessing (capitalization, punctuation, ITN) will be skipped by the speech engine. This property is
292+
* optional and defaults to false.
293+
*
294+
* @param skipPostprocessing The value of the Boolean.
295+
*/
296+
public void setSkipPostprocessing(Boolean skipPostprocessing) {
297+
this.skipPostprocessing = skipPostprocessing;
298+
}
276299

277300
/**
278301
* Returns the speaker channel count.

src/main/java/ai/rev/speechtotext/models/streaming/SessionConfig.java

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class SessionConfig {
1212
private Double startTs;
1313
private String transcriber;
1414
private String language;
15+
private Boolean skipPostprocessing;
1516

1617
/**
1718
* Returns the metadata.
@@ -138,40 +139,71 @@ public void setDetailedPartials(Boolean detailedPartials) {
138139
*
139140
* @return The startTs value.
140141
*/
141-
public Double getStartTs() { return startTs; }
142+
public Double getStartTs() {
143+
return startTs;
144+
}
142145

143146
/**
144147
* Specifies the number of seconds to offset all hypotheses timings.
145148
*
146149
* @param startTs The number of seconds to offset all hypotheses timings.
147150
*/
148-
public void setStartTs(Double startTs) { this.startTs = startTs; }
151+
public void setStartTs(Double startTs) {
152+
this.startTs = startTs;
153+
}
149154

150155
/**
151156
* Returns the value of transcriber.
152157
*
153158
* @return The transcriber value.
154159
*/
155-
public String getTranscriber() { return transcriber; }
160+
public String getTranscriber() {
161+
return transcriber;
162+
}
156163

157164
/**
158165
* Specifies the type of transcriber to use to transcribe the media.
159166
*
160167
* @param transcriber The type of transcriber to use to transcribe the media.
161168
*/
162-
public void setTranscriber(String transcriber) { this.transcriber = transcriber; }
169+
public void setTranscriber(String transcriber) {
170+
this.transcriber = transcriber;
171+
}
163172

164173
/**
165174
* Returns the value of language.
166175
*
167176
* @return The language value.
168177
*/
169-
public String getLanguage() { return language; }
178+
public String getLanguage() {
179+
return language;
180+
}
170181

171182
/**
172183
* Specifies the language to use for the streaming job.
173184
*
174185
* @param language The language to use for the streaming job.
175186
*/
176-
public void setLanguage(String language) { this.language = language; }
187+
public void setLanguage(String language) {
188+
this.language = language;
189+
}
190+
191+
/**
192+
* Returns the value of the skip postprocessing Boolean.
193+
*
194+
* @return The skip postprocessing value.
195+
*/
196+
public Boolean getSkipPostprocessing() {
197+
return skipPostprocessing;
198+
}
199+
200+
/**
201+
* Specifies if all postprocessing (capitalization, punctuation, ITN) will be skipped by the speech engine. This property is
202+
* optional and defaults to false.
203+
*
204+
* @param skipPostprocessing The value of the Boolean.
205+
*/
206+
public void setSkipPostprocessing(Boolean skipPostprocessing) {
207+
this.skipPostprocessing = skipPostprocessing;
208+
}
177209
}

src/test/java/ai/rev/speechtotext/integration/StreamingTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ private SessionConfig createSessionsConfig() {
132132
sessionConfig.setDeleteAfterSeconds(0);
133133
sessionConfig.setDetailedPartials(true);
134134
sessionConfig.setStartTs(10.0);
135-
sessionConfig.setTranscriber("machine");
135+
sessionConfig.setTranscriber("machine_v2");
136136
sessionConfig.setLanguage("en");
137+
sessionConfig.setSkipPostprocessing(false);
137138
return sessionConfig;
138139
}
139140

src/test/java/ai/rev/speechtotext/integration/SubmitJobTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ private RevAiJobOptions getJobOptions() {
171171
revAiJobOptions.setRemoveDisfluencies(true);
172172
revAiJobOptions.setSkipPunctuation(true);
173173
revAiJobOptions.setSkipDiarization(true);
174+
revAiJobOptions.setSkipPostprocessing(true);
174175
revAiJobOptions.setSpeakerChannelsCount(null);
175176
revAiJobOptions.setDeleteAfterSeconds(0);
176177
revAiJobOptions.setLanguage("en");

src/test/java/ai/rev/speechtotext/unit/RevAiJobTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public void SubmitJobUrl_UrlAndOptionsAreSpecified_ReturnsARevAiJob() throws IOE
159159
options.setRemoveDisfluencies(true);
160160
options.setSkipPunctuation(true);
161161
options.setSkipDiarization(true);
162+
options.setSkipPostprocessing(true);
162163
options.setNotificationConfig("https://example.com");
163164
options.setMetadata(METADATA);
164165
options.setSpeakerChannelsCount(2);
@@ -196,6 +197,7 @@ public void SubmitJobUrl_UrlAndOptionsAreSpecified_WithAuthHeaders_ReturnsARevAi
196197
options.setRemoveDisfluencies(true);
197198
options.setSkipPunctuation(true);
198199
options.setSkipDiarization(true);
200+
options.setSkipPostprocessing(true);
199201
options.setNotificationConfig(NOTIFICATION_URL, NOTIFICATION_AUTH);
200202
options.setMetadata(METADATA);
201203
options.setSpeakerChannelsCount(2);

src/test/java/ai/rev/speechtotext/unit/RevAiStreamingClientOptionalParametersTest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ public static String[] vocabIdAndNull() {
4848

4949
@DataPoints("deleteAfterSecondsAndNull")
5050
public static Integer[] deleteAfterSecondsAndNull() {
51-
return new Integer[] {0, 1, null};
51+
return new Integer[] {1, null};
5252
}
5353

5454
@DataPoints("booleanValuesAndNull")
5555
public static Boolean[] booleanValuesAndNull() {
56-
return new Boolean[] {true, false, null};
56+
return new Boolean[] {false, null};
5757
}
5858

5959
@DataPoints("startTsAndNull")
6060
public static Double[] startTsAndNull() {
61-
return new Double[] {0.0, 10.0, null};
61+
return new Double[] {10.0, null};
6262
}
6363

6464
@DataPoints("transcriberAndNull")
@@ -114,7 +114,8 @@ public void StreamingClient_GivenOptionalParameterSet_ContainsNonNullParametersI
114114
@FromDataPoints("booleanValuesAndNull") Boolean detailedPartials,
115115
@FromDataPoints("startTsAndNull") Double startTs,
116116
@FromDataPoints("transcriberAndNull") String transcriber,
117-
@FromDataPoints("languageAndNull") String language)
117+
@FromDataPoints("languageAndNull") String language,
118+
@FromDataPoints("booleanValuesAndNull") Boolean skipPostprocessing)
118119
throws UnsupportedEncodingException {
119120
sessionConfig.setMetaData(metadata);
120121
sessionConfig.setFilterProfanity(filterProfanity);
@@ -125,6 +126,7 @@ public void StreamingClient_GivenOptionalParameterSet_ContainsNonNullParametersI
125126
sessionConfig.setStartTs(startTs);
126127
sessionConfig.setTranscriber(transcriber);
127128
sessionConfig.setLanguage(language);
129+
sessionConfig.setSkipPostprocessing(skipPostprocessing);
128130

129131
streamingClient.connect(
130132
Mockito.mock(RevAiWebSocketListener.class), defaultContentType, sessionConfig);
@@ -179,6 +181,10 @@ private void assertStreamOptions(RecordedRequest request) throws UnsupportedEnco
179181
assertThat(request.getPath())
180182
.contains("language=" + sessionConfig.getLanguage());
181183
}
184+
if (sessionConfig.getSkipPostprocessing() != null) {
185+
assertThat(request.getPath())
186+
.contains("skip_postprocessing=" + sessionConfig.getSkipPostprocessing());
187+
}
182188
assertThat(request.getPath()).contains("access_token=" + FAKE_ACCESS_TOKEN);
183189
}
184190
}

0 commit comments

Comments
 (0)