XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Fix SpeechRecognition on Phone

cec2a10e
Heiner Lohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +9 -8
Modified g4f/gui/client/static/js/chat.v1.js +9 -8
@@ -1261,22 +1261,22 @@ if (SpeechRecognition) {
1261 1261 recognition.interimResults = true;
1262 1262 recognition.maxAlternatives = 1;
1263 1263
1264 function may_stop() {
1265 if (microLabel.classList.contains("recognition")) {
1266 recognition.stop();
1267 }
1268 }
1269
1270 1264 let startValue;
1265 let shouldStop = false;
1271 1266 let lastDebounceTranscript;
1272 1267 recognition.onstart = function() {
1273 1268 microLabel.classList.add("recognition");
1274 1269 startValue = messageInput.value;
1270 shouldStop = false;
1275 1271 lastDebounceTranscript = "";
1276 1272 };
1277 1273 recognition.onend = function() {
1278 microLabel.classList.remove("recognition");
1279 messageInput.focus();
1274 if (shouldStop) {
1275 microLabel.classList.remove("recognition");
1276 messageInput.focus();
1277 } else {
1278 recognition.start();
1279 }
1280 1280 };
1281 1281 recognition.onresult = function(event) {
1282 1282 if (!event.results) {
@@ -1303,6 +1303,7 @@ if (SpeechRecognition) {
1303 1303
1304 1304 microLabel.addEventListener("click", () => {
1305 1305 if (microLabel.classList.contains("recognition")) {
1306 shouldStop = true;
1306 1307 recognition.stop();
1307 1308 } else {
1308 1309 const lang = document.getElementById("recognition-language")?.value;