Skip to content

Commit 0991d29

Browse files
authored
Merge pull request #14 from Unity-Lab-AI/revert-13-codex/fix-hardcoded-input-issue-for-voice-commands
Revert "Fix voice command text being trimmed"
2 parents a21b330 + aa81772 commit 0991d29

File tree

3 files changed

+49
-44
lines changed

3 files changed

+49
-44
lines changed

chat-core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ document.addEventListener("DOMContentLoaded", () => {
194194
return true;
195195
}
196196

197-
const clickMatch = message.match(/^(click|press|activate|toggle|open|start|close|stop|pause|resume|play|save|copy|hide|exit|fullscreen) (?:the )?(.+)$/i);
197+
const clickMatch = message.match(/^(click|press|activate|toggle|open|start|close|stop|pause|resume|play|save|copy|hide|show|exit|fullscreen) (?:the )?(.+)$/i);
198198
if (clickMatch) {
199199
const verb = clickMatch[1].toLowerCase();
200200
const target = clickMatch[2].trim();
@@ -221,7 +221,7 @@ document.addEventListener("DOMContentLoaded", () => {
221221
return true;
222222
}
223223

224-
const singleMatch = message.match(/^(pause|resume|play|save|copy|hide|exit|fullscreen)$/i);
224+
const singleMatch = message.match(/^(pause|resume|play|save|copy|hide|show|exit|fullscreen)$/i);
225225
if (singleMatch) {
226226
const verb = singleMatch[1];
227227
const el = findElement(verb);

chat-init.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -678,13 +678,13 @@ document.addEventListener("DOMContentLoaded", () => {
678678
clearTimeout(silenceTimeout);
679679
silenceTimeout = setTimeout(() => {
680680
if (voiceBuffer.trim()) {
681-
window.addNewMessage({ role: "user", content: voiceBuffer.trim() });
682-
window.sendToPollinations();
683-
voiceBuffer = "";
684-
chatInput.value = "";
685-
}
686-
}, 1500);
687-
}
681+
window.addNewMessage({ role: "user", content: voiceBuffer.trim() });
682+
window.sendToPollinations(startVoiceChatSlideshow);
683+
voiceBuffer = "";
684+
chatInput.value = "";
685+
}
686+
}, 1500);
687+
}
688688
};
689689
}
690690
return true;
@@ -732,19 +732,21 @@ document.addEventListener("DOMContentLoaded", () => {
732732
modalBody.appendChild(controlsDiv);
733733
startBtn.addEventListener("click", () => {
734734
if (!setupCustomSpeechRecognition()) return showToast("Failed to initialize speech recognition");
735-
try {
736-
window._chatInternals.recognition.start();
737-
} catch (error) {
738-
showToast("Could not start speech recognition: " + error.message);
739-
}
740-
});
741-
stopBtn.addEventListener("click", () => {
742-
if (window._chatInternals.recognition && window._chatInternals.isListening) {
743-
window._chatInternals.recognition.stop();
744-
showToast("Voice recognition stopped");
745-
}
746-
});
747-
};
735+
try {
736+
window._chatInternals.recognition.start();
737+
startVoiceChatSlideshow();
738+
} catch (error) {
739+
showToast("Could not start speech recognition: " + error.message);
740+
}
741+
});
742+
stopBtn.addEventListener("click", () => {
743+
if (window._chatInternals.recognition && window._chatInternals.isListening) {
744+
window._chatInternals.recognition.stop();
745+
stopVoiceChatSlideshow();
746+
showToast("Voice recognition stopped");
747+
}
748+
});
749+
};
748750
const updateAllVoiceDropdowns = selectedIndex => {
749751
["voice-select", "voice-select-modal", "voice-settings-modal", "voice-select-voicechat"].forEach(id => {
750752
const dropdown = document.getElementById(id);

chat-storage.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -721,15 +721,16 @@ document.addEventListener("DOMContentLoaded", () => {
721721
clearTimeout(silenceTimeout);
722722
silenceTimeout = setTimeout(() => {
723723
if (voiceBuffer.trim()) {
724-
window.addNewMessage({ role: "user", content: voiceBuffer.trim() });
725-
window.sendToPollinations(() => {
726-
chatInput.focus();
727-
});
728-
voiceBuffer = "";
729-
chatInput.value = "";
730-
}
731-
}, 1500);
732-
}
724+
window.addNewMessage({ role: "user", content: voiceBuffer.trim() });
725+
window.sendToPollinations(() => {
726+
startVoiceChatSlideshow();
727+
chatInput.focus();
728+
});
729+
voiceBuffer = "";
730+
chatInput.value = "";
731+
}
732+
}, 1500);
733+
}
733734
};
734735
}
735736
return true;
@@ -786,19 +787,21 @@ document.addEventListener("DOMContentLoaded", () => {
786787
return;
787788
}
788789
const recognition = window._chatInternals.recognition;
789-
try {
790-
recognition.start();
791-
} catch (error) {
792-
showToast("Could not start speech recognition: " + error.message);
793-
}
794-
});
795-
stopBtn.addEventListener("click", () => {
796-
if (window._chatInternals.recognition && window._chatInternals.isListening) {
797-
window._chatInternals.recognition.stop();
798-
showToast("Voice recognition stopped");
799-
}
800-
});
801-
}
790+
try {
791+
recognition.start();
792+
startVoiceChatSlideshow();
793+
} catch (error) {
794+
showToast("Could not start speech recognition: " + error.message);
795+
}
796+
});
797+
stopBtn.addEventListener("click", () => {
798+
if (window._chatInternals.recognition && window._chatInternals.isListening) {
799+
window._chatInternals.recognition.stop();
800+
stopVoiceChatSlideshow();
801+
showToast("Voice recognition stopped");
802+
}
803+
});
804+
}
802805
function updateAllVoiceDropdowns(selectedIndex) {
803806
const voiceDropdownIds = [
804807
"voice-select",

0 commit comments

Comments
 (0)