|
13 | 13 |
|
14 | 14 | public class AsyncTranscribeMediaUrl { |
15 | 15 |
|
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"; |
19 | 19 |
|
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); |
22 | 22 |
|
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")); |
26 | 26 |
|
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); |
37 | 37 |
|
38 | | - RevAiJob submittedJob; |
| 38 | + RevAiJob submittedJob; |
39 | 39 |
|
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"; |
42 | 42 |
|
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()); |
76 | 53 |
|
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 | + } |
82 | 63 |
|
| 64 | + RevAiJobStatus retrievedJobStatus = retrievedJob.getJobStatus(); |
| 65 | + if (retrievedJobStatus == RevAiJobStatus.TRANSCRIBED |
| 66 | + || retrievedJobStatus == RevAiJobStatus.FAILED) { |
| 67 | + isJobComplete = true; |
| 68 | + } else { |
83 | 69 | 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(); |
90 | 73 | } |
| 74 | + } |
| 75 | + } |
91 | 76 |
|
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(); |
98 | 90 | } |
| 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 | + } |
99 | 99 | } |
0 commit comments