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 <[email protected]>
1 parent 4d48ce7 commit aa46747

File tree

72 files changed

+1245
-215
lines changed

Some content is hidden

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

72 files changed

+1245
-215
lines changed

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
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
145145
case $MAX_FD in #(
146146
max*)
147147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
149149
MAX_FD=$( ulimit -H -n ) ||
150150
warn "Could not query maximum file descriptor limit"
151151
esac
152152
case $MAX_FD in #(
153153
'' | soft) :;; #(
154154
*)
155155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
157157
ulimit -n "$MAX_FD" ||
158158
warn "Could not set maximum file descriptor limit to $MAX_FD"
159159
esac
@@ -202,11 +202,11 @@ fi
202202
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203203
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204204

205-
# Collect all arguments for the java command;
206-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
207-
# shell script including quotes and variable substitutions, so put them in
208-
# double quotes to make sure that they get re-expanded; and
209-
# * put everything else in single quotes, so that it's not re-expanded.
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
210210

211211
set -- \
212212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

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
}

src/main/java/com/assemblyai/api/resources/lemur/LemurClient.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ public LemurClient(ClientOptions clientOptions) {
3131
this.clientOptions = clientOptions;
3232
}
3333

34-
/**
35-
* Custom Summary allows you to distill a piece of audio into a few impactful sentences. You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
36-
*/
37-
public LemurSummaryResponse summary(LemurSummaryParameters request) {
38-
return summary(request, null);
39-
}
40-
4134
/**
4235
* Custom Summary allows you to distill a piece of audio into a few impactful sentences. You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
4336
*/
@@ -74,10 +67,10 @@ public LemurSummaryResponse summary(LemurSummaryParameters request, RequestOptio
7467
}
7568

