Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
fix: typo in Spokestack ASR profile
Browse files Browse the repository at this point in the history
  • Loading branch information
space-pope committed Mar 8, 2021
1 parent d4358e4 commit 1b6293b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public SpeechPipeline.Builder apply(SpeechPipeline.Builder builder) {
stages.add("io.spokestack.spokestack.webrtc.VoiceActivityDetector");
stages.add("io.spokestack.spokestack.ActivationTimeout");
stages.add(
"io.spokestack.spokestack.android.SpokestackCloudRecognizer");
"io.spokestack.spokestack.asr.SpokestackCloudRecognizer");

return builder
.setInputClass("io.spokestack.spokestack.android.MicrophoneInput")
Expand Down
38 changes: 33 additions & 5 deletions src/test/java/io/spokestack/spokestack/SpeechPipelineTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.spokestack.spokestack;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.concurrent.Semaphore;
Expand Down Expand Up @@ -105,17 +106,44 @@ public void testBuilder() throws Exception {
}

@Test
public void testProfiles() {
@SuppressWarnings("unchecked")
public void testProfiles() throws Exception {
assertThrows(IllegalArgumentException.class, () ->
new SpeechPipeline.Builder()
.useProfile("io.spokestack.InvalidProfile")
);

// no pre-set profiles should throw errors on use
// (use instantiates the associated profile class)
SpeechConfig config = new SpeechConfig();
Field stageField = SpeechPipeline.Builder.class
.getDeclaredField("stageClasses");
stageField.setAccessible(true);

// all classes from all profiles should be accessible on the classpath
for (Class<?> profileClass : PROFILES) {
new SpeechPipeline.Builder()
.useProfile(profileClass.getCanonicalName());
SpeechPipeline.Builder builder =
new SpeechPipeline.Builder()
.useProfile(profileClass.getCanonicalName());

List<String> stages = (List<String>) stageField.get(builder);

for (String stageName : stages) {
try {
SpeechProcessor processor = (SpeechProcessor) Class
.forName(stageName)
.getConstructor(SpeechConfig.class)
.newInstance(new Object[]{config});
} catch (ClassNotFoundException e) {
// we're checking for typos in the fully qualified stage
// names here, so this is the only error we care about
fail("stage " + stageName + " not found for profile " +
profileClass);
} catch (Exception | Error e) {
// various errors are expected because
// this test doesn't provide a proper runtime environment
// or configuration for the stages,
// so do nothing here
}
}
}

// The implicated class requires a config property
Expand Down

0 comments on commit 1b6293b

Please sign in to comment.