Class RealtimeTranscriber.Builder

  • Enclosing class:
    RealtimeTranscriber

    public static final class RealtimeTranscriber.Builder
    extends java.lang.Object
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • apiKey

        public RealtimeTranscriber.Builder apiKey​(java.lang.String apiKey)
        Sets api key
        Parameters:
        apiKey - The AssemblyAI API Key
        Returns:
        this
      • sampleRate

        public RealtimeTranscriber.Builder sampleRate​(int sampleRate)
        Sets sample rate
        Parameters:
        sampleRate - The audio sample rate. Defaults to 16_000
        Returns:
        this
      • wordBoost

        public RealtimeTranscriber.Builder wordBoost​(java.util.List<java.lang.String> wordBoost)
        Sets word boost
        Parameters:
        wordBoost - An array of words to boost
        Returns:
        this
      • endUtteranceSilenceThreshold

        public RealtimeTranscriber.Builder endUtteranceSilenceThreshold​(int threshold)
        Configure the threshold for how long to wait before ending an utterance. Default is 700ms.
        Parameters:
        threshold - The duration of the end utterance silence threshold in milliseconds
        Returns:
        this
      • onSessionBegins

        public RealtimeTranscriber.Builder onSessionBegins​(java.util.function.Consumer<SessionBegins> onSessionBegins)
        Sets onSessionBegins
        Parameters:
        onSessionBegins - an event handler for the start event. Defaults to a noop.
        Returns:
        this
      • onPartialTranscript

        public RealtimeTranscriber.Builder onPartialTranscript​(java.util.function.Consumer<PartialTranscript> onPartialTranscript)
        Sets onPartialTranscript
        Parameters:
        onPartialTranscript - an event handler for the partial transcript event. Defaults to a noop.
        Returns:
        this
      • onFinalTranscript

        public RealtimeTranscriber.Builder onFinalTranscript​(java.util.function.Consumer<FinalTranscript> onFinalTranscript)
        Sets onPartialTranscript
        Parameters:
        onFinalTranscript - an event handler for the final transcript event. Defaults to a noop.
        Returns:
        this
      • onTranscript

        public RealtimeTranscriber.Builder onTranscript​(java.util.function.Consumer<RealtimeTranscript> onTranscript)
        Sets onTranscript
        Parameters:
        onTranscript - an event handler for any transcript event (partial or final). Defaults to a noop.
        Returns:
        this
      • onError

        public RealtimeTranscriber.Builder onError​(java.util.function.Consumer<java.lang.Throwable> onError)
        Sets onError
        Parameters:
        onError - an event handler for an error event. Defaults to a noop.
        Returns:
        this
      • onClose

        public RealtimeTranscriber.Builder onClose​(java.util.function.BiConsumer<java.lang.Integer,​java.lang.String> onClose)
        Sets onClose
        Parameters:
        onClose - an event handler for the closing event. Defaults to a noop.
        Returns:
        this