mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
[voice] Fix try all interpreters (#2980)
* fix try all interpreters * add test Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com>
This commit is contained in:
+3
-1
@@ -302,6 +302,7 @@ public class VoiceManagerImpl implements VoiceManager, ConfigOptionProvider {
|
||||
|
||||
if (!interpreters.isEmpty()) {
|
||||
Locale locale = localeProvider.getLocale();
|
||||
InterpretationException exception = null;
|
||||
for (var interpreter : interpreters) {
|
||||
try {
|
||||
String answer = interpreter.interpret(locale, text);
|
||||
@@ -309,9 +310,10 @@ public class VoiceManagerImpl implements VoiceManager, ConfigOptionProvider {
|
||||
return answer;
|
||||
} catch (InterpretationException e) {
|
||||
logger.debug("Interpretation exception: {}", e.getMessage());
|
||||
throw e;
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
throw exception;
|
||||
}
|
||||
|
||||
if (hliIdList == null) {
|
||||
|
||||
+12
@@ -177,6 +177,18 @@ public class VoiceManagerImplTest extends JavaOSGiTest {
|
||||
assertThat(result, is("Interpreted text"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void interpretSomethingWithGivenMultipleHliIdsWhenFirstFails() throws InterpretationException {
|
||||
hliStub = new HumanLanguageInterpreterStub();
|
||||
registerService(hliStub);
|
||||
hliStub.setExceptionExpected(true);
|
||||
var anotherHLIStub = new HumanLanguageInterpreterStub();
|
||||
registerService(anotherHLIStub);
|
||||
String result = voiceManager.interpret("something",
|
||||
String.join(",", List.of(hliStub.getId(), anotherHLIStub.getId())));
|
||||
assertThat(result, is("Interpreted text"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyThatADialogIsNotStartedWhenAnyOfTheRequiredServiceIsNull() {
|
||||
sttService = new STTServiceStub();
|
||||
|
||||
Reference in New Issue
Block a user