13
13
14
14
import java .io .File ;
15
15
import java .io .IOException ;
16
- import java .nio . file . Files ;
16
+ import java .io . InputStream ;
17
17
import java .nio .file .Path ;
18
18
import java .util .List ;
19
19
@@ -29,6 +29,58 @@ public PollingTranscriptsClient(ClientOptions clientOptions, AssemblyAI client)
29
29
this .client = client ;
30
30
}
31
31
32
+ /**
33
+ * Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
34
+ *
35
+ * @param file Audio file to transcribe
36
+ * @return Queued transcript
37
+ * @throws IOException The file will be read and an IOException may be thrown.
38
+ */
39
+ public Transcript submit (InputStream file ) throws IOException {
40
+ return submit (file , EMPTY_PARAMS , null );
41
+ }
42
+
43
+ /**
44
+ * Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
45
+ *
46
+ * @param file Audio file to transcribe
47
+ * @param requestOptions The HTTP request options
48
+ * @return Queued transcript
49
+ * @throws IOException The file will be read and an IOException may be thrown.
50
+ */
51
+ public Transcript submit (InputStream file , RequestOptions requestOptions ) throws IOException {
52
+ return submit (file , EMPTY_PARAMS , requestOptions );
53
+ }
54
+
55
+ /**
56
+ * Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
57
+ *
58
+ * @param file Audio file to transcribe
59
+ * @param transcriptParams The parameters to transcribe an audio file.
60
+ * @return Queued transcript
61
+ * @throws IOException The file will be read and an IOException may be thrown.
62
+ */
63
+ public Transcript submit (InputStream file , TranscriptOptionalParams transcriptParams ) throws IOException {
64
+ return submit (file , transcriptParams , null );
65
+ }
66
+
67
+ /**
68
+ * Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
69
+ *
70
+ * @param file Audio file to transcribe
71
+ * @param transcriptParams The parameters to transcribe an audio file.
72
+ * @param requestOptions The HTTP request options
73
+ * @return Queued transcript
74
+ */
75
+ public Transcript submit (
76
+ InputStream file ,
77
+ TranscriptOptionalParams transcriptParams ,
78
+ RequestOptions requestOptions
79
+ ) {
80
+ UploadedFile uploadedFile = client .files ().upload (file , requestOptions );
81
+ return submit (uploadedFile .getUploadUrl (), transcriptParams , requestOptions );
82
+ }
83
+
32
84
/**
33
85
* Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
34
86
*
@@ -245,6 +297,56 @@ public Transcript submit(String url, TranscriptOptionalParams transcriptParams,
245
297
return super .submit (fullTranscriptParams , requestOptions );
246
298
}
247
299
300
+ /**
301
+ * Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
302
+ *
303
+ * @param file Audio file to transcribe
304
+ * @return A transcript with status "completed" or "error"
305
+ * @throws IOException The file will be read and an IOException may be thrown.
306
+ */
307
+ public Transcript transcribe (InputStream file ) throws IOException {
308
+ return transcribe (file , EMPTY_PARAMS , null );
309
+ }
310
+
311
+ /**
312
+ * Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
313
+ *
314
+ * @param file Audio file to transcribe
315
+ * @param requestOptions The HTTP request options
316
+ * @return A transcript with status "completed" or "error"
317
+ * @throws IOException The file will be read and an IOException may be thrown.
318
+ */
319
+ public Transcript transcribe (InputStream file , RequestOptions requestOptions ) throws IOException {
320
+ return transcribe (file , EMPTY_PARAMS , requestOptions );
321
+ }
322
+
323
+ /**
324
+ * Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
325
+ *
326
+ * @param file Audio file to transcribe
327
+ * @param transcriptParams The parameters to transcribe an audio file.
328
+ * @return A transcript with status "completed" or "error"
329
+ * @throws IOException The file will be read and an IOException may be thrown.
330
+ */
331
+ public Transcript transcribe (InputStream file , TranscriptOptionalParams transcriptParams ) throws IOException {
332
+ UploadedFile uploadedFile = client .files ().upload (file );
333
+ return transcribe (uploadedFile .getUploadUrl (), transcriptParams , null );
334
+ }
335
+
336
+ /**
337
+ * Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
338
+ *
339
+ * @param file Audio file to transcribe
340
+ * @param transcriptParams The parameters to transcribe an audio file.
341
+ * @param requestOptions The HTTP request options
342
+ * @return A transcript with status "completed" or "error"
343
+ * @throws IOException The file will be read and an IOException may be thrown.
344
+ */
345
+ public Transcript transcribe (InputStream file , TranscriptOptionalParams transcriptParams , RequestOptions requestOptions ) throws IOException {
346
+ UploadedFile uploadedFile = client .files ().upload (file , requestOptions );
347
+ return transcribe (uploadedFile .getUploadUrl (), transcriptParams , requestOptions );
348
+ }
349
+
248
350
/**
249
351
* Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
250
352
*
@@ -344,7 +446,7 @@ public Transcript transcribe(
344
446
TranscriptOptionalParams transcriptParams ,
345
447
RequestOptions requestOptions
346
448
) throws IOException {
347
- UploadedFile uploadedFile = client .files ().upload (Files . readAllBytes ( file . toPath ()) , requestOptions );
449
+ UploadedFile uploadedFile = client .files ().upload (file , requestOptions );
348
450
return transcribe (uploadedFile .getUploadUrl (), transcriptParams , requestOptions );
349
451
}
350
452
0 commit comments