mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 11:45:49 +01:00
[voice] Add hlis argument to interpret command (#4281)
Signed-off-by: Miguel Álvarez <miguelwork92@gmail.com>
This commit is contained in:
parent
9b39f625e8
commit
5578de155f
@ -101,7 +101,8 @@ public class VoiceConsoleCommandExtension extends AbstractConsoleCommandExtensio
|
|||||||
return List.of(buildCommandUsage(SUBCMD_SAY + " <text>", "speaks a text"), buildCommandUsage(
|
return List.of(buildCommandUsage(SUBCMD_SAY + " <text>", "speaks a text"), buildCommandUsage(
|
||||||
SUBCMD_TRANSCRIBE + " [--source <source>]|[--file <file>] [--stt <stt>] [--locale <locale>]",
|
SUBCMD_TRANSCRIBE + " [--source <source>]|[--file <file>] [--stt <stt>] [--locale <locale>]",
|
||||||
"transcribe audio from default source, optionally specify a different source/file, speech-to-text service or locale"),
|
"transcribe audio from default source, optionally specify a different source/file, speech-to-text service or locale"),
|
||||||
buildCommandUsage(SUBCMD_INTERPRET + " <command>", "interprets a human language command"),
|
buildCommandUsage(SUBCMD_INTERPRET + " [--hlis <comma,separated,interpreters>] <command>",
|
||||||
|
"interprets a human language command"),
|
||||||
buildCommandUsage(SUBCMD_VOICES, "lists available voices of the TTS services"),
|
buildCommandUsage(SUBCMD_VOICES, "lists available voices of the TTS services"),
|
||||||
buildCommandUsage(SUBCMD_DIALOGS, "lists the running dialog and their audio/voice services"),
|
buildCommandUsage(SUBCMD_DIALOGS, "lists the running dialog and their audio/voice services"),
|
||||||
buildCommandUsage(SUBCMD_DIALOG_REGS,
|
buildCommandUsage(SUBCMD_DIALOG_REGS,
|
||||||
@ -280,14 +281,31 @@ public class VoiceConsoleCommandExtension extends AbstractConsoleCommandExtensio
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void interpret(String[] args, Console console) {
|
private void interpret(String[] args, Console console) {
|
||||||
StringBuilder sb = new StringBuilder(args[0]);
|
@Nullable
|
||||||
for (int i = 1; i < args.length; i++) {
|
String hliIdList = null;
|
||||||
|
String[] arguments;
|
||||||
|
if (args.length > 0 && "--hlis".equals(args[0])) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
console.println("No hli id list provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hliIdList = args[1];
|
||||||
|
arguments = Arrays.copyOfRange(args, 2, args.length);
|
||||||
|
} else {
|
||||||
|
arguments = args;
|
||||||
|
}
|
||||||
|
if (arguments.length == 0) {
|
||||||
|
console.println("No command provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder(arguments[0]);
|
||||||
|
for (int i = 1; i < arguments.length; i++) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append(args[i]);
|
sb.append(arguments[i]);
|
||||||
}
|
}
|
||||||
String msg = sb.toString();
|
String msg = sb.toString();
|
||||||
try {
|
try {
|
||||||
String result = voiceManager.interpret(msg);
|
String result = voiceManager.interpret(msg, hliIdList);
|
||||||
console.println(result);
|
console.println(result);
|
||||||
} catch (InterpretationException ie) {
|
} catch (InterpretationException ie) {
|
||||||
console.println(Objects.requireNonNullElse(ie.getMessage(),
|
console.println(Objects.requireNonNullElse(ie.getMessage(),
|
||||||
|
Loading…
Reference in New Issue
Block a user