Skip to content

Commit

Permalink
Simplify disablePartialTranscripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Apr 10, 2024
1 parent ef1e1d3 commit 114cecf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/assemblyai/api/RealtimeTranscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public final class RealtimeTranscriber implements AutoCloseable {
private static final OkHttpClient OK_HTTP_CLIENT = new OkHttpClient.Builder().build();
private final String apiKey;
private final int sampleRate;
private final Optional<Boolean> disablePartialTranscripts;
private final boolean disablePartialTranscripts;
private final Optional<List<String>> wordBoost;
private final Optional<Integer> endUtteranceSilenceThreshold;
private final Consumer<SessionBegins> onSessionBegins;
Expand All @@ -49,7 +49,7 @@ public final class RealtimeTranscriber implements AutoCloseable {
private RealtimeTranscriber(
String apiKey,
int sampleRate,
Optional<Boolean> disablePartialTranscripts,
boolean disablePartialTranscripts,
Optional<List<String>> wordBoost,
Optional<Integer> endUtteranceSilenceThreshold,
Consumer<SessionBegins> onSessionBegins,
Expand Down Expand Up @@ -77,7 +77,7 @@ private RealtimeTranscriber(
*/
public void connect() {
String url = BASE_URL + "/v2/realtime/ws?sample_rate=" + sampleRate;
if(disablePartialTranscripts.isPresent() && disablePartialTranscripts.get()){
if (disablePartialTranscripts) {
url += "&disable_partial_transcripts=true";
}
if (wordBoost.isPresent() && !wordBoost.get().isEmpty()) {
Expand Down Expand Up @@ -152,7 +152,7 @@ public static final class Builder {
private static final int DEFAULT_SAMPLE_RATE = 16_000;
private String apiKey;
private Integer sampleRate;
private Optional<Boolean> disablePartialTranscripts;
private boolean disablePartialTranscripts;
private List<String> wordBoost;
private Optional<Integer> endUtteranceSilenceThreshold = Optional.empty();
private Consumer<SessionBegins> onSessionBegins;
Expand Down Expand Up @@ -190,7 +190,7 @@ public RealtimeTranscriber.Builder sampleRate(int sampleRate) {
* @return this
*/
public RealtimeTranscriber.Builder disablePartialTranscripts() {
this.disablePartialTranscripts = Optional.of(true);
this.disablePartialTranscripts = true;
return this;
}

Expand Down

0 comments on commit 114cecf

Please sign in to comment.