Spaces:
Running
<!doctype html>
Browse files<html lang="fr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Rosalinda — Espace Codage</title>
<style>
body{margin:0;font-family:system-ui;background:#0b0f16;color:#fff}
.wrap{max-width:980px;margin:0 auto;padding:18px}
.top{display:flex;gap:10px;align-items:center;justify-content:space-between}
.badge{padding:8px 12px;border:1px solid rgba(255,255,255,.12);border-radius:999px;background:rgba(255,255,255,.04)}
.chat{margin-top:14px;border:1px solid rgba(255,255,255,.12);border-radius:16px;overflow:hidden;background:rgba(255,255,255,.03)}
.msgs{height:55vh;overflow:auto;padding:14px;display:flex;flex-direction:column;gap:10px}
.msg{max-width:85%;padding:10px 12px;border-radius:14px;border:1px solid rgba(255,255,255,.10)}
.me{margin-left:auto;background:rgba(93,173,255,.10)}
.ai{background:rgba(255,255,255,.04)}
.row{display:flex;gap:10px;align-items:center;padding:12px;border-top:1px solid rgba(255,255,255,.10)}
input{flex:1;background:transparent;border:1px solid rgba(255,255,255,.12);border-radius:14px;padding:12px;color:#fff;outline:none}
button{border:1px solid rgba(255,255,255,.12);background:rgba(255,255,255,.05);color:#fff;border-radius:14px;padding:10px 12px;cursor:pointer}
button:disabled{opacity:.5;cursor:not-allowed}
.small{color:rgba(255,255,255,.65);font-size:12px;margin-top:10px;line-height:1.4}
</style>
</head>
<body>
<div class="wrap">
<div class="top">
<div class="badge"><b>Rosalinda</b> — Espace Codage</div>
<div class="badge" id="status">Micro: prêt</div>
</div>
<div class="chat">
<div class="msgs" id="msgs"></div>
<div class="row">
<button id="micBtn">🎤</button>
<input id="inp" placeholder="Écris à Rosalinda…" />
<button id="sendBtn">➤</button>
<button id="speakBtn" title="Lire la dernière réponse">🔊</button>
</div>
</div>
<div class="small">
✅ Micro & voix = API du navigateur (Chrome/Edge).<br>
⚠️ Cette version répond avec une “IA locale simple” (règles). Étape suivante : brancher un vrai modèle IA (local ou API).
</div>
</div>
<script>
const msgs = document.getElementById("msgs");
const inp = document.getElementById("inp");
const sendBtn = document.getElementById("sendBtn");
const micBtn = document.getElementById("micBtn");
const speakBtn = document.getElementById("speakBtn");
const statusEl = document.getElementById("status");
let lastAIText = "";
function addMsg(text, who){
const div = document.createElement("div");
div.className = "msg " + (who === "me" ? "me" : "ai");
div.textContent = text;
msgs.appendChild(div);
msgs.scrollTop = msgs.scrollHeight;
}
// IA simple (placeholder) : on remplace ça par un vrai modèle à l'étape suivante
function rosalindaBrain(userText){
const t = userText.toLowerCase();
if (t.includes("bonjour") || t.includes("salut")) return "Bonjour 😄 Je suis Rosalinda. Dis-moi ce que tu veux créer : site, thème, image, vidéo, plugin…";
if (t.includes("theme") || t.includes("thème")) return "Ok ✅ Dis-moi : (1) style (moderne, luxe, minimal, flashy), (2) couleurs, (3) 3 colonnes ou non, (4) Shopify/WooCommerce/autre.";
if (t.includes("image")) return "Je peux préparer une demande d’image. Dis-moi : sujet + style + format (1:1, 16:9, 9:16) + texte à afficher.";
if (t.includes("vidéo") || t.includes("video")) return "Je peux préparer une demande vidéo. Dis-moi : durée, style (réaliste/3D), texte à l’écran, musique oui/non.";
if (t.includes("micro")) return "Pour le micro : clique 🎤, autorise le micro dans ton navigateur, puis parle. Je transcris et je réponds.";
return "Compris ✅ Donne-moi plus de détails (objectif + plateforme + style), et je te génère une réponse claire.";
}
function speak(text){
if (!("speechSynthesis" in window)) {
alert("TTS non supporté sur ce navigateur.");
return;
}
const u = new SpeechSynthesisUtterance(text);
u.lang = "fr-FR";
window.speechSynthesis.cancel();
window.speechSynthesis.speak(u);
}
function handleSend(text){
const v = (text ?? inp.value).trim();
if (!v) return;
addMsg(v, "me");
inp.value = "";
const reply = rosalindaBrain(v);
lastAIText = reply;
addMsg(reply, "ai");
speak(reply); // réponse vocale automatique
}
sendBtn.onclick = () => handleSend();
inp.addEventListener("keydown", (e) => {
if (e.key === "Enter") handleSend();
});
speakBtn.onclick = () => lastAIText && speak(lastAIText);
// Micro (STT)
let rec = null;
let listening = false;
function setupSTT(){
const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
if (!SR) return null;
const r = new SR();
r.lang = "fr-FR";
r.interimResults = true;
r.continuous = false;
return r;
}
rec = setupSTT();
micBtn.onclick = async () => {
if (!rec){
alert("Reconnaissance vocale non disponible ici. Essaie Chrome/Edge.");
return;
}
if (listening) return;
listening = true;
statusEl.textContent = "Micro: écoute…";
let finalText = "";
rec.onresult = (e) => {
let transcript = "";
for (let i = e.resultIndex; i < e.results.length; i++){
transcript += e.results[i][0].transcript;
if (e.results[i].isFinal) finalText += e.results[i][0].transcript + " ";
}
inp.value = (finalText || transcript).trim();
};
rec.onerror = () => {
listening = false;
statusEl.textContent = "Micro: erreur";
};
rec.onend = () => {
listening = false;
statusEl.textContent = "Micro: prêt";
if (inp.value.trim()) handleSend(inp.value);
};
try { rec.start(); } catch (e) {
listening = false;
statusEl.textContent = "Micro: prêt";
}
};
// Message de démarrage
addMsg("Bonjour 👋 Je suis Rosalinda. Clique 🎤 pour parler ou écris-moi.", "ai");
</script>
</body>
</html>
- index.html +7 -1
- rosalinda.html +161 -0
- style.css +37 -1
|
@@ -45,13 +45,19 @@
|
|
| 45 |
</a>
|
| 46 |
|
| 47 |
<h2 class="text-xs uppercase tracking-wider text-gray-500 px-3 py-2 mt-4">Raccourcis</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
<a href="#" class="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-gray-750/50 border border-transparent hover:border-gray-700 text-gray-300 mb-1">
|
| 49 |
<div class="p-2 rounded-lg bg-gray-750 border border-gray-700">
|
| 50 |
<i data-feather="book" class="w-4 h-4"></i>
|
| 51 |
</div>
|
| 52 |
<span class="truncate">Bibliothèque</span>
|
| 53 |
</a>
|
| 54 |
-
|
| 55 |
<div class="p-2 rounded-lg bg-gray-750 border border-gray-700">
|
| 56 |
<i data-feather="settings" class="w-4 h-4"></i>
|
| 57 |
</div>
|
|
|
|
| 45 |
</a>
|
| 46 |
|
| 47 |
<h2 class="text-xs uppercase tracking-wider text-gray-500 px-3 py-2 mt-4">Raccourcis</h2>
|
| 48 |
+
<a href="rosalinda.html" class="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-gray-750/50 border border-transparent hover:border-gray-700 text-gray-300 mb-1">
|
| 49 |
+
<div class="p-2 rounded-lg bg-gray-750 border border-gray-700">
|
| 50 |
+
<i data-feather="message-circle" class="w-4 h-4"></i>
|
| 51 |
+
</div>
|
| 52 |
+
<span class="truncate">Rosalinda IA</span>
|
| 53 |
+
</a>
|
| 54 |
<a href="#" class="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-gray-750/50 border border-transparent hover:border-gray-700 text-gray-300 mb-1">
|
| 55 |
<div class="p-2 rounded-lg bg-gray-750 border border-gray-700">
|
| 56 |
<i data-feather="book" class="w-4 h-4"></i>
|
| 57 |
</div>
|
| 58 |
<span class="truncate">Bibliothèque</span>
|
| 59 |
</a>
|
| 60 |
+
<a href="#" class="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-gray-750/50 border border-transparent hover:border-gray-700 text-gray-300 mb-1">
|
| 61 |
<div class="p-2 rounded-lg bg-gray-750 border border-gray-700">
|
| 62 |
<i data-feather="settings" class="w-4 h-4"></i>
|
| 63 |
</div>
|
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fr">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Rosalinda — Espace Codage</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
<script src="script.js"></script>
|
| 9 |
+
</head>
|
| 10 |
+
<body class="bg-gray-900 text-gray-100">
|
| 11 |
+
<div class="wrap max-w-4xl mx-auto p-4">
|
| 12 |
+
<div class="top flex gap-2 items-center justify-between mb-4">
|
| 13 |
+
<div class="badge px-3 py-2 rounded-full border border-gray-700 bg-gray-800">
|
| 14 |
+
<b>Rosalinda</b> — Espace Codage
|
| 15 |
+
</div>
|
| 16 |
+
<div class="badge px-3 py-2 rounded-full border border-gray-700 bg-gray-800" id="status">
|
| 17 |
+
Micro: prêt
|
| 18 |
+
</div>
|
| 19 |
+
</div>
|
| 20 |
+
|
| 21 |
+
<div class="chat border border-gray-700 rounded-xl overflow-hidden bg-gray-800">
|
| 22 |
+
<div class="msgs h-[60vh] overflow-auto p-4 flex flex-col gap-3" id="msgs"></div>
|
| 23 |
+
<div class="row flex gap-2 items-center p-3 border-t border-gray-700">
|
| 24 |
+
<button id="micBtn" class="p-2 rounded-lg bg-gray-750 hover:bg-gray-700 border border-gray-700">
|
| 25 |
+
<i data-feather="mic" class="w-5 h-5"></i>
|
| 26 |
+
</button>
|
| 27 |
+
<input id="inp" placeholder="Écris à Rosalinda…"
|
| 28 |
+
class="flex-1 bg-gray-750 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500">
|
| 29 |
+
<button id="sendBtn" class="p-2 rounded-lg bg-blue-600 hover:bg-blue-500 text-white">
|
| 30 |
+
<i data-feather="send" class="w-5 h-5"></i>
|
| 31 |
+
</button>
|
| 32 |
+
<button id="speakBtn" title="Lire la dernière réponse"
|
| 33 |
+
class="p-2 rounded-lg bg-gray-750 hover:bg-gray-700 border border-gray-700">
|
| 34 |
+
<i data-feather="volume-2" class="w-5 h-5"></i>
|
| 35 |
+
</button>
|
| 36 |
+
</div>
|
| 37 |
+
</div>
|
| 38 |
+
|
| 39 |
+
<div class="small text-gray-400 text-sm mt-4 leading-relaxed">
|
| 40 |
+
✅ Micro & voix = API du navigateur (Chrome/Edge).<br>
|
| 41 |
+
⚠️ Cette version répond avec une "IA locale simple" (règles). Étape suivante: brancher un vrai modèle IA (local ou API).
|
| 42 |
+
</div>
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<script>
|
| 46 |
+
feather.replace();
|
| 47 |
+
|
| 48 |
+
const msgs = document.getElementById("msgs");
|
| 49 |
+
const inp = document.getElementById("inp");
|
| 50 |
+
const sendBtn = document.getElementById("sendBtn");
|
| 51 |
+
const micBtn = document.getElementById("micBtn");
|
| 52 |
+
const speakBtn = document.getElementById("speakBtn");
|
| 53 |
+
const statusEl = document.getElementById("status");
|
| 54 |
+
|
| 55 |
+
let lastAIText = "";
|
| 56 |
+
|
| 57 |
+
function addMsg(text, who){
|
| 58 |
+
const div = document.createElement("div");
|
| 59 |
+
div.className = `msg max-w-[85%] p-3 rounded-xl border ${who === "me" ?
|
| 60 |
+
"ml-auto bg-blue-900/10 border-blue-800/50" :
|
| 61 |
+
"bg-gray-700/50 border-gray-700"}`;
|
| 62 |
+
div.textContent = text;
|
| 63 |
+
msgs.appendChild(div);
|
| 64 |
+
msgs.scrollTop = msgs.scrollHeight;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
function rosalindaBrain(userText){
|
| 68 |
+
const t = userText.toLowerCase();
|
| 69 |
+
if (t.includes("bonjour") || t.includes("salut")) return "Bonjour 😄 Je suis Rosalinda. Dis-moi ce que tu veux créer : site, thème, image, vidéo, plugin…";
|
| 70 |
+
if (t.includes("theme") || t.includes("thème")) return "Ok ✅ Dis-moi : (1) style (moderne, luxe, minimal, flashy), (2) couleurs, (3) 3 colonnes ou non, (4) Shopify/WooCommerce/autre.";
|
| 71 |
+
if (t.includes("image")) return "Je peux préparer une demande d'image. Dis-moi : sujet + style + format (1:1, 16:9, 9:16) + texte à afficher.";
|
| 72 |
+
if (t.includes("vidéo") || t.includes("video")) return "Je peux préparer une demande vidéo. Dis-moi : durée, style (réaliste/3D), texte à l'écran, musique oui/non.";
|
| 73 |
+
if (t.includes("micro")) return "Pour le micro : clique 🎤, autorise le micro dans ton navigateur, puis parle. Je transcris et je réponds.";
|
| 74 |
+
return "Compris ✅ Donne-moi plus de détails (objectif + plateforme + style), et je te génère une réponse claire.";
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
function speak(text){
|
| 78 |
+
if (!("speechSynthesis" in window)) {
|
| 79 |
+
alert("TTS non supporté sur ce navigateur.");
|
| 80 |
+
return;
|
| 81 |
+
}
|
| 82 |
+
const u = new SpeechSynthesisUtterance(text);
|
| 83 |
+
u.lang = "fr-FR";
|
| 84 |
+
window.speechSynthesis.cancel();
|
| 85 |
+
window.speechSynthesis.speak(u);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function handleSend(text){
|
| 89 |
+
const v = (text ?? inp.value).trim();
|
| 90 |
+
if (!v) return;
|
| 91 |
+
addMsg(v, "me");
|
| 92 |
+
inp.value = "";
|
| 93 |
+
const reply = rosalindaBrain(v);
|
| 94 |
+
lastAIText = reply;
|
| 95 |
+
addMsg(reply, "ai");
|
| 96 |
+
speak(reply);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
sendBtn.onclick = () => handleSend();
|
| 100 |
+
inp.addEventListener("keydown", (e) => {
|
| 101 |
+
if (e.key === "Enter") handleSend();
|
| 102 |
+
});
|
| 103 |
+
|
| 104 |
+
speakBtn.onclick = () => lastAIText && speak(lastAIText);
|
| 105 |
+
|
| 106 |
+
let rec = null;
|
| 107 |
+
let listening = false;
|
| 108 |
+
|
| 109 |
+
function setupSTT(){
|
| 110 |
+
const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
|
| 111 |
+
if (!SR) return null;
|
| 112 |
+
const r = new SR();
|
| 113 |
+
r.lang = "fr-FR";
|
| 114 |
+
r.interimResults = true;
|
| 115 |
+
r.continuous = false;
|
| 116 |
+
return r;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
rec = setupSTT();
|
| 120 |
+
|
| 121 |
+
micBtn.onclick = async () => {
|
| 122 |
+
if (!rec){
|
| 123 |
+
alert("Reconnaissance vocale non disponible ici. Essaie Chrome/Edge.");
|
| 124 |
+
return;
|
| 125 |
+
}
|
| 126 |
+
if (listening) return;
|
| 127 |
+
|
| 128 |
+
listening = true;
|
| 129 |
+
statusEl.textContent = "Micro: écoute…";
|
| 130 |
+
let finalText = "";
|
| 131 |
+
|
| 132 |
+
rec.onresult = (e) => {
|
| 133 |
+
let transcript = "";
|
| 134 |
+
for (let i = e.resultIndex; i < e.results.length; i++){
|
| 135 |
+
transcript += e.results[i][0].transcript;
|
| 136 |
+
if (e.results[i].isFinal) finalText += e.results[i][0].transcript + " ";
|
| 137 |
+
}
|
| 138 |
+
inp.value = (finalText || transcript).trim();
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
rec.onerror = () => {
|
| 142 |
+
listening = false;
|
| 143 |
+
statusEl.textContent = "Micro: erreur";
|
| 144 |
+
};
|
| 145 |
+
|
| 146 |
+
rec.onend = () => {
|
| 147 |
+
listening = false;
|
| 148 |
+
statusEl.textContent = "Micro: prêt";
|
| 149 |
+
if (inp.value.trim()) handleSend(inp.value);
|
| 150 |
+
};
|
| 151 |
+
|
| 152 |
+
try { rec.start(); } catch (e) {
|
| 153 |
+
listening = false;
|
| 154 |
+
statusEl.textContent = "Micro: prêt";
|
| 155 |
+
}
|
| 156 |
+
};
|
| 157 |
+
|
| 158 |
+
addMsg("Bonjour 👋 Je suis Rosalinda. Clique 🎤 pour parler ou écris-moi.", "ai");
|
| 159 |
+
</script>
|
| 160 |
+
</body>
|
| 161 |
+
</html>
|
|
@@ -26,13 +26,49 @@
|
|
| 26 |
button, a, input {
|
| 27 |
transition: all 0.15s ease;
|
| 28 |
}
|
| 29 |
-
|
| 30 |
/* Focus styles */
|
| 31 |
input:focus, button:focus {
|
| 32 |
outline: none;
|
| 33 |
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
|
| 34 |
}
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
/* Animation for empty state */
|
| 37 |
@keyframes pulse {
|
| 38 |
0%, 100% {
|
|
|
|
| 26 |
button, a, input {
|
| 27 |
transition: all 0.15s ease;
|
| 28 |
}
|
|
|
|
| 29 |
/* Focus styles */
|
| 30 |
input:focus, button:focus {
|
| 31 |
outline: none;
|
| 32 |
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
|
| 33 |
}
|
| 34 |
|
| 35 |
+
/* Rosalinda chat styles */
|
| 36 |
+
.wrap {
|
| 37 |
+
max-width: 980px;
|
| 38 |
+
margin: 0 auto;
|
| 39 |
+
padding: 1rem;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.chat {
|
| 43 |
+
border: 1px solid rgba(255, 255, 255, 0.12);
|
| 44 |
+
border-radius: 1rem;
|
| 45 |
+
overflow: hidden;
|
| 46 |
+
background: rgba(255, 255, 255, 0.03);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.msgs {
|
| 50 |
+
height: 60vh;
|
| 51 |
+
overflow: auto;
|
| 52 |
+
padding: 1rem;
|
| 53 |
+
display: flex;
|
| 54 |
+
flex-direction: column;
|
| 55 |
+
gap: 0.75rem;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.msg {
|
| 59 |
+
max-width: 85%;
|
| 60 |
+
padding: 0.75rem 1rem;
|
| 61 |
+
border-radius: 0.875rem;
|
| 62 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.badge {
|
| 66 |
+
padding: 0.5rem 0.75rem;
|
| 67 |
+
border: 1px solid rgba(255, 255, 255, 0.12);
|
| 68 |
+
border-radius: 999px;
|
| 69 |
+
background: rgba(255, 255, 255, 0.04);
|
| 70 |
+
font-size: 0.875rem;
|
| 71 |
+
}
|
| 72 |
/* Animation for empty state */
|
| 73 |
@keyframes pulse {
|
| 74 |
0%, 100% {
|