software.amazon.awssdk.services.transcribestreaming.model.Item Maven / Gradle / Ivy
Show all versions of transcribestreaming Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.transcribestreaming.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A word, phrase, or punctuation mark that is transcribed from the input audio.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Item implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField START_TIME_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("StartTime").getter(getter(Item::startTime)).setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartTime").build()).build();
private static final SdkField END_TIME_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("EndTime").getter(getter(Item::endTime)).setter(setter(Builder::endTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndTime").build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Type")
.getter(getter(Item::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type").build()).build();
private static final SdkField CONTENT_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Content")
.getter(getter(Item::content)).setter(setter(Builder::content))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Content").build()).build();
private static final SdkField VOCABULARY_FILTER_MATCH_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("VocabularyFilterMatch").getter(getter(Item::vocabularyFilterMatch))
.setter(setter(Builder::vocabularyFilterMatch))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("VocabularyFilterMatch").build())
.build();
private static final SdkField SPEAKER_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Speaker")
.getter(getter(Item::speaker)).setter(setter(Builder::speaker))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Speaker").build()).build();
private static final SdkField CONFIDENCE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("Confidence").getter(getter(Item::confidence)).setter(setter(Builder::confidence))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Confidence").build()).build();
private static final SdkField STABLE_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("Stable").getter(getter(Item::stable)).setter(setter(Builder::stable))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Stable").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(START_TIME_FIELD,
END_TIME_FIELD, TYPE_FIELD, CONTENT_FIELD, VOCABULARY_FILTER_MATCH_FIELD, SPEAKER_FIELD, CONFIDENCE_FIELD,
STABLE_FIELD));
private static final long serialVersionUID = 1L;
private final Double startTime;
private final Double endTime;
private final String type;
private final String content;
private final Boolean vocabularyFilterMatch;
private final String speaker;
private final Double confidence;
private final Boolean stable;
private Item(BuilderImpl builder) {
this.startTime = builder.startTime;
this.endTime = builder.endTime;
this.type = builder.type;
this.content = builder.content;
this.vocabularyFilterMatch = builder.vocabularyFilterMatch;
this.speaker = builder.speaker;
this.confidence = builder.confidence;
this.stable = builder.stable;
}
/**
*
* The offset from the beginning of the audio stream to the beginning of the audio that resulted in the item.
*
*
* @return The offset from the beginning of the audio stream to the beginning of the audio that resulted in the
* item.
*/
public final Double startTime() {
return startTime;
}
/**
*
* The offset from the beginning of the audio stream to the end of the audio that resulted in the item.
*
*
* @return The offset from the beginning of the audio stream to the end of the audio that resulted in the item.
*/
public final Double endTime() {
return endTime;
}
/**
*
* The type of the item. PRONUNCIATION
indicates that the item is a word that was recognized in the
* input audio. PUNCTUATION
indicates that the item was interpreted as a pause in the input audio.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ItemType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of the item. PRONUNCIATION
indicates that the item is a word that was recognized in
* the input audio. PUNCTUATION
indicates that the item was interpreted as a pause in the input
* audio.
* @see ItemType
*/
public final ItemType type() {
return ItemType.fromValue(type);
}
/**
*
* The type of the item. PRONUNCIATION
indicates that the item is a word that was recognized in the
* input audio. PUNCTUATION
indicates that the item was interpreted as a pause in the input audio.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ItemType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of the item. PRONUNCIATION
indicates that the item is a word that was recognized in
* the input audio. PUNCTUATION
indicates that the item was interpreted as a pause in the input
* audio.
* @see ItemType
*/
public final String typeAsString() {
return type;
}
/**
*
* The word or punctuation that was recognized in the input audio.
*
*
* @return The word or punctuation that was recognized in the input audio.
*/
public final String content() {
return content;
}
/**
*
* Indicates whether a word in the item matches a word in the vocabulary filter you've chosen for your media stream.
* If true
then a word in the item matches your vocabulary filter.
*
*
* @return Indicates whether a word in the item matches a word in the vocabulary filter you've chosen for your media
* stream. If true
then a word in the item matches your vocabulary filter.
*/
public final Boolean vocabularyFilterMatch() {
return vocabularyFilterMatch;
}
/**
*
* If speaker identification is enabled, shows the speakers identified in the media stream.
*
*
* @return If speaker identification is enabled, shows the speakers identified in the media stream.
*/
public final String speaker() {
return speaker;
}
/**
*
* A value between zero and one for an item that is a confidence score that Amazon Transcribe assigns to each word
* or phrase that it transcribes.
*
*
* @return A value between zero and one for an item that is a confidence score that Amazon Transcribe assigns to
* each word or phrase that it transcribes.
*/
public final Double confidence() {
return confidence;
}
/**
*
* If partial result stabilization has been enabled, indicates whether the word or phrase in the item is stable. If
* Stable
is true
, the result is stable.
*
*
* @return If partial result stabilization has been enabled, indicates whether the word or phrase in the item is
* stable. If Stable
is true
, the result is stable.
*/
public final Boolean stable() {
return stable;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(endTime());
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(content());
hashCode = 31 * hashCode + Objects.hashCode(vocabularyFilterMatch());
hashCode = 31 * hashCode + Objects.hashCode(speaker());
hashCode = 31 * hashCode + Objects.hashCode(confidence());
hashCode = 31 * hashCode + Objects.hashCode(stable());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Item)) {
return false;
}
Item other = (Item) obj;
return Objects.equals(startTime(), other.startTime()) && Objects.equals(endTime(), other.endTime())
&& Objects.equals(typeAsString(), other.typeAsString()) && Objects.equals(content(), other.content())
&& Objects.equals(vocabularyFilterMatch(), other.vocabularyFilterMatch())
&& Objects.equals(speaker(), other.speaker()) && Objects.equals(confidence(), other.confidence())
&& Objects.equals(stable(), other.stable());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("Item").add("StartTime", startTime()).add("EndTime", endTime()).add("Type", typeAsString())
.add("Content", content()).add("VocabularyFilterMatch", vocabularyFilterMatch()).add("Speaker", speaker())
.add("Confidence", confidence()).add("Stable", stable()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "StartTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "EndTime":
return Optional.ofNullable(clazz.cast(endTime()));
case "Type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "Content":
return Optional.ofNullable(clazz.cast(content()));
case "VocabularyFilterMatch":
return Optional.ofNullable(clazz.cast(vocabularyFilterMatch()));
case "Speaker":
return Optional.ofNullable(clazz.cast(speaker()));
case "Confidence":
return Optional.ofNullable(clazz.cast(confidence()));
case "Stable":
return Optional.ofNullable(clazz.cast(stable()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function