Skip to content

Commit eb6a5ef

Browse files
authored
AISDK:118: Updated Developer Documentation
1 parent 87fe537 commit eb6a5ef

18 files changed

+1339
-1355
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,17 @@ Before contributing to the project please install the following
253253
* [IntelliJ IDE](https://www.jetbrains.com/idea/)
254254
* [google-java-format plugin](https://plugins.jetbrains.com/plugin/8527-google-java-format)
255255

256-
Before opening a pull-request please run the `Code > Reformat Code` option in any classes that were touched to ensure the code is formatted correctly.
256+
Before opening a pull-request
257+
* go to `Settings > Plugins` and install google-java-format.
258+
* then `Settings > google-java-format Settings` and click enable option.
259+
* please run the `Code > Reformat Code` option in any classes that were touched to ensure the code is formatted correctly.
260+
You can also right click on `src` folder and run `Reformat Code`.
257261

258262
Run `mvn package` to build the code, run the unit tests and create the SDK jar.
259263

260264
Run `mvn verify` to also run integration tests. They require the `REVAI_ACCESS_TOKEN` environment variable to be set to a valid rev.ai access token.
265+
266+
To save the `REVAI_ACCESS_TOKEN` to be available for Integration tests
267+
* go to `Run > Edit Configurations` and add a new JUnit configuration if none exists yet.
268+
* for the new JUnit configuration, go to `Environmental Variables` and click on the browse option.
269+
* click `+` and add `TOKEN` under name and `REVAI_ACCESS_TOKEN` under value.

examples/AsyncTranscribeLocalMediaFile.java

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -13,86 +13,86 @@
1313

1414
public class AsyncTranscribeLocalMediaFile {
1515

16-
public static void main(String[] args) {
17-
// Assign your access token to a String
18-
String accessToken = "your_access_token";
16+
public static void main(String[] args) {
17+
// Assign your access token to a String
18+
String accessToken = "your_access_token";
1919

20-
// Initialize the ApiClient with your access token
21-
ApiClient apiClient = new ApiClient(accessToken);
20+
// Initialize the ApiClient with your access token
21+
ApiClient apiClient = new ApiClient(accessToken);
2222

23-
// Create a custom vocabulary for your submission
24-
CustomVocabulary customVocabulary =
25-
new CustomVocabulary(Arrays.asList("Robert Berwick", "Noam Chomsky", "Evelina Fedorenko"));
23+
// Create a custom vocabulary for your submission
24+
CustomVocabulary customVocabulary =
25+
new CustomVocabulary(Arrays.asList("Robert Berwick", "Noam Chomsky", "Evelina Fedorenko"));
2626

27-
// Initialize the RevAiJobOptions object and assign
28-
RevAiJobOptions revAiJobOptions = new RevAiJobOptions();
29-
revAiJobOptions.setCustomVocabularies(Arrays.asList(customVocabulary));
30-
revAiJobOptions.setMetadata("My first submission");
31-
revAiJobOptions.setCallbackUrl("https://example.com");
32-
revAiJobOptions.setSkipPunctuation(false);
33-
revAiJobOptions.setSkipDiarization(false);
34-
revAiJobOptions.setFilterProfanity(true);
35-
revAiJobOptions.setRemoveDisfluencies(true);
36-
revAiJobOptions.setSpeakerChannelsCount(null);
27+
// Initialize the RevAiJobOptions object and assign
28+
RevAiJobOptions revAiJobOptions = new RevAiJobOptions();
29+
revAiJobOptions.setCustomVocabularies(Arrays.asList(customVocabulary));
30+
revAiJobOptions.setMetadata("My first submission");
31+
revAiJobOptions.setCallbackUrl("https://example.com");
32+
revAiJobOptions.setSkipPunctuation(false);
33+
revAiJobOptions.setSkipDiarization(false);
34+
revAiJobOptions.setFilterProfanity(true);
35+
revAiJobOptions.setRemoveDisfluencies(true);
36+
revAiJobOptions.setSpeakerChannelsCount(null);
3737

38-
RevAiJob submittedJob;
38+
RevAiJob submittedJob;
3939

40-
String localFile = "path/to/file";
40+
String localFile = "path/to/file";
4141

42-
try {
43-
// Submit the local file and transcription options
44-
submittedJob = apiClient.submitJobLocalFile(localFile, revAiJobOptions);
45-
} catch (IOException e) {
46-
throw new RuntimeException("Failed to submit file [" + localFile + "] " + e.getMessage());
47-
}
48-
String jobId = submittedJob.getJobId();
49-
System.out.println("Job Id: " + jobId);
50-
System.out.println("Job Status: " + submittedJob.getJobStatus());
51-
System.out.println("Created On: " + submittedJob.getCreatedOn());
52-
53-
// Waits 5 seconds between each status check to see if job is complete
54-
boolean isJobComplete = false;
55-
while (!isJobComplete) {
56-
RevAiJob retrievedJob;
57-
try {
58-
retrievedJob = apiClient.getJobDetails(jobId);
59-
} catch (IOException e) {
60-
throw new RuntimeException("Failed to retrieve job [" + jobId + "] " + e.getMessage());
61-
}
62-
63-
RevAiJobStatus retrievedJobStatus = retrievedJob.getJobStatus();
64-
if (retrievedJobStatus == RevAiJobStatus.TRANSCRIBED
65-
|| retrievedJobStatus == RevAiJobStatus.FAILED) {
66-
isJobComplete = true;
67-
} else {
68-
try {
69-
Thread.sleep(5000);
70-
} catch (InterruptedException e) {
71-
e.printStackTrace();
72-
}
73-
}
74-
}
42+
try {
43+
// Submit the local file and transcription options
44+
submittedJob = apiClient.submitJobLocalFile(localFile, revAiJobOptions);
45+
} catch (IOException e) {
46+
throw new RuntimeException("Failed to submit file [" + localFile + "] " + e.getMessage());
47+
}
48+
String jobId = submittedJob.getJobId();
49+
System.out.println("Job Id: " + jobId);
50+
System.out.println("Job Status: " + submittedJob.getJobStatus());
51+
System.out.println("Created On: " + submittedJob.getCreatedOn());
7552

76-
// Get the transcript and caption outputs
77-
RevAiTranscript objectTranscript;
78-
String textTranscript;
79-
InputStream srtCaptions;
80-
InputStream vttCaptions;
53+
// Waits 5 seconds between each status check to see if job is complete
54+
boolean isJobComplete = false;
55+
while (!isJobComplete) {
56+
RevAiJob retrievedJob;
57+
try {
58+
retrievedJob = apiClient.getJobDetails(jobId);
59+
} catch (IOException e) {
60+
throw new RuntimeException("Failed to retrieve job [" + jobId + "] " + e.getMessage());
61+
}
8162

63+
RevAiJobStatus retrievedJobStatus = retrievedJob.getJobStatus();
64+
if (retrievedJobStatus == RevAiJobStatus.TRANSCRIBED
65+
|| retrievedJobStatus == RevAiJobStatus.FAILED) {
66+
isJobComplete = true;
67+
} else {
8268
try {
83-
objectTranscript = apiClient.getTranscriptObject(jobId);
84-
textTranscript = apiClient.getTranscriptText(jobId);
85-
srtCaptions = apiClient.getCaptions(jobId, RevAiCaptionType.SRT);
86-
vttCaptions = apiClient.getCaptions(jobId, RevAiCaptionType.VTT);
87-
} catch (IOException e) {
88-
e.printStackTrace();
69+
Thread.sleep(5000);
70+
} catch (InterruptedException e) {
71+
e.printStackTrace();
8972
}
73+
}
74+
}
9075

91-
/*
92-
* The job can now be deleted. Deleting the job will remove ALL information
93-
* about the job from the Rev.ai servers. Subsequent requests to Rev.ai that
94-
* use the deleted jobs Id will return 404's.
95-
*/
96-
// apiClient.deleteJob(jobId);
76+
// Get the transcript and caption outputs
77+
RevAiTranscript objectTranscript;
78+
String textTranscript;
79+
InputStream srtCaptions;
80+
InputStream vttCaptions;
81+
82+
try {
83+
objectTranscript = apiClient.getTranscriptObject(jobId);
84+
textTranscript = apiClient.getTranscriptText(jobId);
85+
srtCaptions = apiClient.getCaptions(jobId, RevAiCaptionType.SRT);
86+
vttCaptions = apiClient.getCaptions(jobId, RevAiCaptionType.VTT);
87+
} catch (IOException e) {
88+
e.printStackTrace();
9789
}
90+
91+
/*
92+
* The job can now be deleted. Deleting the job will remove ALL information
93+
* about the job from the Rev.ai servers. Subsequent requests to Rev.ai that
94+
* use the deleted jobs Id will return 404's.
95+
*/
96+
// apiClient.deleteJob(jobId);
97+
}
9898
}

examples/AsyncTranscribeMediaUrl.java

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -13,87 +13,87 @@
1313

1414
public class AsyncTranscribeMediaUrl {
1515

16-
public static void main(String[] args) {
17-
// Assign your access token to a String
18-
String accessToken = "your_access_token";
16+
public static void main(String[] args) {
17+
// Assign your access token to a String
18+
String accessToken = "your_access_token";
1919

20-
// Initialize the ApiClient with your access token
21-
ApiClient apiClient = new ApiClient(accessToken);
20+
// Initialize the ApiClient with your access token
21+
ApiClient apiClient = new ApiClient(accessToken);
2222

23-
// Create a custom vocabulary for your submission
24-
CustomVocabulary customVocabulary =
25-
new CustomVocabulary(Arrays.asList("Robert Berwick", "Noam Chomsky", "Evelina Fedorenko"));
23+
// Create a custom vocabulary for your submission
24+
CustomVocabulary customVocabulary =
25+
new CustomVocabulary(Arrays.asList("Robert Berwick", "Noam Chomsky", "Evelina Fedorenko"));
2626

27-
// Initialize the RevAiJobOptions object and assign
28-
RevAiJobOptions revAiJobOptions = new RevAiJobOptions();
29-
revAiJobOptions.setCustomVocabularies(Arrays.asList(customVocabulary));
30-
revAiJobOptions.setMetadata("My first submission");
31-
revAiJobOptions.setCallbackUrl("https://example.com");
32-
revAiJobOptions.setSkipPunctuation(false);
33-
revAiJobOptions.setSkipDiarization(false);
34-
revAiJobOptions.setFilterProfanity(true);
35-
revAiJobOptions.setRemoveDisfluencies(true);
36-
revAiJobOptions.setSpeakerChannelsCount(null);
27+
// Initialize the RevAiJobOptions object and assign
28+
RevAiJobOptions revAiJobOptions = new RevAiJobOptions();
29+
revAiJobOptions.setCustomVocabularies(Arrays.asList(customVocabulary));
30+
revAiJobOptions.setMetadata("My first submission");
31+
revAiJobOptions.setCallbackUrl("https://example.com");
32+
revAiJobOptions.setSkipPunctuation(false);
33+
revAiJobOptions.setSkipDiarization(false);
34+
revAiJobOptions.setFilterProfanity(true);
35+
revAiJobOptions.setRemoveDisfluencies(true);
36+
revAiJobOptions.setSpeakerChannelsCount(null);
3737

38-
RevAiJob submittedJob;
38+
RevAiJob submittedJob;
3939

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

43-
try {
44-
// Submit the local file and transcription options
45-
submittedJob = apiClient.submitJobUrl(mediaUrl, revAiJobOptions);
46-
} catch (IOException e) {
47-
throw new RuntimeException("Failed to submit url [" + mediaUrl + "] " + e.getMessage());
48-
}
49-
String jobId = submittedJob.getJobId();
50-
System.out.println("Job Id: " + jobId);
51-
System.out.println("Job Status: " + submittedJob.getJobStatus());
52-
System.out.println("Created On: " + submittedJob.getCreatedOn());
53-
54-
// Waits 5 seconds between each status check to see if job is complete
55-
boolean isJobComplete = false;
56-
while (!isJobComplete) {
57-
RevAiJob retrievedJob;
58-
try {
59-
retrievedJob = apiClient.getJobDetails(jobId);
60-
} catch (IOException e) {
61-
throw new RuntimeException("Failed to retrieve job [" + jobId + "] " + e.getMessage());
62-
}
63-
64-
RevAiJobStatus retrievedJobStatus = retrievedJob.getJobStatus();
65-
if (retrievedJobStatus == RevAiJobStatus.TRANSCRIBED
66-
|| retrievedJobStatus == RevAiJobStatus.FAILED) {
67-
isJobComplete = true;
68-
} else {
69-
try {
70-
Thread.sleep(5000);
71-
} catch (InterruptedException e) {
72-
e.printStackTrace();
73-
}
74-
}
75-
}
43+
try {
44+
// Submit the local file and transcription options
45+
submittedJob = apiClient.submitJobUrl(mediaUrl, revAiJobOptions);
46+
} catch (IOException e) {
47+
throw new RuntimeException("Failed to submit url [" + mediaUrl + "] " + e.getMessage());
48+
}
49+
String jobId = submittedJob.getJobId();
50+
System.out.println("Job Id: " + jobId);
51+
System.out.println("Job Status: " + submittedJob.getJobStatus());
52+
System.out.println("Created On: " + submittedJob.getCreatedOn());
7653

77-
// Get the transcript and caption outputs
78-
RevAiTranscript objectTranscript;
79-
String textTranscript;
80-
InputStream srtCaptions;
81-
InputStream vttCaptions;
54+
// Waits 5 seconds between each status check to see if job is complete
55+
boolean isJobComplete = false;
56+
while (!isJobComplete) {
57+
RevAiJob retrievedJob;
58+
try {
59+
retrievedJob = apiClient.getJobDetails(jobId);
60+
} catch (IOException e) {
61+
throw new RuntimeException("Failed to retrieve job [" + jobId + "] " + e.getMessage());
62+
}
8263

64+
RevAiJobStatus retrievedJobStatus = retrievedJob.getJobStatus();
65+
if (retrievedJobStatus == RevAiJobStatus.TRANSCRIBED
66+
|| retrievedJobStatus == RevAiJobStatus.FAILED) {
67+
isJobComplete = true;
68+
} else {
8369
try {
84-
objectTranscript = apiClient.getTranscriptObject(jobId);
85-
textTranscript = apiClient.getTranscriptText(jobId);
86-
srtCaptions = apiClient.getCaptions(jobId, RevAiCaptionType.SRT);
87-
vttCaptions = apiClient.getCaptions(jobId, RevAiCaptionType.VTT);
88-
} catch (IOException e) {
89-
e.printStackTrace();
70+
Thread.sleep(5000);
71+
} catch (InterruptedException e) {
72+
e.printStackTrace();
9073
}
74+
}
75+
}
9176

92-
/*
93-
* The job can now be deleted. Deleting the job will remove ALL information
94-
* about the job from the Rev.ai servers. Subsequent requests to Rev.ai that
95-
* use the deleted jobs Id will return 404's.
96-
*/
97-
// apiClient.deleteJob(jobId);
77+
// Get the transcript and caption outputs
78+
RevAiTranscript objectTranscript;
79+
String textTranscript;
80+
InputStream srtCaptions;
81+
InputStream vttCaptions;
82+
83+
try {
84+
objectTranscript = apiClient.getTranscriptObject(jobId);
85+
textTranscript = apiClient.getTranscriptText(jobId);
86+
srtCaptions = apiClient.getCaptions(jobId, RevAiCaptionType.SRT);
87+
vttCaptions = apiClient.getCaptions(jobId, RevAiCaptionType.VTT);
88+
} catch (IOException e) {
89+
e.printStackTrace();
9890
}
91+
92+
/*
93+
* The job can now be deleted. Deleting the job will remove ALL information
94+
* about the job from the Rev.ai servers. Subsequent requests to Rev.ai that
95+
* use the deleted jobs Id will return 404's.
96+
*/
97+
// apiClient.deleteJob(jobId);
98+
}
9999
}

0 commit comments

Comments
 (0)