Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit aa46747

Browse files
🌿 Fern Regeneration -- November 10, 2023 (#22)
* SDK regeneration * fix compile * poll transcription by default --------- Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: dsinghvi <dsinghvi@umich.edu>
1 parent 4d48ce7 commit aa46747

72 files changed

Lines changed: 1245 additions & 215 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ Transcriber transcriber = Transcriber.builder()
7777
.apiKey("YOUR_API_KEY")
7878
.build();
7979

80-
TranscriptResponse transcript = transcriber.transcribe(
81-
"https://example.org/audio.mp3", true);
80+
TranscriptResponse transcript =
81+
transcriber.transcribe("https://example.org/audio.mp3");
8282
```
8383
8484
## Using the Realtime Transcriber

build.gradle

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ dependencies {
2121
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
2222
}
2323

24+
25+
sourceCompatibility = 1.8
26+
targetCompatibility = 1.8
27+
2428
spotless {
2529
java {
2630
palantirJavaFormat()
@@ -34,14 +38,16 @@ java {
3438

3539
test {
3640
useJUnitPlatform()
41+
testLogging {
42+
showStandardStreams = true
43+
}
3744
}
38-
3945
publishing {
4046
publications {
4147
maven(MavenPublication) {
4248
groupId = 'com.assemblyai'
4349
artifactId = 'assemblyai-java'
44-
version = '0.0.5-beta2'
50+
version = '0.0.5-beta3'
4551
from components.java
4652
}
4753
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample-app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ dependencies {
1313
implementation rootProject
1414
}
1515

16+
17+
sourceCompatibility = 1.8
18+
targetCompatibility = 1.8
19+

sample-app/src/main/java/sample/App.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
import com.assemblyai.api.Transcriber;
66
import com.assemblyai.api.resources.transcript.requests.CreateTranscriptParameters;
77
import com.assemblyai.api.resources.transcript.requests.TranscriptWordSearchRequest;
8+
import com.assemblyai.api.types.ParagraphsResponse;
9+
import com.assemblyai.api.types.SentencesResponse;
810
import com.assemblyai.api.types.SubtitleFormat;
911
import com.assemblyai.api.types.Transcript;
12+
import com.assemblyai.api.types.TranscriptList;
1013
import com.assemblyai.api.types.UploadedFile;
14+
import com.assemblyai.api.types.WordSearchResponse;
1115
import java.io.File;
1216
import java.io.FileInputStream;
1317
import java.io.IOException;
@@ -28,19 +32,19 @@ public static void main(String... args) throws IOException {
2832
transcriber.transcribe("https://storage.googleapis.com/aai-docs-samples/nbc.mp3", true);
2933
System.out.println(transcript);
3034

31-
var sentences = aai.transcript().getSentences(transcript.getId());
35+
SentencesResponse sentences = aai.transcript().getSentences(transcript.getId());
3236
System.out.println("Get transcript sentences. " + sentences);
3337

34-
var paragraphs = aai.transcript().getParagraphs(transcript.getId());
38+
ParagraphsResponse paragraphs = aai.transcript().getParagraphs(transcript.getId());
3539
System.out.println("Get transcript paragraphs. " + paragraphs);
3640

37-
var srt = aai.transcript().getSubtitles(transcript.getId(), SubtitleFormat.SRT);
41+
String srt = aai.transcript().getSubtitles(transcript.getId(), SubtitleFormat.SRT);
3842
System.out.println("Get transcript srt. " + srt);
3943

40-
var vtt = aai.transcript().getSubtitles(transcript.getId(), SubtitleFormat.VTT);
44+
String vtt = aai.transcript().getSubtitles(transcript.getId(), SubtitleFormat.VTT);
4145
System.out.println("Get transcript vtt. " + vtt);
4246

43-
var search = aai.transcript().wordSearch(transcript.getId(), TranscriptWordSearchRequest.builder()
47+
WordSearchResponse search = aai.transcript().wordSearch(transcript.getId(), TranscriptWordSearchRequest.builder()
4448
.words("NBC")
4549
.build());
4650
System.out.println("Search transcript. " + search);
@@ -60,7 +64,7 @@ public static void main(String... args) throws IOException {
6064
transcript = aai.transcript().get(transcript.getId());
6165
System.out.println("Got transcript. " + transcript);
6266

63-
var transcripts = aai.transcript().list();
67+
TranscriptList transcripts = aai.transcript().list();
6468
System.out.println("List transcript. " + transcripts);
6569

6670
RealtimeTranscriber realtimeTranscriber = RealtimeTranscriber.builder()

src/main/java/com/assemblyai/api/Transcriber.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ private Transcriber(AssemblyAI client) {
1818
this.client = client;
1919
}
2020

21+
/**
22+
* Transcribes an audio file whose location can be specified via a URL.
23+
* Polls until transcription is done.
24+
*/
25+
public Transcript transcribe(String url) {
26+
return transcribe(url, CreateTranscriptOptionalParameters.builder().build(), true);
27+
}
28+
2129
/**
2230
* Transcribes an audio file whose location can be specified via a URL.
2331
*/
@@ -56,6 +64,14 @@ public Transcript transcribe(String url, CreateTranscriptOptionalParameters tran
5664
return transcriptResponse;
5765
}
5866

67+
/**
68+
* Transcribes an audio file whose location can be specified via a filepath.
69+
* Polls until transcription is done.
70+
*/
71+
public Transcript transcribe(File data) throws IOException {
72+
return transcribe(data, CreateTranscriptOptionalParameters.builder().build(), true);
73+
}
74+
5975
/**
6076
* Transcribes an audio file whose location can be specified via a filepath.
6177
*/

src/main/java/com/assemblyai/api/core/ClientOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private ClientOptions(
2929
"X-Fern-SDK-Name",
3030
"com.assemblyai.fern:api-sdk",
3131
"X-Fern-SDK-Version",
32-
"0.0.5-beta2",
32+
"0.0.5-beta3",
3333
"X-Fern-Language",
3434
"JAVA"));
3535
this.headerSuppliers = headerSuppliers;

src/main/java/com/assemblyai/api/core/RetryInterceptor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@ public Response intercept(Chain chain) throws IOException {
2525
Response response = chain.proceed(chain.request());
2626

2727
if (shouldRetry(response.code())) {
28-
return retryChain(chain);
28+
return retryChain(response, chain);
2929
}
3030

3131
return response;
3232
}
3333

34-
private Response retryChain(Chain chain) throws IOException {
34+
private Response retryChain(Response response, Chain chain) throws IOException {
3535
Optional<Duration> nextBackoff = this.backoff.nextBackoff();
36-
3736
while (nextBackoff.isPresent()) {
3837
try {
3938
Thread.sleep(nextBackoff.get().toMillis());
4039
} catch (InterruptedException e) {
4140
throw new IOException("Interrupted while trying request", e);
4241
}
43-
Response response = chain.proceed(chain.request());
42+
response.close();
43+
response = chain.proceed(chain.request());
4444
if (shouldRetry(response.code())) {
4545
nextBackoff = this.backoff.nextBackoff();
4646
} else {
4747
return response;
4848
}
4949
}
5050

51-
throw new IOException("Max retries reached");
51+
return response;
5252
}
5353

5454
private static boolean shouldRetry(int statusCode) {

src/main/java/com/assemblyai/api/resources/files/FilesClient.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ public FilesClient(ClientOptions clientOptions) {
2222
this.clientOptions = clientOptions;
2323
}
2424

25-
/**
26-
* Upload your audio or video file directly to the AssemblyAI API if it isn't accessible via a URL already.
27-
*/
28-
public UploadedFile upload(byte[] request) {
29-
return upload(request, null);
30-
}
31-
3225
/**
3326
* Upload your audio or video file directly to the AssemblyAI API if it isn't accessible via a URL already.
3427
*/
@@ -57,4 +50,11 @@ public UploadedFile upload(byte[] request, RequestOptions requestOptions) {
5750
throw new RuntimeException(e);
5851
}
5952
}
53+
54+
/**
55+
* Upload your audio or video file directly to the AssemblyAI API if it isn't accessible via a URL already.
56+
*/
57+
public UploadedFile upload(byte[] request) {
58+
return upload(request, null);
59+
}
6060
}

0 commit comments

Comments
 (0)