added speech functions
This commit is contained in:
parent
f89dbd0c23
commit
71595cc8de
@ -31,6 +31,6 @@ Content-Length: 51
|
|||||||
< strict-transport-security: max-age=2592000
|
< strict-transport-security: max-age=2592000
|
||||||
< x-powered-by: ASP.NET
|
< x-powered-by: ASP.NET
|
||||||
< x-content-type-options: nosniff
|
< x-content-type-options: nosniff
|
||||||
< date: Sat, 06 Sep 2025 10:24:00 GMT
|
< date: Sat, 06 Sep 2025 15:56:46 GMT
|
||||||
<
|
<
|
||||||
* Connection #0 to host 93.43.5.102 left intact
|
* Connection #0 to host 93.43.5.102 left intact
|
||||||
|
|||||||
@ -15,11 +15,11 @@
|
|||||||
* [HTTP/2] [1] [:scheme: https]
|
* [HTTP/2] [1] [:scheme: https]
|
||||||
* [HTTP/2] [1] [:authority: 93.43.5.102]
|
* [HTTP/2] [1] [:authority: 93.43.5.102]
|
||||||
* [HTTP/2] [1] [:path: /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues]
|
* [HTTP/2] [1] [:path: /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues]
|
||||||
* [HTTP/2] [1] [authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NzE2MTQ0MCwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.UgVN5wzjtR8MRU2xLDFWRHIAYLJTmxF3x7kWeVU11YU]
|
* [HTTP/2] [1] [authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NzE4MTQwNiwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.Mc-XEaxejCd2zrrcYVPwD9YuDk-P4t8vFNEdcLDpKMk]
|
||||||
* [HTTP/2] [1] [accept: application/json]
|
* [HTTP/2] [1] [accept: application/json]
|
||||||
> GET /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues HTTP/2
|
> GET /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues HTTP/2
|
||||||
Host: 93.43.5.102
|
Host: 93.43.5.102
|
||||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ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: application/json
|
||||||
|
|
||||||
< HTTP/2 200
|
< HTTP/2 200
|
||||||
@ -30,6 +30,6 @@ Accept: application/json
|
|||||||
< odata-version: 4.0
|
< odata-version: 4.0
|
||||||
< x-powered-by: ASP.NET
|
< x-powered-by: ASP.NET
|
||||||
< x-content-type-options: nosniff
|
< x-content-type-options: nosniff
|
||||||
< date: Sat, 06 Sep 2025 10:24:02 GMT
|
< date: Sat, 06 Sep 2025 15:56:49 GMT
|
||||||
<
|
<
|
||||||
* Connection #0 to host 93.43.5.102 left intact
|
* Connection #0 to host 93.43.5.102 left intact
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
|||||||
<!-- Modal -->
|
<!-- Modal modificato con pulsante per riconoscimento vocale -->
|
||||||
<div class="modal fade" id="partsModal" tabindex="-1" aria-labelledby="partsModalLabel" aria-hidden="true">
|
<div class="modal fade" id="partsModal" tabindex="-1" aria-labelledby="partsModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-xl" style="max-width: 80% !important; width: 80% !important;">
|
<div class="modal-dialog modal-xl" style="max-width: 80% !important; width: 80% !important;">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -15,6 +15,7 @@
|
|||||||
<input type="checkbox" id="showMixParts" name="showMixParts" style="margin-right: 5px;">
|
<input type="checkbox" id="showMixParts" name="showMixParts" style="margin-right: 5px;">
|
||||||
<label for="showMixParts" style="font-size: 0.9rem; margin-right: 10px;">Mix</label>
|
<label for="showMixParts" style="font-size: 0.9rem; margin-right: 10px;">Mix</label>
|
||||||
<button type="button" class="btn btn-info btn-sm" id="renumberPartsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rinumera Parti</button>
|
<button type="button" class="btn btn-info btn-sm" id="renumberPartsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rinumera Parti</button>
|
||||||
|
<button type="button" class="btn btn-secondary btn-sm ms-2" id="toggleVoiceBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;"><i class="fas fa-microphone"></i> Voce</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul id="partsList" class="list-group"></ul>
|
<ul id="partsList" class="list-group"></ul>
|
||||||
|
|||||||
@ -20,6 +20,115 @@ $(document).ready(function () {
|
|||||||
// selection
|
// selection
|
||||||
let selectedPartNumber = null;
|
let selectedPartNumber = null;
|
||||||
|
|
||||||
|
// ===================
|
||||||
|
// VOICE RECOGNITION SETUP
|
||||||
|
// ===================
|
||||||
|
const SpeechRecognition =
|
||||||
|
window.SpeechRecognition || window.webkitSpeechRecognition;
|
||||||
|
let recognition = null;
|
||||||
|
let isVoiceActive = false;
|
||||||
|
const magicWord = "salva"; // Parola magica scelta: "prossima" (fa andare alla riga successiva)
|
||||||
|
|
||||||
|
if (SpeechRecognition) {
|
||||||
|
recognition = new SpeechRecognition();
|
||||||
|
recognition.lang = "it-IT"; // Lingua italiana
|
||||||
|
recognition.continuous = true; // Ascolto continuo
|
||||||
|
recognition.interimResults = false; // Solo risultati finali per semplicità
|
||||||
|
|
||||||
|
recognition.onresult = function (event) {
|
||||||
|
const transcript = event.results[
|
||||||
|
event.results.length - 1
|
||||||
|
][0].transcript
|
||||||
|
.trim()
|
||||||
|
.toLowerCase();
|
||||||
|
console.log("Transcript vocale:", transcript);
|
||||||
|
|
||||||
|
const $currentRow = $("#partsTableBody tr:last"); // Ultima riga corrente
|
||||||
|
const $descriptionInput = $currentRow.find(".part-description");
|
||||||
|
|
||||||
|
if (transcript.includes(magicWord)) {
|
||||||
|
// Rimuovi la parola magica e aggiungi il resto alla descrizione corrente
|
||||||
|
const cleanedTranscript = transcript
|
||||||
|
.replace(magicWord, "")
|
||||||
|
.trim();
|
||||||
|
if (cleanedTranscript) {
|
||||||
|
$descriptionInput.val(
|
||||||
|
(
|
||||||
|
$descriptionInput.val() +
|
||||||
|
" " +
|
||||||
|
cleanedTranscript
|
||||||
|
).trim(),
|
||||||
|
);
|
||||||
|
$descriptionInput.trigger("blur"); // Salva se necessario
|
||||||
|
}
|
||||||
|
// Aggiungi nuova riga (simile a click su +)
|
||||||
|
const maxPartNumber = Math.max(
|
||||||
|
...$("#partsTableBody tr")
|
||||||
|
.map(function () {
|
||||||
|
return (
|
||||||
|
parseInt($(this).find(".part-number").val()) ||
|
||||||
|
0
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.get(),
|
||||||
|
);
|
||||||
|
addNewRow(maxPartNumber + 1);
|
||||||
|
// Focus sulla nuova descrizione
|
||||||
|
const $newRow = $("#partsTableBody tr:last");
|
||||||
|
$newRow.find(".part-description").focus();
|
||||||
|
} else {
|
||||||
|
// Aggiungi il transcript alla descrizione corrente
|
||||||
|
$descriptionInput.val(
|
||||||
|
($descriptionInput.val() + " " + transcript).trim(),
|
||||||
|
);
|
||||||
|
$descriptionInput.trigger("blur"); // Salva se necessario
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
recognition.onerror = function (event) {
|
||||||
|
console.error("Errore riconoscimento vocale:", event.error);
|
||||||
|
if (event.error === "no-speech" || event.error === "aborted") {
|
||||||
|
// Riavvia se necessario
|
||||||
|
if (isVoiceActive) recognition.start();
|
||||||
|
} else {
|
||||||
|
alert("Errore nel riconoscimento vocale: " + event.error);
|
||||||
|
toggleVoiceRecognition();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
recognition.onend = function () {
|
||||||
|
if (isVoiceActive) {
|
||||||
|
recognition.start(); // Riavvia per ascolto continuo
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
console.warn("Riconoscimento vocale non supportato dal browser.");
|
||||||
|
$("#toggleVoiceBtn").hide(); // Nascondi pulsante se non supportato
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleVoiceRecognition() {
|
||||||
|
if (!recognition) return;
|
||||||
|
|
||||||
|
isVoiceActive = !isVoiceActive;
|
||||||
|
const $btn = $("#toggleVoiceBtn");
|
||||||
|
if (isVoiceActive) {
|
||||||
|
$btn.addClass("btn-danger").html(
|
||||||
|
'<i class="fas fa-microphone-slash"></i> Stop Voce',
|
||||||
|
);
|
||||||
|
recognition.start();
|
||||||
|
// Focus iniziale sull'ultima descrizione
|
||||||
|
const $currentRow = $("#partsTableBody tr:last");
|
||||||
|
$currentRow.find(".part-description").focus();
|
||||||
|
} else {
|
||||||
|
$btn.removeClass("btn-danger")
|
||||||
|
.addClass("btn-secondary")
|
||||||
|
.html('<i class="fas fa-microphone"></i> Voce');
|
||||||
|
recognition.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#toggleVoiceBtn").on("click", toggleVoiceRecognition);
|
||||||
|
|
||||||
// ===================
|
// ===================
|
||||||
// POPUP HANDLING
|
// POPUP HANDLING
|
||||||
// ===================
|
// ===================
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user