Skip to content

Commit

Permalink
Set default value so endUtteranceSilenceThreshold isn't null.
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Mar 11, 2024
1 parent d6a6165 commit 172b11c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/java/com/assemblyai/api/RealtimeTranscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public void connect() {

/**
* Stream binary audio data
*
* @param audio byte array audio data
*/
public void sendAudio(byte[] audio) {
Expand All @@ -99,6 +100,7 @@ public void sendAudio(byte[] audio) {

/**
* Stream base64 encoded audio data
*
* @param audio base64 audio data string
*/
public void sendAudio(String audio) {
Expand Down Expand Up @@ -144,7 +146,7 @@ public static final class Builder {
private String apiKey;
private Integer sampleRate;
private List<String> wordBoost;
private Optional<Integer> endUtteranceSilenceThreshold;
private Optional<Integer> endUtteranceSilenceThreshold = Optional.empty();
private Consumer<SessionBegins> onSessionBegins;
private Consumer<PartialTranscript> onPartialTranscript;
private Consumer<FinalTranscript> onFinalTranscript;
Expand All @@ -154,6 +156,7 @@ public static final class Builder {

/**
* Sets api key
*
* @param apiKey The AssemblyAI API Key
* @return this
*/
Expand All @@ -164,6 +167,7 @@ public RealtimeTranscriber.Builder apiKey(String apiKey) {

/**
* Sets sample rate
*
* @param sampleRate The audio sample rate. Defaults to 16_000
* @return this
*/
Expand All @@ -174,6 +178,7 @@ public RealtimeTranscriber.Builder sampleRate(int sampleRate) {

/**
* Sets word boost
*
* @param wordBoost An array of words to boost
* @return this
*/
Expand All @@ -184,6 +189,7 @@ public RealtimeTranscriber.Builder wordBoost(List<String> wordBoost) {

/**
* Configure the threshold for how long to wait before ending an utterance. Default is 700ms.
*
* @param threshold The duration of the end utterance silence threshold in milliseconds
* @return this
*/
Expand All @@ -195,6 +201,7 @@ public RealtimeTranscriber.Builder endUtteranceSilenceThreshold(int threshold) {

/**
* Sets onSessionStart
*
* @param onSessionStart an event handler for the start event. Defaults to a noop.
* @return this
* @deprecated use {@link #onSessionBegins(Consumer)} instead.
Expand All @@ -206,6 +213,7 @@ public RealtimeTranscriber.Builder onSessionStart(Consumer<SessionBegins> onSess

/**
* Sets onSessionBegins
*
* @param onSessionBegins an event handler for the start event. Defaults to a noop.
* @return this
*/
Expand All @@ -216,6 +224,7 @@ public RealtimeTranscriber.Builder onSessionBegins(Consumer<SessionBegins> onSes

/**
* Sets onPartialTranscript
*
* @param onPartialTranscript an event handler for the partial transcript event. Defaults to a noop.
* @return this
*/
Expand All @@ -226,6 +235,7 @@ public RealtimeTranscriber.Builder onPartialTranscript(Consumer<PartialTranscrip

/**
* Sets onPartialTranscript
*
* @param onFinalTranscript an event handler for the final transcript event. Defaults to a noop.
* @return this
*/
Expand All @@ -236,6 +246,7 @@ public RealtimeTranscriber.Builder onFinalTranscript(Consumer<FinalTranscript> o

/**
* Sets onTranscript
*
* @param onTranscript an event handler for any transcript event (partial or final). Defaults to a noop.
* @return this
*/
Expand All @@ -246,6 +257,7 @@ public RealtimeTranscriber.Builder onTranscript(Consumer<RealtimeTranscript> onT

/**
* Sets onError
*
* @param onError an event handler for an error event. Defaults to a noop.
* @return this
*/
Expand All @@ -256,6 +268,7 @@ public RealtimeTranscriber.Builder onError(Consumer<Throwable> onError) {

/**
* Sets onClose
*
* @param onClose an event handler for the closing event. Defaults to a noop.
* @return this
*/
Expand Down

0 comments on commit 172b11c

Please sign in to comment.