Skip to content

Commit 8444dc9

Browse files
authored
AISDK-129: Add delete_after_seconds option to streaming and async clients (#26)
1 parent 6129c54 commit 8444dc9

File tree

13 files changed

+74
-12
lines changed

13 files changed

+74
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The recommended way to use the Rev.ai Java SDK is to import it into the project
1313
<dependency>
1414
<groupId>ai.rev.speechtotext</groupId>
1515
<artifactId>revai-java-sdk-speechtotext</artifactId>
16-
<version>1.1.1</version>
16+
<version>1.2.0</version>
1717
</dependency>
1818

1919
## Build and install locally from source
@@ -74,7 +74,7 @@ RevAiJob revAiJob = apiClient.submitJobLocalFile(fileInputStream, String fileNam
7474
If you want to get fancy, all submit job methods have overrides that allow specifying
7575
[RevAiJobOptions](src/main/java/ai/rev/speechtotext/models/asynchronous/RevAiJobOptions.java) to configure job specific settings.
7676
In RevAiJobOptions, you could include `metadata`, `callback_url`,
77-
`skip_diarization`, `skip_punctuation`, `speaker_channels_count`, `custom_vocabularies`, `filter_profanity` and `remove_disfluencies` as optional parameters, these are described in the request body of
77+
`skip_diarization`, `skip_punctuation`, `speaker_channels_count`, `custom_vocabularies`, `filter_profanity`, `remove_disfluencies`, and `delete_after_seconds` as optional parameters, these are described in the request body of
7878
the [Submit Job](https://www.rev.ai/docs#operation/SubmitTranscriptionJob) endpoint.
7979

8080
### Checking your job's status
@@ -199,7 +199,7 @@ public class Listener implements RevAiWebSocketListener {
199199
}
200200
```
201201

202-
Now you will be able to connect and start the streaming session by calling the `streamingClient.connect()` method and passing in the Listener! You can supply an optional `SessionConfig` object, containing `metadata`, `filter_profanity` and `remove_disfluencies` as optional parameters, to the function in order to provide additional information for that session.
202+
Now you will be able to connect and start the streaming session by calling the `streamingClient.connect()` method and passing in the Listener! You can supply an optional `SessionConfig` object, containing `metadata`, `filter_profanity`, `remove_disfluencies`, and `delete_after_seconds` as optional parameters, to the function in order to provide additional information for that session.
203203

204204
```
205205
Listener listener = new Listener();

examples/AsyncTranscribeLocalMediaFile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static void main(String[] args) {
3434
revAiJobOptions.setFilterProfanity(true);
3535
revAiJobOptions.setRemoveDisfluencies(true);
3636
revAiJobOptions.setSpeakerChannelsCount(null);
37+
revAiJobOptions.setDeleteAfterSeconds(2592000); // 30 days in seconds
3738

3839
RevAiJob submittedJob;
3940

examples/AsyncTranscribeMediaUrl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public static void main(String[] args) {
3434
revAiJobOptions.setFilterProfanity(true);
3535
revAiJobOptions.setRemoveDisfluencies(true);
3636
revAiJobOptions.setSpeakerChannelsCount(null);
37+
revAiJobOptions.setDeleteAfterSeconds(2592000); // 30 days in seconds
3738

3839
RevAiJob submittedJob;
3940

40-
String mediaUrl =
41-
"https://support.rev.com/hc/en-us/article_attachments/200043975/FTC_Sample_1_-_Single.mp3";
41+
String mediaUrl = "https://www.rev.ai/FTC_Sample_1.mp3";
4242

4343
try {
4444
// Submit the local file and transcription options

examples/CustomVocabulariesExample.java renamed to examples/CustomVocabularies.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.io.IOException;
99
import java.util.Arrays;
1010

11-
public class CustomVocabulariesExample {
11+
public class CustomVocabularies {
1212

1313
public static void main(String[] args) {
1414
// Assign your access token to a String

examples/StreamingFromLocalFileExample.java renamed to examples/StreamingFromLocalFile.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.nio.ByteBuffer;
1616
import java.util.Arrays;
1717

18-
public class StreamingFromLocalFileExample {
18+
public class StreamingFromLocalFile {
1919

2020
public static void main(String[] args) throws InterruptedException {
2121
// Assign your access token to a String
@@ -34,6 +34,7 @@ public static void main(String[] args) throws InterruptedException {
3434
sessionConfig.setMetaData("Streaming from the Java SDK");
3535
sessionConfig.setFilterProfanity(true);
3636
sessionConfig.setRemoveDisfluencies(true);
37+
sessionConfig.setDeleteAfterSeconds(2592000); // 30 days in seconds
3738

3839
// Initialize your client with your access token
3940
StreamingClient streamingClient = new StreamingClient(accessToken);

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>ai.rev.speechtotext</groupId>
66
<artifactId>revai-java-sdk-speechtotext</artifactId>
7-
<version>1.1.1</version>
7+
<version>1.2.0</version>
88
<name>Rev.ai speech to text SDK for Java</name>
99
<description>Java SDK for rev.ai speech to text API</description>
1010
<url>https://www.rev.ai/docs</url>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ private String buildURL(
198198
urlBuilder.addQueryParameter(
199199
"remove_disfluencies", String.valueOf(sessionConfig.getRemoveDisfluencies()));
200200
}
201+
if (sessionConfig.getDeleteAfterSeconds() != null) {
202+
urlBuilder.addQueryParameter(
203+
"delete_after_seconds", String.valueOf(sessionConfig.getDeleteAfterSeconds()));
204+
}
201205
}
202206
return urlBuilder.build().toString()
203207
+ "&content_type="

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public class RevAiJobOptions {
5252
@SerializedName("remove_disfluencies")
5353
private Boolean removeDisfluencies;
5454

55+
/** Optional number of seconds after job completion when job is auto-deleted */
56+
@SerializedName("delete_after_seconds")
57+
private Integer deleteAfterSeconds;
58+
5559
/**
5660
* Returns the media url.
5761
*
@@ -208,7 +212,7 @@ public void setFilterProfanity(Boolean filterProfanity) {
208212
/**
209213
* Returns the value of the removeDisfluencies Boolean
210214
*
211-
* @return The remove disfluencies value.
215+
* @return The removeDisfluencies value.
212216
*/
213217
public Boolean getRemoveDisfluencies() {
214218
return removeDisfluencies;
@@ -223,4 +227,23 @@ public Boolean getRemoveDisfluencies() {
223227
public void setRemoveDisfluencies(Boolean removeDisfluencies) {
224228
this.removeDisfluencies = removeDisfluencies;
225229
}
230+
231+
/**
232+
* Returns the value of deleteAfterSeconds.
233+
*
234+
* @return The deleteAfterSeconds value.
235+
*/
236+
public Integer getDeleteAfterSeconds() {
237+
return deleteAfterSeconds;
238+
}
239+
240+
/**
241+
* Specifies the number of seconds to be waited until the job is auto-deleted after its
242+
* completion.
243+
*
244+
* @param deleteAfterSeconds The number of seconds after job completion when job is auto-deleted.
245+
*/
246+
public void setDeleteAfterSeconds(Integer deleteAfterSeconds) {
247+
this.deleteAfterSeconds = deleteAfterSeconds;
248+
}
226249
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class SessionConfig {
77
private Boolean filterProfanity;
88
private String customVocabularyId;
99
private Boolean removeDisfluencies;
10+
private Integer deleteAfterSeconds;
1011

1112
/**
1213
* Returns the metadata.
@@ -86,4 +87,23 @@ public Boolean getRemoveDisfluencies() {
8687
public void setRemoveDisfluencies(Boolean removeDisfluencies) {
8788
this.removeDisfluencies = removeDisfluencies;
8889
}
90+
91+
/**
92+
* Returns the value of deleteAfterSeconds.
93+
*
94+
* @return The deleteAfterSeconds value.
95+
*/
96+
public Integer getDeleteAfterSeconds() {
97+
return deleteAfterSeconds;
98+
}
99+
100+
/**
101+
* Specifies the number of seconds to be waited until the job is auto-deleted after its
102+
* completion.
103+
*
104+
* @param deleteAfterSeconds The number of seconds after job completion when job is auto-deleted.
105+
*/
106+
public void setDeleteAfterSeconds(Integer deleteAfterSeconds) {
107+
this.deleteAfterSeconds = deleteAfterSeconds;
108+
}
89109
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ private SessionConfig createSessionsConfig() {
125125
sessionConfig.setMetaData(testName.getMethodName());
126126
sessionConfig.setFilterProfanity(true);
127127
sessionConfig.setRemoveDisfluencies(true);
128+
sessionConfig.setDeleteAfterSeconds(0);
128129
return sessionConfig;
129130
}
130131

0 commit comments

Comments
 (0)