This commit is contained in:
Exequiel Aramburu 2024-12-15 19:28:47 -03:00
parent 7ec54a57e2
commit d65a64d9df
6 changed files with 222 additions and 0 deletions

57
CSS/estilo.css Normal file
View File

@ -0,0 +1,57 @@
@font-face {
font-family: "SLA_UY";
font-style: normal;
font-weight: normal;
src: local("?"), url("../FONT/Lsu.ttf") format("truetype");
}
@font-face {
font-family: "SLA_AR";
font-style: normal;
font-weight: normal;
src: local("?"), url("../FONT/Lsa.ttf") format("truetype");
}
/* CSS comes here */
body {
font-family: arial;
background-image: url("../IMG/fondo.jpg");
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
background-size: cover;
}
.pids-wrapper{
width: 100%;
}
.pid{
width: calc(5% - 10px);
height: 5px;
display: inline-block;
margin: 3px;
}
.hide {
display:none;
}
.show {
display:block;
}
.TEXTO_TRA {
font-family: arial;
font-size: 30px!important;
}
.SLA_UY {
font-family: SLA_UY;
font-size: 50px!important;
text-transform: lowercase;
}
.SLA_AR {
font-family: SLA_AR;
font-size: 50px!important;
text-transform: lowercase;
}

BIN
FONT/Lsa.ttf Normal file

Binary file not shown.

BIN
FONT/Lsu.ttf Normal file

Binary file not shown.

1
JS/notify.min.js vendored Normal file

File diff suppressed because one or more lines are too long

164
JS/recognition.js Normal file
View File

