/** * * * <pre> * *Optional* array of [SpeechContext][google.cloud.speech.v1.SpeechContext]. * A means to provide context to assist the speech recognition. For more * information, see [Phrase Hints](/speech-to-text/docs/basics#phrase-hints). * </pre> * * <code>repeated .google.cloud.speech.v1.SpeechContext speech_contexts = 6;</code> */ public Builder addSpeechContexts( int index, com.google.cloud.speech.v1.SpeechContext.Builder builderForValue) { if (speechContextsBuilder_ == null) { ensureSpeechContextsIsMutable(); speechContexts_.add(index, builderForValue.build()); onChanged(); } else { speechContextsBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * *Optional* A list of strings containing words and phrases "hints" so that * the speech recognition is more likely to recognize them. This can be used * to improve the accuracy for specific words and phrases, for example, if * specific commands are typically spoken by the user. This can also be used * to add additional words to the vocabulary of the recognizer. See * [usage limits](/speech-to-text/quotas#content). * </pre> * * <code>repeated string phrases = 1;</code> */ public Builder setPhrases(int index, java.lang.String value) { if (value == null) { throw new NullPointerException(); } ensurePhrasesIsMutable(); phrases_.set(index, value); onChanged(); return this; } /**
@java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { com.google.cloud.speech.v1.SpeechContext parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (com.google.cloud.speech.v1.SpeechContext) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; }
/** * Initialize speechContexts if needed, by getting all the phrases used * by the action handlers to detect commands to handle. * Inserts all speechContexts to the <tt>RecognitionConfig.Builder</tt>. * @param builder the builder where to add speech contexts. */ private void addSpeechContexts(RecognitionConfig.Builder builder) { if (speechContexts == null) { speechContexts = new ArrayList<>(); ActionServicesHandler.getInstance().getPhrases() .stream().map(ph -> speechContexts.add( SpeechContext.newBuilder().addPhrases(ph).build())); } speechContexts.stream().map(ctx -> builder.addSpeechContexts(ctx)); }
/** * * * <pre> * *Optional* array of [SpeechContext][google.cloud.speech.v1.SpeechContext]. * A means to provide context to assist the speech recognition. For more * information, see [Phrase Hints](/speech-to-text/docs/basics#phrase-hints). * </pre> * * <code>repeated .google.cloud.speech.v1.SpeechContext speech_contexts = 6;</code> */ public Builder setSpeechContexts( int index, com.google.cloud.speech.v1.SpeechContext.Builder builderForValue) { if (speechContextsBuilder_ == null) { ensureSpeechContextsIsMutable(); speechContexts_.set(index, builderForValue.build()); onChanged(); } else { speechContextsBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * *Optional* array of [SpeechContext][google.cloud.speech.v1.SpeechContext]. * A means to provide context to assist the speech recognition. For more * information, see [Phrase Hints](/speech-to-text/docs/basics#phrase-hints). * </pre> * * <code>repeated .google.cloud.speech.v1.SpeechContext speech_contexts = 6;</code> */ public Builder addSpeechContexts( com.google.cloud.speech.v1.SpeechContext.Builder builderForValue) { if (speechContextsBuilder_ == null) { ensureSpeechContextsIsMutable(); speechContexts_.add(builderForValue.build()); onChanged(); } else { speechContextsBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * *Optional* A list of strings containing words and phrases "hints" so that * the speech recognition is more likely to recognize them. This can be used * to improve the accuracy for specific words and phrases, for example, if * specific commands are typically spoken by the user. This can also be used * to add additional words to the vocabulary of the recognizer. See * [usage limits](/speech-to-text/quotas#content). * </pre> * * <code>repeated string phrases = 1;</code> */ public Builder addPhrasesBytes(com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); ensurePhrasesIsMutable(); phrases_.add(value); onChanged(); return this; }
/** * * * <pre> * *Optional* A list of strings containing words and phrases "hints" so that * the speech recognition is more likely to recognize them. This can be used * to improve the accuracy for specific words and phrases, for example, if * specific commands are typically spoken by the user. This can also be used * to add additional words to the vocabulary of the recognizer. See * [usage limits](/speech-to-text/quotas#content). * </pre> * * <code>repeated string phrases = 1;</code> */ public Builder addPhrases(java.lang.String value) { if (value == null) { throw new NullPointerException(); } ensurePhrasesIsMutable(); phrases_.add(value); onChanged(); return this; } /**
/** * * * <pre> * *Optional* A list of strings containing words and phrases "hints" so that * the speech recognition is more likely to recognize them. This can be used * to improve the accuracy for specific words and phrases, for example, if * specific commands are typically spoken by the user. This can also be used * to add additional words to the vocabulary of the recognizer. See * [usage limits](/speech-to-text/quotas#content). * </pre> * * <code>repeated string phrases = 1;</code> */ public Builder addAllPhrases(java.lang.Iterable<java.lang.String> values) { ensurePhrasesIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll(values, phrases_); onChanged(); return this; } /**
private Builder() { maybeForceBuilderInitialization(); }
public static Builder newBuilder(com.google.cloud.speech.v1.SpeechContext prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); }
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); }
public Builder mergeFrom(com.google.cloud.speech.v1.SpeechContext other) { if (other == com.google.cloud.speech.v1.SpeechContext.getDefaultInstance()) return this; if (!other.phrases_.isEmpty()) { if (phrases_.isEmpty()) { phrases_ = other.phrases_; bitField0_ = (bitField0_ & ~0x00000001); } else { ensurePhrasesIsMutable(); phrases_.addAll(other.phrases_); } onChanged(); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public com.google.cloud.speech.v1.SpeechContext buildPartial() { com.google.cloud.speech.v1.SpeechContext result = new com.google.cloud.speech.v1.SpeechContext(this); int from_bitField0_ = bitField0_; if (((bitField0_ & 0x00000001) == 0x00000001)) { phrases_ = phrases_.getUnmodifiableView(); bitField0_ = (bitField0_ & ~0x00000001); } result.phrases_ = phrases_; onBuilt(); return result; }
@java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof com.google.cloud.speech.v1.SpeechContext) { return mergeFrom((com.google.cloud.speech.v1.SpeechContext) other); } else { super.mergeFrom(other); return this; } }
@java.lang.Override protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /**
@java.lang.Override public com.google.cloud.speech.v1.SpeechContext build() { com.google.cloud.speech.v1.SpeechContext result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }