Skip to content

Commit 05d25d7

Browse files
committed
Remove approve/reject commands
I couldn't say "I don't" or "I do" to the LLM because it would be recognized as a command. Not useful. So no more of those commands. I'll have to find another way to request confirmation to the user when I need it again.
1 parent 8b820f8 commit 05d25d7

File tree

2 files changed

+27
-77
lines changed

2 files changed

+27
-77
lines changed

app/src/main/java/com/edw590/visor_c_a/Modules/CmdsExecutor/CmdsExecutor.java

+27-69
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,12 @@
5252
import com.edw590.visor_c_a.Modules.CmdsExecutor.CmdsList.CmdsList;
5353
import com.edw590.visor_c_a.Modules.CmdsExecutor.CmdsList.UtilsCmdsList;
5454
import com.edw590.visor_c_a.Modules.Speech.Speech2;
55-
import com.edw590.visor_c_a.Modules.Speech.UtilsSpeech2;
5655
import com.edw590.visor_c_a.Modules.Speech.UtilsSpeech2BC;
5756
import com.edw590.visor_c_a.Modules.SpeechRecognitionCtrl.UtilsSpeechRecognizersBC;
5857
import com.edw590.visor_c_a.Modules.TelephonyManagement.TelephonyManagement;
5958
import com.edw590.visor_c_a.ModulesList;
60-
import com.edw590.visor_c_a.Registry.UtilsRegistry;
6159
import com.edw590.visor_c_a.Registry.RegistryKeys;
60+
import com.edw590.visor_c_a.Registry.UtilsRegistry;
6261
import com.edw590.visor_c_a.TasksList;
6362

6463
import ACD.ACD;
@@ -824,45 +823,40 @@ int processTask(@NonNull final String sentence_str, final boolean partial_result
824823
final String contact_name = contacts_list[contact_index][0];
825824
final String contact_number = contacts_list[contact_index][1];
826825

827-
final Runnable do_after_confirm = () -> {
828-
final Runnable runnable = () -> {
829-
final int return_code = UtilsAndroidTelephony.makePhoneCall(contact_number);
826+
final Runnable runnable = () -> {
827+
final int return_code = UtilsAndroidTelephony.makePhoneCall(contact_number);
830828

831-
switch (return_code) {
832-
case (UtilsAndroid.NO_CALL_EMERGENCY): {
833-
final String speak = "Insufficient privileges to call " + contact_number +
834-
", since it is an emergency number. " +
835-
"Instead, it was only dialed and requires your manual confirmation " +
836-
"to proceed the call.";
837-
UtilsSpeech2BC.speak(speak, speech_priority, speech_mode2, UtilsSpeech2BC.GPT_DUMB, false, null);
838-
839-
break;
840-
}
841-
case (UtilsAndroid.NO_CALL_ANY): {
842-
final String speak = "Insufficient privileges to call numbers. The number " +
843-
"was instead only dialed and requires your manual confirmation " +
844-
"to proceed the call.";
845-
UtilsSpeech2BC.speak(speak, speech_priority, speech_mode2, UtilsSpeech2BC.GPT_DUMB, false, null);
829+
switch (return_code) {
830+
case (UtilsAndroid.NO_CALL_EMERGENCY): {
831+
final String speak = "Insufficient privileges to call " + contact_number +
832+
", since it is an emergency number. " +
833+
"Instead, it was only dialed and requires your manual confirmation " +
834+
"to proceed the call.";
835+
UtilsSpeech2BC.speak(speak, speech_priority, speech_mode2, UtilsSpeech2BC.GPT_DUMB, false, null);
846836

847-
break;
848-
}
849-
case (UtilsAndroid.NOT_AVAILABLE): {
850-
final String speak = "Phone calls not supported on the device.";
851-
UtilsSpeech2BC.speak(speak, speech_priority, speech_mode2, UtilsSpeech2BC.GPT_DUMB, false, null);
837+
break;
838+
}
839+
case (UtilsAndroid.NO_CALL_ANY): {
840+
final String speak = "Insufficient privileges to call numbers. The number " +
841+
"was instead only dialed and requires your manual confirmation " +
842+
"to proceed the call.";
843+
UtilsSpeech2BC.speak(speak, speech_priority, speech_mode2, UtilsSpeech2BC.GPT_DUMB, false, null);
852844

853-
break;
854-
}
845+
break;
855846
}
856-
};
847+
case (UtilsAndroid.NOT_AVAILABLE): {
848+
final String speak = "Phone calls not supported on the device.";
849+
UtilsSpeech2BC.speak(speak, speech_priority, speech_mode2, UtilsSpeech2BC.GPT_DUMB, false, null);
857850

858-
final String speak = "Calling " + contact_name + " now, sir.";
859-
UtilsSpeech2BC.speak(speak, speech_priority, speech_mode2, UtilsSpeech2BC.GPT_NONE, false, runnable);
851+
break;
852+
}
853+
}
860854
};
861855

862-
final String spoken_action = "phone call " + contact_name;
863-
requestConfirmation(spoken_action, speech_mode2);
856+
final String speak = "Calling " + contact_name + " now, sir.";
857+
UtilsSpeech2BC.speak(speak, speech_priority, speech_mode2, UtilsSpeech2BC.GPT_NONE, false, runnable);
864858

865-
previous_cmd = new Command(command, spoken_action, do_after_confirm);
859+
previous_cmd = new Command(command, "phone call " + contact_name, null);
866860
break;
867861
}
868862
case (CmdsList.CmdIds.CMD_STOP_RECORD_MEDIA): {
@@ -1005,29 +999,6 @@ int processTask(@NonNull final String sentence_str, final boolean partial_result
1005999
previous_cmd = new Command(command, "stop media", null);
10061000
break;
10071001
}
1008-
case (CmdsList.CmdIds.CMD_CONFIRM):
1009-
case (CmdsList.CmdIds.CMD_REJECT): {
1010-
some_cmd_detected = true;
1011-
if (only_returning) continue;
1012-
1013-
if (previous_cmd.task_id < 0 ||
1014-
(previous_cmd.detection_when > (System.currentTimeMillis() + 60_000))) {
1015-
// No runnable to execute (no command needing confirmation then) or the previous command was
1016-
// more than a minute ago.
1017-
final String speak = "There is nothing to confirm or reject, sir.";
1018-
UtilsSpeech2BC.speak(speak, speech_priority, speech_mode2, UtilsSpeech2BC.GPT_NONE, false, null);
1019-
} else {
1020-
if (cmd_id.equals(CmdsList.CmdIds.CMD_CONFIRM)) {
1021-
new Thread(TasksList.removeTask(previous_cmd.task_id).runnable).start();
1022-
} else {
1023-
UtilsSpeech2BC.speak(previous_cmd.cmd_spoken_action + " rejected, sir.", speech_priority,
1024-
speech_mode2, UtilsSpeech2BC.GPT_NONE, false, null);
1025-
}
1026-
}
1027-
1028-
previous_cmd = new Command();
1029-
break;
1030-
}
10311002
case (CmdsList.CmdIds.CMD_STOP_LISTENING): {
10321003
some_cmd_detected = true;
10331004
if (only_returning) continue;
@@ -1243,19 +1214,6 @@ int processTask(@NonNull final String sentence_str, final boolean partial_result
12431214
}
12441215
}
12451216

1246-
/**
1247-
* <p>Makes VISOR speak "Do you confirm to [action]?".</p>
1248-
*
1249-
* @param action the action mentioned above
1250-
* @param mode same as in {@link Speech2#speak(String, int, int)}
1251-
*/
1252-
private void requestConfirmation(@NonNull final String action, final int mode) {
1253-
ask_anything_else = false;
1254-
1255-
final String speak = "Do you confirm to " + action + "?";
1256-
UtilsSpeech2BC.speak(speak, Speech2.PRIORITY_USER_ACTION, mode, UtilsSpeech2BC.GPT_NONE, false, UtilsSpeech2.CALL_COMMANDS_RECOG);
1257-
}
1258-
12591217
private void sendToGPT(final String sentence_str) {
12601218
if (!UtilsSWA.isCommunicatorConnectedSERVER()) {
12611219
String speak = "GPT unavailable. Not connected to the server.";

app/src/main/java/com/edw590/visor_c_a/Modules/CmdsExecutor/CmdsList/CmdsList.java

-8
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ public static final class CmdIds {
6262
public static final String CMD_TOGGLE_POWER_SAVER_MODE = "19";
6363
public static final String CMD_STOP_RECORD_MEDIA = "20";
6464
public static final String CMD_CONTROL_MEDIA = "21";
65-
public static final String CMD_CONFIRM = "22";
66-
public static final String CMD_REJECT = "23";
6765
public static final String CMD_STOP_LISTENING = "24";
6866
public static final String CMD_START_LISTENING = "25";
6967
public static final String CMD_TELL_WEATHER = "26";
@@ -172,8 +170,6 @@ public LinkedHashMap<String, String> clone() throws AssertionError {
172170
put(CmdIds.CMD_TOGGLE_POWER_SAVER_MODE, CmdAddInfo.CMDi_INF1_DO_SOMETHING); // 19
173171
put(CmdIds.CMD_STOP_RECORD_MEDIA, CmdAddInfo.CMDi_INF1_DO_SOMETHING); // 20
174172
put(CmdIds.CMD_CONTROL_MEDIA, CmdAddInfo.CMDi_INF1_DO_SOMETHING); // 21
175-
put(CmdIds.CMD_CONFIRM, CmdAddInfo.CMDi_INF1_ASSIST_CMD); // 22
176-
put(CmdIds.CMD_REJECT, CmdAddInfo.CMDi_INF1_ASSIST_CMD); // 23
177173
put(CmdIds.CMD_STOP_LISTENING, CmdAddInfo.CMDi_INF1_DO_SOMETHING); // 24
178174
put(CmdIds.CMD_START_LISTENING, CmdAddInfo.CMDi_INF1_DO_SOMETHING); // 25
179175
put(CmdIds.CMD_TELL_WEATHER, CmdAddInfo.CMDi_INF1_ONLY_SPEAK); // 26
@@ -224,8 +220,6 @@ private AutoCmds() {
224220
{CmdIds.CMD_TOGGLE_POWER_SAVER_MODE, ACD.CMDi_TYPE_TURN_ONFF, "", "", "power/battery saver"}, // 19
225221
{CmdIds.CMD_STOP_RECORD_MEDIA, ACD.CMDi_TYPE_STOP, "", "", "recording/record|recording/record audio/sound"}, // 20
226222
{CmdIds.CMD_CONTROL_MEDIA, ACD.CMDi_TYPE_NONE, "play continue resume pause stop next previous", "play continue resume|pause|stop|next|previous", "media/song/songs/music/audio/musics/video/videos"}, // 21
227-
{CmdIds.CMD_CONFIRM, ACD.CMDi_TYPE_NONE, "i", "", "do/confirm/approve/certify"}, // 22
228-
{CmdIds.CMD_REJECT, ACD.CMDi_TYPE_NONE, "i", "", "don't/reject/disapprove"}, // 23
229223
{CmdIds.CMD_STOP_LISTENING, ACD.CMDi_TYPE_STOP, "", "", "listening"}, // 24
230224
{CmdIds.CMD_START_LISTENING, ACD.CMDi_TYPE_START, "", "", "listening"}, // 25
231225
{CmdIds.CMD_TELL_WEATHER, ACD.CMDi_TYPE_ASK, "", "", "weather"}, // 26
@@ -256,8 +250,6 @@ private AutoCmds() {
256250
"Turn on/off the power/battery saver mode", // 19
257251
"Stop recording [audio/sound]", // 20
258252
"Play/pause/stop/next/previous media (or song, video, etc)", // 21
259-
"I do/confirm/approve/certify (confirm action when VISOR requests it)", // 22
260-
"I don't/reject/disapprove (reject action instead)", // 23
261253
"Stop listening (hotword recognizer - useful if VISOR is not a " + // 24
262254
"system app, in which case he'll lock the microphone on himself)",
263255
"Start listening (if stopped, to start again - or hold the Power button " + // 25

0 commit comments

Comments
 (0)