diff --git a/build.gradle b/build.gradle index f1bdc3f0..2f0c85bb 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ publishing { maven(MavenPublication) { groupId = 'com.assemblyai' artifactId = 'assemblyai-java' - version = '1.2.0' + version = '1.2.1' from components.java pom { scm { diff --git a/src/main/java/com/assemblyai/api/resources/realtime/types/Realtime.java b/src/main/java/com/assemblyai/api/resources/realtime/types/Realtime.java new file mode 100644 index 00000000..4980f1cd --- /dev/null +++ b/src/main/java/com/assemblyai/api/resources/realtime/types/Realtime.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.resources.realtime.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class Realtime { + public static final Realtime PCM_S16LE = new Realtime(Value.PCM_S16LE, "pcm_s16le"); + + public static final Realtime PCM_MULAW = new Realtime(Value.PCM_MULAW, "pcm_mulaw"); + + private final Value value; + + private final String string; + + Realtime(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Realtime && this.string.equals(((Realtime) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PCM_S16LE: + return visitor.visitPcmS16le(); + case PCM_MULAW: + return visitor.visitPcmMulaw(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Realtime valueOf(String value) { + switch (value) { + case "pcm_s16le": + return PCM_S16LE; + case "pcm_mulaw": + return PCM_MULAW; + default: + return new Realtime(Value.UNKNOWN, value); + } + } + + public enum Value { + PCM_S16LE, + + PCM_MULAW, + + UNKNOWN + } + + public interface Visitor { + T visitPcmS16le(); + + T visitPcmMulaw(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/requests/TranscriptParams.java b/src/main/java/com/assemblyai/api/resources/transcripts/requests/TranscriptParams.java index 96e80471..8b52c016 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/requests/TranscriptParams.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/requests/TranscriptParams.java @@ -225,9 +225,6 @@ public Optional getSpeechModel() { return speechModel; } - /** - * @return The URL to which AssemblyAI send webhooks upon transcription completion - */ @JsonProperty("webhook_url") @java.lang.Override public Optional getWebhookUrl() { @@ -235,7 +232,7 @@ public Optional getWebhookUrl() { } /** - * @return The header name which should be sent back with webhook calls + * @return The header name to be sent with the transcript completed or failed webhook requests */ @JsonProperty("webhook_auth_header_name") @java.lang.Override @@ -244,7 +241,7 @@ public Optional getWebhookAuthHeaderName() { } /** - * @return Specify a header name and value to send back with a webhook call for added security + * @return The header value to send back with the transcript completed or failed webhook requests for added security */ @JsonProperty("webhook_auth_header_value") @java.lang.Override @@ -1374,7 +1371,7 @@ public _FinalStage autoHighlights(Optional autoHighlights) { } /** - *

Specify a header name and value to send back with a webhook call for added security

+ *

The header value to send back with the transcript completed or failed webhook requests for added security

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1391,7 +1388,7 @@ public _FinalStage webhookAuthHeaderValue(Optional webhookAuthHeaderValu } /** - *

The header name which should be sent back with webhook calls

+ *

The header name to be sent with the transcript completed or failed webhook requests

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1407,10 +1404,6 @@ public _FinalStage webhookAuthHeaderName(Optional webhookAuthHeaderName) return this; } - /** - *

The URL to which AssemblyAI send webhooks upon transcription completion

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage webhookUrl(String webhookUrl) { this.webhookUrl = Optional.of(webhookUrl); diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/ParagraphsResponse.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/ParagraphsResponse.java index 3890a97d..dd6585de 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/ParagraphsResponse.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/ParagraphsResponse.java @@ -25,7 +25,7 @@ public final class ParagraphsResponse { private final double confidence; - private final double audioDuration; + private final int audioDuration; private final List paragraphs; @@ -34,7 +34,7 @@ public final class ParagraphsResponse { private ParagraphsResponse( String id, double confidence, - double audioDuration, + int audioDuration, List paragraphs, Map additionalProperties) { this.id = id; @@ -55,7 +55,7 @@ public double getConfidence() { } @JsonProperty("audio_duration") - public double getAudioDuration() { + public int getAudioDuration() { return audioDuration; } @@ -107,7 +107,7 @@ public interface ConfidenceStage { } public interface AudioDurationStage { - _FinalStage audioDuration(double audioDuration); + _FinalStage audioDuration(int audioDuration); } public interface _FinalStage { @@ -126,7 +126,7 @@ public static final class Builder implements IdStage, ConfidenceStage, AudioDura private double confidence; - private double audioDuration; + private int audioDuration; private List paragraphs = new ArrayList<>(); @@ -160,7 +160,7 @@ public AudioDurationStage confidence(double confidence) { @java.lang.Override @JsonSetter("audio_duration") - public _FinalStage audioDuration(double audioDuration) { + public _FinalStage audioDuration(int audioDuration) { this.audioDuration = audioDuration; return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/SentencesResponse.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/SentencesResponse.java index 18295bbf..830c2c9c 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/SentencesResponse.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/SentencesResponse.java @@ -25,7 +25,7 @@ public final class SentencesResponse { private final double confidence; - private final double audioDuration; + private final int audioDuration; private final List sentences; @@ -34,7 +34,7 @@ public final class SentencesResponse { private SentencesResponse( String id, double confidence, - double audioDuration, + int audioDuration, List sentences, Map additionalProperties) { this.id = id; @@ -55,7 +55,7 @@ public double getConfidence() { } @JsonProperty("audio_duration") - public double getAudioDuration() { + public int getAudioDuration() { return audioDuration; } @@ -107,7 +107,7 @@ public interface ConfidenceStage { } public interface AudioDurationStage { - _FinalStage audioDuration(double audioDuration); + _FinalStage audioDuration(int audioDuration); } public interface _FinalStage { @@ -126,7 +126,7 @@ public static final class Builder implements IdStage, ConfidenceStage, AudioDura private double confidence; - private double audioDuration; + private int audioDuration; private List sentences = new ArrayList<>(); @@ -160,7 +160,7 @@ public AudioDurationStage confidence(double confidence) { @java.lang.Override @JsonSetter("audio_duration") - public _FinalStage audioDuration(double audioDuration) { + public _FinalStage audioDuration(int audioDuration) { this.audioDuration = audioDuration; return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/Transcript.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/Transcript.java index 1be81efe..2ee86b40 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/Transcript.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/Transcript.java @@ -41,7 +41,7 @@ public final class Transcript { private final Optional confidence; - private final Optional audioDuration; + private final Optional audioDuration; private final Optional punctuate; @@ -146,7 +146,7 @@ private Transcript( Optional> words, Optional> utterances, Optional confidence, - Optional audioDuration, + Optional audioDuration, Optional punctuate, Optional formatText, Optional dualChannel, @@ -340,7 +340,7 @@ public Optional getConfidence() { * @return The duration of this transcript object's media file, in seconds */ @JsonProperty("audio_duration") - public Optional getAudioDuration() { + public Optional getAudioDuration() { return audioDuration; } @@ -374,7 +374,9 @@ public Optional getSpeechModel() { } /** - * @return The URL to which we send webhooks upon transcription completion + * @return The URL to which we send webhook requests. + * We sends two different types of webhook requests. + * One request when a transcript is completed or failed, and one request when the redacted audio is ready if redact_pii_audio is enabled. */ @JsonProperty("webhook_url") public Optional getWebhookUrl() { @@ -382,7 +384,7 @@ public Optional getWebhookUrl() { } /** - * @return The status code we received from your server when delivering your webhook, if a webhook URL was provided + * @return The status code we received from your server when delivering the transcript completed or failed webhook request, if a webhook URL was provided */ @JsonProperty("webhook_status_code") public Optional getWebhookStatusCode() { @@ -398,7 +400,7 @@ public boolean getWebhookAuth() { } /** - * @return The header name which should be sent back with webhook calls + * @return The header name to be sent with the transcript completed or failed webhook requests */ @JsonProperty("webhook_auth_header_name") public Optional getWebhookAuthHeaderName() { @@ -896,9 +898,9 @@ public interface _FinalStage { _FinalStage confidence(Double confidence); - _FinalStage audioDuration(Optional audioDuration); + _FinalStage audioDuration(Optional audioDuration); - _FinalStage audioDuration(Double audioDuration); + _FinalStage audioDuration(Integer audioDuration); _FinalStage punctuate(Optional punctuate); @@ -1177,7 +1179,7 @@ public static final class Builder private Optional punctuate = Optional.empty(); - private Optional audioDuration = Optional.empty(); + private Optional audioDuration = Optional.empty(); private Optional confidence = Optional.empty(); @@ -1923,7 +1925,7 @@ public _FinalStage speedBoost(Optional speedBoost) { } /** - *

The header name which should be sent back with webhook calls

+ *

The header name to be sent with the transcript completed or failed webhook requests

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1940,7 +1942,7 @@ public _FinalStage webhookAuthHeaderName(Optional webhookAuthHeaderName) } /** - *

The status code we received from your server when delivering your webhook, if a webhook URL was provided

+ *

The status code we received from your server when delivering the transcript completed or failed webhook request, if a webhook URL was provided

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1957,7 +1959,9 @@ public _FinalStage webhookStatusCode(Optional webhookStatusCode) { } /** - *

The URL to which we send webhooks upon transcription completion

+ *

The URL to which we send webhook requests. + * We sends two different types of webhook requests. + * One request when a transcript is completed or failed, and one request when the redacted audio is ready if redact_pii_audio is enabled.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2042,14 +2046,14 @@ public _FinalStage punctuate(Optional punctuate) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage audioDuration(Double audioDuration) { + public _FinalStage audioDuration(Integer audioDuration) { this.audioDuration = Optional.of(audioDuration); return this; } @java.lang.Override @JsonSetter(value = "audio_duration", nulls = Nulls.SKIP) - public _FinalStage audioDuration(Optional audioDuration) { + public _FinalStage audioDuration(Optional audioDuration) { this.audioDuration = audioDuration; return this; } diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptOptionalParams.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptOptionalParams.java index d85ad9e3..f91fd9ec 100644 --- a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptOptionalParams.java +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptOptionalParams.java @@ -211,9 +211,6 @@ public Optional getSpeechModel() { return speechModel; } - /** - * @return The URL to which AssemblyAI send webhooks upon transcription completion - */ @JsonProperty("webhook_url") @java.lang.Override public Optional getWebhookUrl() { @@ -221,7 +218,7 @@ public Optional getWebhookUrl() { } /** - * @return The header name which should be sent back with webhook calls + * @return The header name to be sent with the transcript completed or failed webhook requests */ @JsonProperty("webhook_auth_header_name") @java.lang.Override @@ -230,7 +227,7 @@ public Optional getWebhookAuthHeaderName() { } /** - * @return Specify a header name and value to send back with a webhook call for added security + * @return The header value to send back with the transcript completed or failed webhook requests for added security */ @JsonProperty("webhook_auth_header_value") @java.lang.Override diff --git a/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptWebhookNotification.java b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptWebhookNotification.java new file mode 100644 index 00000000..3f0de121 --- /dev/null +++ b/src/main/java/com/assemblyai/api/resources/transcripts/types/TranscriptWebhookNotification.java @@ -0,0 +1,94 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.assemblyai.api.resources.transcripts.types; + +import com.assemblyai.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = TranscriptWebhookNotification.Deserializer.class) +public final class TranscriptWebhookNotification { + private final Object value; + + private final int type; + + private TranscriptWebhookNotification(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((TranscriptReadyNotification) this.value); + } else if (this.type == 1) { + return visitor.visit((RedactedAudioResponse) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TranscriptWebhookNotification && equalTo((TranscriptWebhookNotification) other); + } + + private boolean equalTo(TranscriptWebhookNotification other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static TranscriptWebhookNotification of(TranscriptReadyNotification value) { + return new TranscriptWebhookNotification(value, 0); + } + + public static TranscriptWebhookNotification of(RedactedAudioResponse value) { + return new TranscriptWebhookNotification(value, 1); + } + + public interface Visitor { + T visit(TranscriptReadyNotification value); + + T visit(RedactedAudioResponse value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(TranscriptWebhookNotification.class); + } + + @java.lang.Override + public TranscriptWebhookNotification deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, TranscriptReadyNotification.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, RedactedAudioResponse.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +}