Skip to content

Commit

Permalink
Add waitUntilReady
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Jul 22, 2024
1 parent 12bc6a9 commit 0f83a9b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.assemblyai'
artifactId = 'assemblyai-java'
version = '2.1.2'
version = '2.1.3'
from components.java
pom {
scm {
Expand Down
2 changes: 2 additions & 0 deletions sample-app/src/main/java/sample/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public static void main(String... args) throws IOException, InterruptedException
return;
}

transcript = client.transcripts().waitUntilReady(transcript.getId());

for (SentimentAnalysisResult result : transcript.getSentimentAnalysisResults().get()) {
System.out.println("Text: " + result.getText());
System.out.println("Sentiment: " + result.getSentiment());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,15 @@ public Transcript transcribe(String url) {
*/
public Transcript transcribe(String url, TranscriptOptionalParams transcriptParams) {
Transcript transcriptResponse = submit(url, transcriptParams);
return awaitCompletion(transcriptResponse.getId());
return waitUntilReady(transcriptResponse.getId());
}

private Transcript awaitCompletion(String transcriptId) {
/**
* Wait until an existing transcript has the status "completed" or "error".
* @param transcriptId The ID of the transcript
* @return The transcript with status "completed" or "error"
*/
public Transcript waitUntilReady(String transcriptId) {
try {
while (true) {
Transcript transcript = this.client.transcripts().get(transcriptId);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/assemblyai/api/core/Constants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.assemblyai.api.core;

public class Constants {
public static final String SDK_VERSION = "2.1.2";
public static final String SDK_VERSION = "2.1.3";
}

0 comments on commit 0f83a9b

Please sign in to comment.