depot git
69
arduino.ino/arduino/arduino.ino
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#include <Arduino_HS300x.h>
|
||||||
|
#include <Arduino_APDS9960.h>
|
||||||
|
#include <HCSR04.h>
|
||||||
|
#include <PDM.h>
|
||||||
|
|
||||||
|
// #define SAMPLE_BUFFER_SIZE 512
|
||||||
|
// short sampleBuffer[SAMPLE_BUFFER_SIZE];
|
||||||
|
// volatile int samplesRead = 0;
|
||||||
|
// static const char channels = 1;
|
||||||
|
// static const int frequency = 16000;
|
||||||
|
|
||||||
|
// Ultrasonic instructions
|
||||||
|
byte triggerPin = 11;
|
||||||
|
byte echoPin = 12;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
while (!Serial);
|
||||||
|
|
||||||
|
if (!HS300x.begin()) {
|
||||||
|
Serial.println("Failed to initialize humidity temperature sensor!");
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
// if (!PDM.begin(channels, frequency)) {
|
||||||
|
// Serial.println("Failed to start PDM!");
|
||||||
|
// while (1);
|
||||||
|
// }
|
||||||
|
// PDM.onReceive(onPDMdata);
|
||||||
|
HCSR04.begin(triggerPin, echoPin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
// int volume = getVolume();
|
||||||
|
float temperature = HS300x.readTemperature();
|
||||||
|
Serial.print("Heat: ");
|
||||||
|
Serial.println(temperature);
|
||||||
|
|
||||||
|
double* distances = HCSR04.measureDistanceCm();
|
||||||
|
Serial.print("Distance: ");
|
||||||
|
Serial.println(distances[0]);
|
||||||
|
// Serial.print(volume);
|
||||||
|
delay(2500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// int getVolume()
|
||||||
|
// {
|
||||||
|
// int volume = 0;
|
||||||
|
// int sum = 0;
|
||||||
|
|
||||||
|
// Serial.print("non");
|
||||||
|
// if (samplesRead) {
|
||||||
|
// Serial.print("yes");
|
||||||
|
// for (int i = 0; i < samplesRead; i++) {
|
||||||
|
// sum += abs(sampleBuffer[i]);
|
||||||
|
// }
|
||||||
|
// volume = sum / samplesRead;
|
||||||
|
// samplesRead = 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return (volume);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void onPDMdata()
|
||||||
|
// {
|
||||||
|
// int bytesAvailable = PDM.available();
|
||||||
|
// PDM.read(sampleBuffer, bytesAvailable);
|
||||||
|
// samplesRead = bytesAvailable / 2;
|
||||||
|
// }
|
||||||
BIN
assets/barre/barre1.PNG
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/barre/barre2.PNG
Normal file
|
After Width: | Height: | Size: 784 B |
BIN
assets/barre/barre3.PNG
Normal file
|
After Width: | Height: | Size: 882 B |
BIN
assets/barre/barre4.PNG
Normal file
|
After Width: | Height: | Size: 773 B |
BIN
assets/barre/barre5.PNG
Normal file
|
After Width: | Height: | Size: 774 B |
BIN
assets/barre/barre6.PNG
Normal file
|
After Width: | Height: | Size: 881 B |
BIN
assets/barre/barre7.PNG
Normal file
|
After Width: | Height: | Size: 871 B |
BIN
assets/barre/barre8.PNG
Normal file
|
After Width: | Height: | Size: 878 B |
BIN
assets/barre/barre9.PNG
Normal file
|
After Width: | Height: | Size: 877 B |
BIN
assets/barre/barreMax1.PNG
Normal file
|
After Width: | Height: | Size: 770 B |
BIN
assets/barre/barreMax2.PNG
Normal file
|
After Width: | Height: | Size: 843 B |
9
assets/cybergirl.mtl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# picocad material
|
||||||
|
newmtl cybergirl_mtl
|
||||||
|
ka 1.000000 1.000000 1.000000
|
||||||
|
kd 1.000000 1.000000 1.000000
|
||||||
|
ks 0.000000 0.000000 0.000000
|
||||||
|
tr 1.000000
|
||||||
|
illum 1
|
||||||
|
ns 0.000000
|
||||||
|
map_kd cybergirl_tex.png
|
||||||
1115
assets/cybergirl.obj
Normal file
BIN
assets/cybergirl_3.gif
Normal file
|
After Width: | Height: | Size: 764 KiB |
BIN
assets/cybergirl_anim/((1.PNG
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
assets/cybergirl_anim/((2.PNG
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
assets/cybergirl_anim/((3.PNG
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
assets/cybergirl_anim/^^1.PNG
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
assets/cybergirl_anim/^^2.PNG
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
assets/cybergirl_anim/^^3.PNG
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
assets/cybergirl_anim/bombe1.PNG
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
assets/cybergirl_anim/bombe2.PNG
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
assets/cybergirl_anim/bombe3.PNG
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
assets/cybergirl_anim/etoile1.PNG
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
assets/cybergirl_anim/etoile2.PNG
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
assets/cybergirl_anim/grr1.PNG
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
assets/cybergirl_anim/grr2.PNG
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
assets/cybergirl_anim/grr3.PNG
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
assets/cybergirl_anim/png/((1.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
assets/cybergirl_anim/png/((2.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
assets/cybergirl_anim/png/((3.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
assets/cybergirl_anim/png/^^1.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
assets/cybergirl_anim/png/^^2.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
assets/cybergirl_anim/png/^^3.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
assets/cybergirl_anim/png/bombe1.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
assets/cybergirl_anim/png/bombe2.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
assets/cybergirl_anim/png/bombe3.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
assets/cybergirl_anim/png/etoile1.png
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
assets/cybergirl_anim/png/etoile2.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
assets/cybergirl_anim/png/grr1.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
assets/cybergirl_anim/png/grr2.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
assets/cybergirl_anim/png/grr3.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
assets/cybergirl_anim/png/pute1.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
assets/cybergirl_anim/png/pute2.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
assets/cybergirl_anim/png/xx1.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
assets/cybergirl_anim/png/xx2.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
assets/cybergirl_anim/png/xx3.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
assets/cybergirl_anim/png/xx4.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
assets/cybergirl_anim/png/xx5.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
assets/cybergirl_anim/pute1.PNG
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
assets/cybergirl_anim/pute2.PNG
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
assets/cybergirl_anim/xx1.PNG
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/cybergirl_anim/xx2.PNG
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
assets/cybergirl_anim/xx3.PNG
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
assets/cybergirl_anim/xx4.PNG
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
assets/cybergirl_anim/xx5.PNG
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
assets/cybergirl_tex.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
323
assets/front.js
Normal file
@ -0,0 +1,323 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const socket = io();
|
||||||
|
|
||||||
|
let barreStress = document.getElementById('barreStress')
|
||||||
|
let stress = 0;
|
||||||
|
let maxInterval1;
|
||||||
|
let maxInterval2;
|
||||||
|
|
||||||
|
// ________________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
setInterval(() => {
|
||||||
|
stress+=10;
|
||||||
|
console.log(stress);
|
||||||
|
testBarre();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function teste(){
|
||||||
|
setInterval(() => {
|
||||||
|
stress=0;
|
||||||
|
}, 15000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function animBarreMax() {
|
||||||
|
clearInterval(maxInterval1);
|
||||||
|
clearInterval(maxInterval2);
|
||||||
|
|
||||||
|
maxInterval1 = setInterval(() => {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barreMax1.PNG")';
|
||||||
|
}, 250);
|
||||||
|
|
||||||
|
maxInterval2 = setInterval(() => {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barreMax2.PNG")';
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function stopAnimBarreMax() {
|
||||||
|
clearInterval(maxInterval1);
|
||||||
|
clearInterval(maxInterval2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testBarre() {
|
||||||
|
if (stress < 100) {
|
||||||
|
stopAnimBarreMax();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stress <= 10) {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barre1.PNG")';
|
||||||
|
} else if (stress <= 20) {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barre2.PNG")';
|
||||||
|
} else if (stress <= 30) {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barre3.PNG")';
|
||||||
|
} else if (stress <= 40) {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barre4.PNG")';
|
||||||
|
} else if (stress <= 50) {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barre5.PNG")';
|
||||||
|
} else if (stress <= 60) {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barre6.PNG")';
|
||||||
|
} else if (stress <= 70) {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barre7.PNG")';
|
||||||
|
} else if (stress <= 80) {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barre8.PNG")';
|
||||||
|
} else if (stress <= 90) {
|
||||||
|
barreStress.style.backgroundImage = 'url("barre/barre9.PNG")';
|
||||||
|
} else if (stress >= 100) {
|
||||||
|
animBarreMax();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ________________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
function addNoise() {
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
const imageData = ctx.createImageData(canvas.width, canvas.height);
|
||||||
|
const data = imageData.data;
|
||||||
|
|
||||||
|
for (let i = 0; i < data.length; i += 4) {
|
||||||
|
const value = Math.random() * 255;
|
||||||
|
data[i] = data[i + 1] = data[i + 2] = value;
|
||||||
|
data[i + 3] = 255; // alpha
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.putImageData(imageData, 0, 0);
|
||||||
|
document.body.style.backgroundImage = `url(${canvas.toDataURL()})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ________________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
function lireTexte() {
|
||||||
|
// Récupérer le texte à lire depuis l'élément HTML avec l'ID 'texte'
|
||||||
|
const Texte = document.getElementById('texte');
|
||||||
|
const texteToSpeak = Texte ? Texte.innerText : "Texte par défaut";
|
||||||
|
|
||||||
|
// Appeler l'API backend pour lire le texte
|
||||||
|
fetch(`/speak?text=${encodeURIComponent(texteToSpeak)}`)
|
||||||
|
.then(reponse => {
|
||||||
|
if (!reponse.ok) {
|
||||||
|
throw new Error('Erreur réseau lors de l\'appel de l\'API');
|
||||||
|
}
|
||||||
|
return reponse.text();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
console.log(data); // Affiche la réponse du serveur
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Erreur :', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ________________________________________________________________________________________
|
||||||
|
|
||||||
|
let envoyerQuestion = document.getElementById("envoyerQuestion");
|
||||||
|
|
||||||
|
|
||||||
|
function doubleRandomWord(question) {
|
||||||
|
let words = question.split(' ');
|
||||||
|
if (words.length === 0) return question;
|
||||||
|
|
||||||
|
let randomIndex = Math.floor(Math.random() * words.length);
|
||||||
|
words.splice(randomIndex, 0, words[randomIndex]);
|
||||||
|
|
||||||
|
return words.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addInsulte(question) {
|
||||||
|
let listeInsulte = [
|
||||||
|
'PUTE',
|
||||||
|
'BITE',
|
||||||
|
'CON',
|
||||||
|
'CONNARD',
|
||||||
|
'SALOPE',
|
||||||
|
'MERDE',
|
||||||
|
'PUTAIN'
|
||||||
|
];
|
||||||
|
let Insulte = listeInsulte[Math.floor(Math.random() * listeInsulte.length)];
|
||||||
|
|
||||||
|
let words = question.split(' ');
|
||||||
|
let randomIndex = Math.floor(Math.random() * (words.length + 1));
|
||||||
|
words.splice(randomIndex, 0, Insulte);
|
||||||
|
|
||||||
|
return words.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
function submitQuestion (){
|
||||||
|
let question = document.getElementById('questionInput').value;
|
||||||
|
if (question.trim() !== '') {
|
||||||
|
|
||||||
|
// Modifier la question
|
||||||
|
// question = doubleRandomWord(question);
|
||||||
|
// question = addInsulte(question);
|
||||||
|
|
||||||
|
// Envoyer la question au serveur via socket.io ou une requête HTTP
|
||||||
|
socket.emit('question', question);
|
||||||
|
|
||||||
|
// Afficher la question dans le conteneur de réponses
|
||||||
|
const reponseContainer = document.getElementById('reponseContainer');
|
||||||
|
const questionElement = document.createElement('div');
|
||||||
|
questionElement.textContent = `Question: ${question}`;
|
||||||
|
reponseContainer.appendChild(questionElement);
|
||||||
|
|
||||||
|
// Vider le champ de saisie
|
||||||
|
document.getElementById('questionInput').value = '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ________________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
// // Créez une scène, une caméra et un rendu
|
||||||
|
// const scene = new THREE.Scene();
|
||||||
|
// const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||||
|
// const renderer = new THREE.WebGLRenderer();
|
||||||
|
// renderer.setSize(window.innerWidth, window.innerHeight);
|
||||||
|
// document.body.appendChild(renderer.domElement);
|
||||||
|
|
||||||
|
// // Ajoutez des lumières
|
||||||
|
// const light = new THREE.HemisphereLight(0xffffbb, 0x080820, 1);
|
||||||
|
// scene.add(light);
|
||||||
|
|
||||||
|
// // Chargez le modèle .obj
|
||||||
|
// const objLoader = new THREE.OBJLoader();
|
||||||
|
// objLoader.load(
|
||||||
|
// 'cybergirl.obj', // Remplacez par le chemin de votre fichier .obj
|
||||||
|
// (object) => {
|
||||||
|
// scene.add(object);
|
||||||
|
// object.position.set(0, 0, 0); // Ajustez la position si nécessaire
|
||||||
|
// },
|
||||||
|
// (xhr) => {
|
||||||
|
// console.log((xhr.loaded / xhr.total * 100) + '% loaded');
|
||||||
|
// },
|
||||||
|
// (error) => {
|
||||||
|
// console.error('Une erreur est survenue lors du chargement du modèle:', error);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
|
// const mtlLoader = new THREE.MTLLoader();
|
||||||
|
// mtlLoader.load('cybergirl.mtl', (materials) => {
|
||||||
|
// materials.preload();
|
||||||
|
|
||||||
|
// const objLoader = new THREE.OBJLoader();
|
||||||
|
// objLoader.setMaterials(materials);
|
||||||
|
// objLoader.load('cybergirl.obj',(object) => {
|
||||||
|
// scene.add(object);
|
||||||
|
// object.position.set(0, 0, 0); // Ajustez la position si nécessaire
|
||||||
|
// },
|
||||||
|
// (xhr) => {
|
||||||
|
// console.log((xhr.loaded / xhr.total * 100) + '% loaded');
|
||||||
|
// },
|
||||||
|
// (error) => {
|
||||||
|
// console.error('Une erreur est survenue lors du chargement du modèle:', error);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
// // Positionnez la caméra
|
||||||
|
// camera.position.z = 5;
|
||||||
|
|
||||||
|
|
||||||
|
// // Fonction de rendu
|
||||||
|
// function animate() {
|
||||||
|
// requestAnimationFrame(animate);
|
||||||
|
// renderer.render(scene, camera);
|
||||||
|
// }
|
||||||
|
// animate();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ________________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
let intervalEcoute;
|
||||||
|
let intervalEcoute1;
|
||||||
|
let intervalEcoute2;
|
||||||
|
|
||||||
|
let tete = document.getElementById('tete');
|
||||||
|
let tetegif =document.getElementById('teteGif')
|
||||||
|
let parle = -1;
|
||||||
|
|
||||||
|
function animAttente() {
|
||||||
|
tete.style.display='none';
|
||||||
|
tetegif.style.display='block';
|
||||||
|
}
|
||||||
|
|
||||||
|
function Ecoute() {
|
||||||
|
tete.style.display='block';
|
||||||
|
tetegif.style.display='none';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function animEcoute() {
|
||||||
|
tete.style.display='block';
|
||||||
|
tetegif.style.display='none';
|
||||||
|
clearInterval(intervalEcoute1);
|
||||||
|
clearInterval(intervalEcoute2);
|
||||||
|
|
||||||
|
intervalEcoute = setInterval(() => {
|
||||||
|
if (parle <= 0) {
|
||||||
|
|
||||||
|
intervalEcoute1 = setInterval(() => {
|
||||||
|
clearInterval(intervalEcoute1);
|
||||||
|
tete.style.backgroundImage='url("cybergirl_anim/png/^^1.png")';
|
||||||
|
console.log('1');
|
||||||
|
|
||||||
|
intervalEcoute2 = setInterval(() => {
|
||||||
|
clearInterval(intervalEcoute2);
|
||||||
|
tete.style.backgroundImage='url("cybergirl_anim/png/^^2.png")';
|
||||||
|
console.log('2');
|
||||||
|
|
||||||
|
}, 1000);
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
console.log('stop');
|
||||||
|
clearInterval(intervalEcoute);
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function animParle() {
|
||||||
|
parle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function animInsulte() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ________________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
envoyerQuestion.addEventListener("click",submitQuestion);
|
||||||
|
document.addEventListener("keydown", function(event) {
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
submitQuestion();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
barreStress.addEventListener("click", lireTexte);
|
||||||
|
questionInput.addEventListener("click",animEcoute);
|
||||||
|
addNoise();
|
||||||
|
teste();
|
||||||
|
test();
|
||||||
|
|
||||||
|
|
||||||
BIN
assets/micropuce_0.gif
Normal file
|
After Width: | Height: | Size: 506 KiB |
BIN
assets/micropuce_1.gif
Normal file
|
After Width: | Height: | Size: 481 KiB |
BIN
assets/micropuce_2.gif
Normal file
|
After Width: | Height: | Size: 553 KiB |
7
assets/socket.io.min.js
vendored
Normal file
87
assets/style.css
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
|
||||||
|
|
||||||
|
@keyframes flicker {
|
||||||
|
0%, 100% { opacity: 1; }
|
||||||
|
50% { opacity: 0.9; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
body{
|
||||||
|
margin: 0;
|
||||||
|
border: 0;
|
||||||
|
background-color: #1d2b53;
|
||||||
|
/* filter: sepia(0.5) grayscale(0.3) contrast(1.2); */
|
||||||
|
animation: flicker 0.15s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
#fond{
|
||||||
|
position: fixed;
|
||||||
|
background-color: #1d2b53;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin-left: 0;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#teteGif{
|
||||||
|
position: fixed;
|
||||||
|
margin-left: 22.5%;
|
||||||
|
margin-top: -5%;
|
||||||
|
width: 55%;
|
||||||
|
height: 105%;
|
||||||
|
background-image: url("cybergirl_3.gif");
|
||||||
|
background-size: 98%;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#tete{
|
||||||
|
position: fixed;
|
||||||
|
border: 0;
|
||||||
|
display: none;
|
||||||
|
margin-left: 22.5%;
|
||||||
|
margin-top: -5%;
|
||||||
|
width: 55%;
|
||||||
|
height: 105%;
|
||||||
|
background-size: 110%;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#barreStress{
|
||||||
|
position: fixed;
|
||||||
|
margin-top: 2%;
|
||||||
|
margin-left: 2%;
|
||||||
|
width: 300px;
|
||||||
|
height: 85px;
|
||||||
|
background-image: url("barre/barre1.PNG");
|
||||||
|
background-size: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#questionInput{
|
||||||
|
/* background-color: #FF77A8; */
|
||||||
|
position: fixed;
|
||||||
|
width: 50%;
|
||||||
|
bottom: 10%;
|
||||||
|
margin-left: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#envoyerQuestion{
|
||||||
|
background-color: #7E2553;
|
||||||
|
position: fixed;
|
||||||
|
width: 10%;
|
||||||
|
bottom: 5%;
|
||||||
|
margin-left: 45%;
|
||||||
|
border-radius: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#reponseContainer{
|
||||||
|
position: fixed;
|
||||||
|
width: 10%;
|
||||||
|
height: 100%;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
21
client.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import socket
|
||||||
|
|
||||||
|
ip = '127.0.0.1'
|
||||||
|
port = 5000
|
||||||
|
|
||||||
|
def start_client():
|
||||||
|
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
client_socket.connect((ip, port))
|
||||||
|
|
||||||
|
while True:
|
||||||
|
message = input("Entrez un message pour le serveur: ")
|
||||||
|
|
||||||
|
client_socket.send(message.encode())
|
||||||
|
response = client_socket.recv(1024).decode()
|
||||||
|
if (response.lower() == "exit"):
|
||||||
|
break
|
||||||
|
print(response)
|
||||||
|
|
||||||
|
client_socket.close()
|
||||||
|
|
||||||
|
start_client()
|
||||||
1476
package-lock.json
generated
Normal file
24
package.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "express",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"author": "",
|
||||||
|
"type": "commonjs",
|
||||||
|
"main": "server.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"start": "node server.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.21.2",
|
||||||
|
"pug": "^3.0.3",
|
||||||
|
"socket.io": "^4.8.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitea.esadhar.fr/emile.robinot/hackaton2025.git"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
86
server.js
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
const { io: Client } = require("socket.io-client");
|
||||||
|
|
||||||
|
const express = require('express');
|
||||||
|
// const { createServer } = require('node:http');
|
||||||
|
// const { http } = require('node:http');
|
||||||
|
const http = require('node:http');
|
||||||
|
const { Server } = require('socket.io');
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const server = http.createServer(app);
|
||||||
|
const io = new Server(server);
|
||||||
|
|
||||||
|
|
||||||
|
const port = 3000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
app.set('view engine', 'pug')
|
||||||
|
app.use(express.static('assets'))
|
||||||
|
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
// res.send('Hello World!')
|
||||||
|
res.render('index', { title: 'SGT', message: 'bonjour, je suis lucie et j`ai le syndorme de PUTe de la tourette!' })
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// app.get('/speak', (req, res) => {
|
||||||
|
// const text = req.query.text || message;
|
||||||
|
// const command = `espeak "${text}"`;
|
||||||
|
|
||||||
|
// exec(command, (error, stdout, stderr) => {
|
||||||
|
// if (error) {
|
||||||
|
// console.error(`Erreur lors de l'exécution de la commande : ${error}`);
|
||||||
|
// return res.status(500).send('Erreur lors de la lecture du texte.');
|
||||||
|
// }
|
||||||
|
// res.send(`Texte lu : ${text}`);
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
io.on('connection', (socket) => {
|
||||||
|
console.log('Un utilisateur s\'est connecté');
|
||||||
|
|
||||||
|
let stress = 0.1;
|
||||||
|
setInterval(() => {
|
||||||
|
stress += 0.1;
|
||||||
|
socket.emit('stress', stress);
|
||||||
|
console.log(stress);
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
// Écoute les questions envoyées par le client
|
||||||
|
socket.on('question', (question) => {
|
||||||
|
console.log(`Question reçue: ${question}`);
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
host: 'localhost',
|
||||||
|
port: 5000,
|
||||||
|
path: '/',
|
||||||
|
};
|
||||||
|
|
||||||
|
// Sending the request
|
||||||
|
const req = http.request(options, (res) => {
|
||||||
|
let data = ''
|
||||||
|
|
||||||
|
res.on('data', (chunk) => {
|
||||||
|
data += chunk;
|
||||||
|
console.log('on data', data);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ending the response
|
||||||
|
res.on('end', () => {
|
||||||
|
console.log('Body:', JSON.parse(data))
|
||||||
|
});
|
||||||
|
|
||||||
|
}).on("error", (err) => {
|
||||||
|
console.log("Error: ", err)
|
||||||
|
}).end()
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
server.listen(port, () => {
|
||||||
|
console.log(`Example app listening on port ${port}`)
|
||||||
|
})
|
||||||
|
|
||||||
71
serveur.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import socket
|
||||||
|
import ollama
|
||||||
|
import serial
|
||||||
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
|
ip = '127.0.0.1'
|
||||||
|
port = 5000
|
||||||
|
|
||||||
|
usbPort = '/dev/ttyACM0'
|
||||||
|
baud_rate = 9600
|
||||||
|
stopFlag = False
|
||||||
|
|
||||||
|
instruction = "Ne fait pas de long paragraphe répond simplement"
|
||||||
|
|
||||||
|
def send_message(client_socket, message):
|
||||||
|
client_socket.send(message.encode())
|
||||||
|
|
||||||
|
def connect_arduino():
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
ser = serial.Serial(usbPort, baud_rate)
|
||||||
|
while not ser.isOpen():
|
||||||
|
if (count == 5):
|
||||||
|
count = 0
|
||||||
|
print("Serial port still trying to open...")
|
||||||
|
time.sleep(1)
|
||||||
|
count += 1
|
||||||
|
return (ser)
|
||||||
|
|
||||||
|
def arduino_thread(thread_name, ser):
|
||||||
|
global stopFlag
|
||||||
|
|
||||||
|
while not stopFlag:
|
||||||
|
if ser.in_waiting > 0:
|
||||||
|
data = ser.readline().decode('utf-8').strip()
|
||||||
|
print("Arduino data:", data)
|
||||||
|
|
||||||
|
def start_server():
|
||||||
|
global stopFlag
|
||||||
|
|
||||||
|
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
server_socket.bind((ip, port))
|
||||||
|
server_socket.listen(1)
|
||||||
|
|
||||||
|
print("Server ready!")
|
||||||
|
|
||||||
|
ser = connect_arduino()
|
||||||
|
client_socket, client_address = server_socket.accept()
|
||||||
|
thread1 = threading.Thread(target=arduino_thread, args=("Thread1", ser))
|
||||||
|
thread1.start()
|
||||||
|
while (1):
|
||||||
|
message = client_socket.recv(1024).decode()
|
||||||
|
|
||||||
|
if (message == "exit"):
|
||||||
|
send_message(client_socket, "exit")
|
||||||
|
break
|
||||||
|
message = message + instruction
|
||||||
|
response = ollama.chat(model='mistral', messages=[
|
||||||
|
{
|
||||||
|
'role': 'user',
|
||||||
|
'content': message,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
send_message(client_socket, response['message']['content'])
|
||||||
|
stopFlag = True
|
||||||
|
print("closed server.")
|
||||||
|
thread1.join()
|
||||||
|
client_socket.close()
|
||||||
|
|
||||||
|
start_server()
|
||||||
26
views/index.pug
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
html
|
||||||
|
head
|
||||||
|
title= title
|
||||||
|
link(rel="stylesheet", href="style.css")
|
||||||
|
script(src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js")
|
||||||
|
script(src="https://cdn.rawgit.com/mrdoob/three.js/r128/examples/js/loaders/OBJLoader.js")
|
||||||
|
script(src="https://cdn.rawgit.com/mrdoob/three.js/r128/examples/js/loaders/MTLLoader.js")
|
||||||
|
|
||||||
|
|
||||||
|
body
|
||||||
|
div(id='fond')
|
||||||
|
div(id='tete')
|
||||||
|
div(id='teteGif')
|
||||||
|
div(id='barreStress')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
div
|
||||||
|
textarea(id='questionInput', placeholder='Posez votre question ici...')
|
||||||
|
button(id='envoyerQuestion') Poser la question
|
||||||
|
|
||||||
|
div(id='reponseContainer')
|
||||||
|
|
||||||
|
script(src="socket.io.min.js")
|
||||||
|
script(src="front.js")
|
||||||