@ -0,0 +1,164 @@
// LIBRERIA PARA ESCUCHAR Y TRANSCRIBIR
function isMobile(){
return (
(navigator.userAgent.match(/Android/i)) ||
(navigator.userAgent.match(/webOS/i)) ||
(navigator.userAgent.match(/iPhone/i)) ||
(navigator.userAgent.match(/iPod/i)) ||
(navigator.userAgent.match(/iPad/i)) ||
(navigator.userAgent.match(/BlackBerry/i))
);
}
var recognition;
var output = document.getElementById("output");
var outputsenasAR = document.getElementById("outputsenasAR");
var outputsenasUY = document.getElementById("outputsenasUY");
var outputHistoria = document.getElementById("outputHistoria");
const removeAcentos = (str) => { return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); }
function cambiarSenasAR() { $("#outputHistoria").attr('class', 'form-control SLA_AR');}
function cambiarSenasUY() { $("#outputHistoria").attr('class', 'form-control SLA_UY');}
function cambiarTexto() {$("#outputHistoria").attr('class', 'form-control TEXTO_TRA');}
function stopSpeechRecognition() {
$.notify("DETENIDO.", "warn");
$('#boff').prop('disabled', true);
$('#bon').prop('disabled', false);
$('#mic').attr('src','IMG/mic_off.png');
recognition.stop();
}
function insertarSimbolo(simbolo)
{
if(simbolo== "NEW_LINE"){simbolo = String.fromCharCode(13, 10);}
if(simbolo== "NEW_LINE2"){simbolo = String.fromCharCode(13, 10)+String.fromCharCode(13, 10);}
output.innerHTML += simbolo;
outputsenasAR.innerHTML += simbolo;
outputsenasUY.innerHTML += simbolo;
outputHistoria.innerHTML += simbolo
}
function runSpeechRecognition(parametro = true)
{
$('#boff').prop('disabled', false);
$('#bon').prop('disabled', true);
$('#mic').attr('src','IMG/mic_on.png');
// get output div reference
var output = document.getElementById("output");
// new speech recognition object
var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;
var SpeechGrammarList = SpeechGrammarList || webkitSpeechGrammarList
var SpeechRecognitionEvent = SpeechRecognitionEvent || webkitSpeechRecognitionEvent
recognition = new SpeechRecognition();
// This runs when the speech recognition service starts
if ( isMobile() )
{
recognition.continuous = false;
}else{
recognition.continuous = true;
}
recognition.lang = 'es-ES';
recognition.interimResults = true;
recognition.maxAlternatives = 100;
recognition.onstart = function(){
if(parametro == true) $.notify("Escuchando..", "info");
};
recognition.onspeechend = function(){
if (parametro == true) $.notify("Sin sonido..", "info");
setTimeout('runSpeechRecognition(false)',1000);
}
recognition.onerror = function(event) {
$.notify(event.error, "warn");
}
recognition.onresult = function(event){
var interim_transcript = '';
var final_transcript = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
// Verify if the recognized text is the last with the isFinal property
if (event.results[i].isFinal) {
final_transcript += event.results[i][0].transcript;
} else {
interim_transcript += event.results[i][0].transcript;
}
}
var transcript = interim_transcript;
var newline = String.fromCharCode(13, 10);
transcript = transcript.replaceAll("punto y coma", ";").replaceAll("dos puntos", ":").replaceAll('punto','.').replaceAll("coma", ",").replaceAll("signo de exclamación", "!").replaceAll("signo de interrogación", "?").replaceAll("guión", "-").replaceAll("nueva línea", newline).replaceAll("abrir paréntesis", "(").replaceAll("cerrar paréntesis", ")").replaceAll("cara sonriente", ":-)").replaceAll("cara triste", ":-(").replaceAll("nuevo apartado", newline+newline);
output.innerHTML = removeAcentos(transcript);
outputsenasAR.innerHTML = removeAcentos(transcript);
outputsenasUY.innerHTML = removeAcentos(transcript);
final_transcript = final_transcript.replaceAll("punto y coma", ";").replaceAll("dos puntos", ":").replaceAll('punto','.').replaceAll("coma", ",").replaceAll("signo de exclamación", "!").replaceAll("signo de interrogación", "?").replaceAll("guión", "-").replaceAll("nueva línea", newline).replaceAll("abrir paréntesis", "(").replaceAll("cerrar paréntesis", ")").replaceAll("cara sonriente", ":-)").replaceAll("cara triste", ":-(").replaceAll("nuevo apartado", newline+newline);
outputHistoria.innerHTML += removeAcentos(final_transcript);
};
// start recognition
recognition.start();
}
// PARA DIBUJAR LA INTESIDAD DEL MICROFONO
function colorPids(vol) {
let all_pids = $('.pid');
let amout_of_pids = Math.round(vol/4);
let elem_range = all_pids.slice(0, amout_of_pids);
for (var i = 0; i < all_pids.length; i++) {
all_pids[i].style.backgroundColor="#e6e7e8";
}
for (var i = 0; i < elem_range.length; i++) {
elem_range[i].style.backgroundColor="#69ce2b";
}
var estado = $('#bon').prop('disabled');
if(amout_of_pids>8 && estado == false) {
var testData = !!document.getElementsByClassName("data-notify-text");
$("#barra").notify("Notamos que estas hablando, pero te falta realizar click en Comenzar.", "info");
}
}
navigator.mediaDevices.getUserMedia({ audio: true})
.then(function(stream) {
$('#mic').attr('src','IMG/mic_on.png');
audioContext = new AudioContext();
analyser = audioContext.createAnalyser();
microphone = audioContext.createMediaStreamSource(stream);
javascriptNode = audioContext.createScriptProcessor(2048, 1, 1);
analyser.smoothingTimeConstant = 0.8;
analyser.fftSize = 1024;
microphone.connect(analyser);
analyser.connect(javascriptNode);
javascriptNode.connect(audioContext.destination);
javascriptNode.onaudioprocess = function() {
var array = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteFrequencyData(array);
var values = 0;
var length = array.length;
for (var i = 0; i < length; i++) {
values += (array[i]);
}
var average = values / length;
colorPids(average);
}
})
.catch(function(err) {
});

BIN
MANUAL/manual.pdf Normal file

Binary file not shown.