7669
/**
77-
* Question &amp; Answer allows you to ask free-form questions about a single transcript or a group of transcripts. The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.
70+
* Custom Summary allows you to distill a piece of audio into a few impactful sentences. You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
7871
*/
79-
public LemurQuestionAnswerResponse questionAnswer(LemurQuestionAnswerParameters request) {
80-
return questionAnswer(request, null);
72+
public LemurSummaryResponse summary(LemurSummaryParameters request) {
73+
return summary(request, null);
8174
}
8275

8376
/**
@@ -117,10 +110,10 @@ public LemurQuestionAnswerResponse questionAnswer(
117110
}
118111

119112
/**
120-
* Use LeMUR to generate a list of Action Items from a transcript
113+
* Question &amp; Answer allows you to ask free-form questions about a single transcript or a group of transcripts. The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.
121114
*/
122-
public LemurActionItemsResponse actionItems(LemurBaseParameters request) {
123-
return actionItems(request, null);
115+
public LemurQuestionAnswerResponse questionAnswer(LemurQuestionAnswerParameters request) {
116+
return questionAnswer(request, null);
124117
}
125118

126119
/**
@@ -159,10 +152,10 @@ public LemurActionItemsResponse actionItems(LemurBaseParameters request, Request
159152
}
160153

161154
/**
162-
* Use LeMUR to ask anything with Custom Task
155+
* Use LeMUR to generate a list of Action Items from a transcript
163156
*/
164-
public LemurTaskResponse task(LemurTaskParameters request) {
165-
return task(request, null);
157+
public LemurActionItemsResponse actionItems(LemurBaseParameters request) {
158+
return actionItems(request, null);
166159
}
167160

168161
/**
@@ -201,11 +194,10 @@ public LemurTaskResponse task(LemurTaskParameters request, RequestOptions reques
201194
}
202195

203196
/**
204-
* Delete the data for a previously submitted LeMUR request.
205-
* The LLM response data, as well as any context provided in the original request will be removed.
197+
* Use LeMUR to ask anything with Custom Task
206198
*/
207-
public PurgeLemurRequestDataResponse purgeRequestData(String requestId) {
208-
return purgeRequestData(requestId, null);
199+
public LemurTaskResponse task(LemurTaskParameters request) {
200+
return task(request, null);
209201
}
210202

211203
/**
@@ -238,4 +230,12 @@ public PurgeLemurRequestDataResponse purgeRequestData(String requestId, RequestO
238230
throw new RuntimeException(e);
239231
}
240232
}
233+
234+
/**
235+
* Delete the data for a previously submitted LeMUR request.
236+
* The LLM response data, as well as any context provided in the original request will be removed.
237+
*/
238+
public PurgeLemurRequestDataResponse purgeRequestData(String requestId) {
239+
return purgeRequestData(requestId, null);
240+
}
241241
}

src/main/java/com/assemblyai/api/resources/lemur/requests/LemurQuestionAnswerParameters.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
import com.assemblyai.api.types.LemurBaseParametersContext;
99
import com.assemblyai.api.types.LemurModel;
1010
import com.assemblyai.api.types.LemurQuestion;
11+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
12+
import com.fasterxml.jackson.annotation.JsonAnySetter;
1113
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1214
import com.fasterxml.jackson.annotation.JsonInclude;
1315
import com.fasterxml.jackson.annotation.JsonProperty;
1416
import com.fasterxml.jackson.annotation.JsonSetter;
1517
import com.fasterxml.jackson.annotation.Nulls;
1618
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
1719
import java.util.ArrayList;
20+
import java.util.HashMap;
1821
import java.util.List;
22+
import java.util.Map;
1923
import java.util.Objects;
2024
import java.util.Optional;
2125

@@ -34,19 +38,23 @@ public final class LemurQuestionAnswerParameters implements ILemurBaseParameters
3438

3539
private final List<LemurQuestion> questions;
3640

41+
private final Map<String, Object> additionalProperties;
42+
3743
private LemurQuestionAnswerParameters(
3844
List<String> transcriptIds,
3945
Optional<LemurBaseParametersContext> context,
4046
Optional<LemurModel> finalModel,
4147
Optional<Integer> maxOutputSize,
4248
Optional<Double> temperature,
43-
List<LemurQuestion> questions) {
49+
List<LemurQuestion> questions,
50+
Map<String, Object> additionalProperties) {
4451
this.transcriptIds = transcriptIds;
4552
this.context = context;
4653
this.finalModel = finalModel;
4754
this.maxOutputSize = maxOutputSize;
4855
this.temperature = temperature;
4956
this.questions = questions;
57+
this.additionalProperties = additionalProperties;
5058
}
5159

5260
/**
@@ -107,6 +115,11 @@ public boolean equals(Object other) {
107115
return other instanceof LemurQuestionAnswerParameters && equalTo((LemurQuestionAnswerParameters) other);
108116
}
109117

118+
@JsonAnyGetter
119+
public Map<String, Object> getAdditionalProperties() {
120+
return this.additionalProperties;
121+
}
122+
110123
private boolean equalTo(LemurQuestionAnswerParameters other) {
111124
return transcriptIds.equals(other.transcriptIds)
112125
&& context.equals(other.context)
@@ -150,6 +163,9 @@ public static final class Builder {
150163

151164
private List<LemurQuestion> questions = new ArrayList<>();
152165

166+
@JsonAnySetter
167+
private Map<String, Object> additionalProperties = new HashMap<>();
168+
153169
private Builder() {}
154170

155171
public Builder from(LemurQuestionAnswerParameters other) {
@@ -242,7 +258,7 @@ public Builder addAllQuestions(List<LemurQuestion> questions) {
242258

243259
public LemurQuestionAnswerParameters build() {
244260
return new LemurQuestionAnswerParameters(
245-
transcriptIds, context, finalModel, maxOutputSize, temperature, questions);
261+
transcriptIds, context, finalModel, maxOutputSize, temperature, questions, additionalProperties);
246262
}
247263
}
248264
}

0 commit comments

Comments
 (0)