@@ -130,90 +130,6 @@ public void SubmitJob_SourceConfigAndNotificationConfigSet_ReturnsLanguageIdJobI
130130 assertLanguageIdJob (languageIdJob );
131131 }
132132
133- @ Test
134- public void Example () throws IOException {
135- String accessToken = "<YOUR_ACCESS_TOKEN>" ;
136-
137- // Initialize the LanguageIdClient with your access token
138- LanguageIdClient languageIdClient = new LanguageIdClient (accessToken );
139-
140- // Set up source configuration parameters
141- String mediaUrl = "https://www.rev.ai/FTC_Sample_1.mp3" ;
142- // Authorization header is optional; use it if needed to access the source media url
143- Map <String , String > sourceAuth = new HashMap <>();
144- sourceAuth .put ("Authorization" , "Bearer <source_token>" );
145-
146- // Set up notification configuration parameters
147- String callbackUrl = "https://example.com" ;
148- // Authorization header is optional; use it if needed to access the callback url
149- Map <String , String > notificationAuth = new HashMap <>();
150- notificationAuth .put ("Authorization" , "Bearer <notification_token>" );
151-
152- // Initialize the LanguageIdJobOptions object and assign
153- LanguageIdJobOptions languageIdJobOptions = new LanguageIdJobOptions ();
154- languageIdJobOptions .setSourceConfig (mediaUrl , sourceAuth );
155- languageIdJobOptions .setMetadata ("My first submission" );
156- languageIdJobOptions .setNotificationConfig (callbackUrl , notificationAuth );
157- languageIdJobOptions .setDeleteAfterSeconds (2592000 ); // 30 days in seconds
158-
159- LanguageIdJob submittedJob ;
160-
161- try {
162- // Submit job with language id options
163- submittedJob = languageIdClient .submitJob (languageIdJobOptions );
164- } catch (IOException e ) {
165- throw new RuntimeException ("Failed to submit url [" + mediaUrl + "] " + e .getMessage ());
166- }
167- String jobId = submittedJob .getJobId ();
168- System .out .println ("Job Id: " + jobId );
169- System .out .println ("Job Status: " + submittedJob .getJobStatus ());
170- System .out .println ("Created On: " + submittedJob .getCreatedOn ());
171-
172- // Waits 5 seconds between each status check to see if job is complete
173- boolean isJobComplete = false ;
174- while (!isJobComplete ) {
175- LanguageIdJob retrievedJob ;
176- try {
177- retrievedJob = languageIdClient .getJobDetails (jobId );
178- } catch (IOException e ) {
179- throw new RuntimeException ("Failed to retrieve job [" + jobId + "] " + e .getMessage ());
180- }
181-
182- LanguageIdJobStatus retrievedJobStatus = retrievedJob .getJobStatus ();
183- if (retrievedJobStatus == LanguageIdJobStatus .COMPLETED
184- || retrievedJobStatus == LanguageIdJobStatus .FAILED ) {
185- isJobComplete = true ;
186- } else {
187- try {
188- Thread .sleep (5000 );
189- } catch (InterruptedException e ) {
190- e .printStackTrace ();
191- }
192- }
193- }
194-
195- // Get the language id result
196- LanguageIdResult languageIdResult ;
197-
198- try {
199- languageIdResult = languageIdClient .getResultObject (jobId );
200- System .out .printf ("Top Language: %s\n " , languageIdResult .getTopLanguage ());
201- for (LanguageConfidence languageConfidence : languageIdResult .getLanguageConfidences ()) {
202- System .out .printf ("Language: %s Confidence: %f\n " , languageConfidence .getLanguage (), languageConfidence .getConfidence ());
203- }
204- } catch (IOException e ) {
205- e .printStackTrace ();
206- }
207-
208- /*
209- * The job can now be deleted. Deleting the job will remove ALL information
210- * about the job from the Rev AI servers. Subsequent requests to Rev AI that
211- * use the deleted jobs Id will return 404's.
212- */
213- // languageIdClient.deleteJob(jobId);
214- // System.out.printf("Deleted language id job %s", jobId);
215- }
216-
217133 public void assertLanguageIdJob (LanguageIdJob languageIdJob ) {
218134 assertThat (languageIdJob .getJobId ()).as ("Job Id" ).isNotNull ();
219135 assertThat (languageIdJob .getJobStatus ()).as ("Job status" ).isEqualTo (LanguageIdJobStatus .IN_PROGRESS );
0 commit comments