Skip to content

Commit d6b6936

Browse files
committedOct 3, 2024··
Add overloads for transcribe accepting InputStream
1 parent 78d2a19 commit d6b6936

File tree

1 file changed

+103
-1
lines changed

1 file changed

+103
-1
lines changed
 

‎src/main/java/com/assemblyai/api/PollingTranscriptsClient.java

+103-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import java.io.File;
1515
import java.io.IOException;
16-
import java.nio.file.Files;
16+
import java.io.InputStream;
1717
import java.nio.file.Path;
1818
import java.util.List;
1919

@@ -29,6 +29,58 @@ public PollingTranscriptsClient(ClientOptions clientOptions, AssemblyAI client)
2929
this.client = client;
3030
}
3131

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+
3284
/**
3385
* Submits a transcription job for an audio file. This will not wait until the transcript status is "completed" or "error".
3486
*
@@ -245,6 +297,56 @@ public Transcript submit(String url, TranscriptOptionalParams transcriptParams,
245297
return super.submit(fullTranscriptParams, requestOptions);
246298
}
247299

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+
248350
/**
249351
* Transcribe an audio file. This will create a transcript and wait until the transcript status is "completed" or "error".
250352
*

0 commit comments

Comments
 (0)
Please sign in to comment.