Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ before_install:
script:
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_a973fe4f8e79_key -iv $encrypted_a973fe4f8e79_iv -in .config.properties.enc -out core/src/test/resources/.config.properties -d || true'
- ./gradlew install -x check
- ./gradlew test
- ./gradlew codeCoverageReport
- ./gradlew docs > /dev/null # build the javadoc

after_success:
- bash <(curl -s https://codecov.io/bash)
- .utility/push-javadoc-to-gh-pages.sh
- .utility/deploy_snapshot.sh

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ public class SpeechToText extends WatsonService {
private static final String WORD_SORT = "sort";
private static final String WORD_TYPE_TO_ADD = "word_type_to_add";
private static final String WORDS = "words";
private static final String WORD_SORT_ALPHA = "alphabetical";
private static final String WORD_SORT_PLUS_ALPHA = "+alphabetical";
private static final String WORD_SORT_MINUS_ALPHA = "-alphabetical";
private static final String WORD_SORT_COUNT = "count";
private static final String WORD_SORT_PLUS_COUNT = "+count";
private static final String WORD_SORT_MINUS_COUNT = "-count";

private static final String PATH_CORPORA = "/v1/customizations/%s/corpora";
private static final String PATH_CORPUS = "/v1/customizations/%s/corpora/%s";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ public Builder wordConfidence(Boolean wordConfidence) {
@SerializedName("content-type")
private String contentType;
private Boolean continuous;
@SerializedName("inactivity_timeout")
private Integer inactivityTimeout;

@SerializedName("interim_results")
Expand All @@ -310,9 +311,12 @@ public Builder wordConfidence(Boolean wordConfidence) {

@SerializedName("keywords_threshold")
private Double keywordsThreshold;
@SerializedName("max_alternatives")
private Integer maxAlternatives;
@SerializedName("profanity_filter")
private Boolean profanityFilter;
private String model;
@SerializedName("session_id")
private String sessionId;
private Boolean timestamps;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ public class SpeechToTextIT extends WatsonServiceTest {
private static final String SPEECH_RESOURCE = "src/test/resources/speech_to_text/%s";
private static final String SAMPLE_WAV = String.format(SPEECH_RESOURCE, "sample1.wav");
private static final String TWO_SPEAKERS_WAV = String.format(SPEECH_RESOURCE, "twospeakers.wav");
private static final String SAMPLE_WAV_WITH_PAUSE = String.format(SPEECH_RESOURCE, "sound-with-pause.wav");

private CountDownLatch lock = new CountDownLatch(1);
private SpeechToText service;
private SpeechResults asyncResults;
private Boolean inactivityTimeoutOccurred;
private String customizationId;

/** The expected exception. */
Expand Down Expand Up @@ -310,6 +312,51 @@ public void onTranscription(SpeechResults speechResults) {
assertNotNull(wordAlternatives.get(0).getAlternatives());
}


/**
* Test the inactivity timeout parameter for WebSockets
*
* @throws FileNotFoundException the file not found exception
* @throws InterruptedException the interrupted exception
*/
@Test
public void testInactivityTimeoutWithWebSocket() throws FileNotFoundException, InterruptedException {
RecognizeOptions options = new RecognizeOptions.Builder()
.continuous(true)
.interimResults(true)
.inactivityTimeout(3)
.timestamps(true)
.maxAlternatives(2)
.wordAlternativesThreshold(0.5)
.model(EN_BROADBAND16K)
.contentType(HttpMediaType.AUDIO_WAV)
.build();

FileInputStream audio = new FileInputStream(SAMPLE_WAV_WITH_PAUSE);
service.recognizeUsingWebSocket(audio, options, new BaseRecognizeCallback() {

@Override
public void onDisconnected() {
lock.countDown();
}

@Override
public void onError(Exception e) {
e.printStackTrace();
lock.countDown();
}

@Override
public void onInactivityTimeout(RuntimeException runtimeException) {
inactivityTimeoutOccurred = true;
}
});

lock.await(2, TimeUnit.MINUTES);
assertTrue(inactivityTimeoutOccurred);
}


/**
* Test create recognition job.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -915,5 +915,11 @@ void assertNoErrors() {
throw new AssertionError("There were " + this.errors.size() + " errors");
}
}

@Override
public void onInactivityTimeout(RuntimeException runtimeException) { }

@Override
public void onListening() { }
}
}
Binary file not shown.