1) Ce qui est possible “illimité”
Browse filesMicro (STT) + Voix (TTS) : possible “gratuit” via le navigateur (Chrome/Edge) ✅
IA qui répond vraiment intelligemment : il faut un modèle (local sur ton PC, ou via une API). Là, ce n’est jamais réellement illimité, il y aura soit une limite matérielle (local), soit des quotas (API). Je te propose les 2 options.
2) Option A (simple, rapide) : Rosalinda fonctionne en local avec “IA de base” + micro + voix
👉 Tu auras :
Tu parles → Rosalinda écrit ce qu’elle a entendu
Rosalinda répond en texte
Rosalinda lit sa réponse à voix haute
Crée ce fichier : rosalinda.html
(Ouvre-le dans Chrome/Edge)
<!doctype html>
<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>
- components/navbar.js +7 -2
- index.html +1 -0
- rosalinda.html +254 -0
- style.css +7 -1
|
@@ -103,8 +103,13 @@ class CustomNavbar extends HTMLElement {
|
|
| 103 |
</div>
|
| 104 |
<div class="nav-label">Espace Codage - Projet 2</div>
|
| 105 |
</div>
|
| 106 |
-
|
| 107 |
<div class="nav-section">Raccourcis</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
<div class="nav-item">
|
| 109 |
<div class="nav-icon">
|
| 110 |
<i data-feather="book"></i>
|
|
@@ -117,7 +122,7 @@ class CustomNavbar extends HTMLElement {
|
|
| 117 |
</div>
|
| 118 |
<div class="nav-label">Paramètres</div>
|
| 119 |
</div>
|
| 120 |
-
|
| 121 |
|
| 122 |
// Replace feather icons
|
| 123 |
if (typeof feather !== 'undefined') {
|
|
|
|
| 103 |
</div>
|
| 104 |
<div class="nav-label">Espace Codage - Projet 2</div>
|
| 105 |
</div>
|
|
|
|
| 106 |
<div class="nav-section">Raccourcis</div>
|
| 107 |
+
<div class="nav-item">
|
| 108 |
+
<div class="nav-icon">
|
| 109 |
+
<i data-feather="message-circle"></i>
|
| 110 |
+
</div>
|
| 111 |
+
<a href="/rosalinda.html" class="nav-label">Rosalinda IA</a>
|
| 112 |
+
</div>
|
| 113 |
<div class="nav-item">
|
| 114 |
<div class="nav-icon">
|
| 115 |
<i data-feather="book"></i>
|
|
|
|
| 122 |
</div>
|
| 123 |
<div class="nav-label">Paramètres</div>
|
| 124 |
</div>
|
| 125 |
+
`;
|
| 126 |
|
| 127 |
// Replace feather icons
|
| 128 |
if (typeof feather !== 'undefined') {
|
|
@@ -5,6 +5,7 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Espace Codage</title>
|
| 7 |
<link rel="stylesheet" href="style.css">
|
|
|
|
| 8 |
<script src="script.js"></script>
|
| 9 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 10 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Espace Codage</title>
|
| 7 |
<link rel="stylesheet" href="style.css">
|
| 8 |
+
<script src="components/navbar.js"></script>
|
| 9 |
<script src="script.js"></script>
|
| 10 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 11 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
|
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
<style>
|
| 10 |
+
.rosalinda-container {
|
| 11 |
+
max-width: 980px;
|
| 12 |
+
margin: 0 auto;
|
| 13 |
+
padding: 18px;
|
| 14 |
+
height: calc(100vh - 80px);
|
| 15 |
+
display: flex;
|
| 16 |
+
flex-direction: column;
|
| 17 |
+
}
|
| 18 |
+
.rosalinda-top {
|
| 19 |
+
display: flex;
|
| 20 |
+
gap: 10px;
|
| 21 |
+
align-items: center;
|
| 22 |
+
justify-content: space-between;
|
| 23 |
+
margin-bottom: 14px;
|
| 24 |
+
}
|
| 25 |
+
.rosalinda-badge {
|
| 26 |
+
padding: 8px 12px;
|
| 27 |
+
border: 1px solid var(--border);
|
| 28 |
+
border-radius: 999px;
|
| 29 |
+
background: var(--bg-panel);
|
| 30 |
+
font-size: 14px;
|
| 31 |
+
}
|
| 32 |
+
.rosalinda-chat {
|
| 33 |
+
flex: 1;
|
| 34 |
+
border: 1px solid var(--border);
|
| 35 |
+
border-radius: 16px;
|
| 36 |
+
overflow: hidden;
|
| 37 |
+
background: var(--bg-panel);
|
| 38 |
+
display: flex;
|
| 39 |
+
flex-direction: column;
|
| 40 |
+
}
|
| 41 |
+
.rosalinda-msgs {
|
| 42 |
+
flex: 1;
|
| 43 |
+
overflow: auto;
|
| 44 |
+
padding: 14px;
|
| 45 |
+
display: flex;
|
| 46 |
+
flex-direction: column;
|
| 47 |
+
gap: 10px;
|
| 48 |
+
}
|
| 49 |
+
.rosalinda-msg {
|
| 50 |
+
max-width: 85%;
|
| 51 |
+
padding: 10px 12px;
|
| 52 |
+
border-radius: 14px;
|
| 53 |
+
border: 1px solid rgba(255,255,255,.10);
|
| 54 |
+
font-size: 14px;
|
| 55 |
+
line-height: 1.5;
|
| 56 |
+
}
|
| 57 |
+
.rosalinda-me {
|
| 58 |
+
margin-left: auto;
|
| 59 |
+
background: rgba(93,173,255,.10);
|
| 60 |
+
}
|
| 61 |
+
.rosalinda-ai {
|
| 62 |
+
background: rgba(255,255,255,.04);
|
| 63 |
+
}
|
| 64 |
+
.rosalinda-row {
|
| 65 |
+
display: flex;
|
| 66 |
+
gap: 10px;
|
| 67 |
+
align-items: center;
|
| 68 |
+
padding: 12px;
|
| 69 |
+
border-top: 1px solid var(--border);
|
| 70 |
+
background: rgba(0,0,0,.2);
|
| 71 |
+
}
|
| 72 |
+
.rosalinda-input {
|
| 73 |
+
flex: 1;
|
| 74 |
+
background: transparent;
|
| 75 |
+
border: 1px solid var(--border);
|
| 76 |
+
border-radius: 14px;
|
| 77 |
+
padding: 12px;
|
| 78 |
+
color: var(--text-light);
|
| 79 |
+
outline: none;
|
| 80 |
+
}
|
| 81 |
+
.rosalinda-btn {
|
| 82 |
+
width: 42px;
|
| 83 |
+
height: 42px;
|
| 84 |
+
display: flex;
|
| 85 |
+
align-items: center;
|
| 86 |
+
justify-content: center;
|
| 87 |
+
background: rgba(255,255,255,.05);
|
| 88 |
+
border: 1px solid var(--border);
|
| 89 |
+
color: var(--text-light);
|
| 90 |
+
border-radius: 14px;
|
| 91 |
+
cursor: pointer;
|
| 92 |
+
}
|
| 93 |
+
.rosalinda-btn:hover {
|
| 94 |
+
background: rgba(255,255,255,.08);
|
| 95 |
+
}
|
| 96 |
+
.rosalinda-btn:disabled {
|
| 97 |
+
opacity: .5;
|
| 98 |
+
cursor: not-allowed;
|
| 99 |
+
}
|
| 100 |
+
.rosalinda-send {
|
| 101 |
+
background: var(--primary);
|
| 102 |
+
}
|
| 103 |
+
.rosalinda-send:hover:not(:disabled) {
|
| 104 |
+
background: var(--primary-hover);
|
| 105 |
+
}
|
| 106 |
+
.rosalinda-info {
|
| 107 |
+
color: var(--text-muted);
|
| 108 |
+
font-size: 12px;
|
| 109 |
+
margin-top: 10px;
|
| 110 |
+
line-height: 1.5;
|
| 111 |
+
}
|
| 112 |
+
</style>
|
| 113 |
+
</head>
|
| 114 |
+
<body class="bg-gray-900 text-gray-100">
|
| 115 |
+
<custom-navbar></custom-navbar>
|
| 116 |
+
<div class="rosalinda-container">
|
| 117 |
+
<div class="rosalinda-top">
|
| 118 |
+
<div class="rosalinda-badge"><b>Rosalinda</b> — Espace Codage</div>
|
| 119 |
+
<div class="rosalinda-badge" id="rosalindaStatus">Micro: prêt</div>
|
| 120 |
+
</div>
|
| 121 |
+
|
| 122 |
+
<div class="rosalinda-chat">
|
| 123 |
+
<div class="rosalinda-msgs" id="rosalindaMsgs"></div>
|
| 124 |
+
<div class="rosalinda-row">
|
| 125 |
+
<button class="rosalinda-btn" id="rosalindaMicBtn">🎤</button>
|
| 126 |
+
<input class="rosalinda-input" id="rosalindaInput" placeholder="Écris à Rosalinda…">
|
| 127 |
+
<button class="rosalinda-btn rosalinda-send" id="rosalindaSendBtn">➤</button>
|
| 128 |
+
<button class="rosalinda-btn" id="rosalindaSpeakBtn" title="Lire la dernière réponse">🔊</button>
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
<div class="rosalinda-info">
|
| 133 |
+
✅ Micro & voix = API du navigateur (Chrome/Edge).<br>
|
| 134 |
+
⚠️ Cette version répond avec une "IA locale simple" (règles). Étape suivante : brancher un vrai modèle IA (local ou API).
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
|
| 138 |
+
<script>
|
| 139 |
+
const rosalindaMsgs = document.getElementById("rosalindaMsgs");
|
| 140 |
+
const rosalindaInput = document.getElementById("rosalindaInput");
|
| 141 |
+
const rosalindaSendBtn = document.getElementById("rosalindaSendBtn");
|
| 142 |
+
const rosalindaMicBtn = document.getElementById("rosalindaMicBtn");
|
| 143 |
+
const rosalindaSpeakBtn = document.getElementById("rosalindaSpeakBtn");
|
| 144 |
+
const rosalindaStatus = document.getElementById("rosalindaStatus");
|
| 145 |
+
|
| 146 |
+
let lastAIText = "";
|
| 147 |
+
|
| 148 |
+
function addRosalindaMsg(text, who) {
|
| 149 |
+
const div = document.createElement("div");
|
| 150 |
+
div.className = `rosalinda-msg ${who === "me" ? "rosalinda-me" : "rosalinda-ai"}`;
|
| 151 |
+
div.textContent = text;
|
| 152 |
+
rosalindaMsgs.appendChild(div);
|
| 153 |
+
rosalindaMsgs.scrollTop = rosalindaMsgs.scrollHeight;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
function rosalindaBrain(userText) {
|
| 157 |
+
const t = userText.toLowerCase();
|
| 158 |
+
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…";
|
| 159 |
+
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.";
|
| 160 |
+
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.";
|
| 161 |
+
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.";
|
| 162 |
+
if (t.includes("micro")) return "Pour le micro : clique 🎤, autorise le micro dans ton navigateur, puis parle. Je transcris et je réponds.";
|
| 163 |
+
return "Compris ✅ Donne-moi plus de détails (objectif + plateforme + style), et je te génère une réponse claire.";
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
function rosalindaSpeak(text) {
|
| 167 |
+
if (!("speechSynthesis" in window)) {
|
| 168 |
+
alert("Synthèse vocale non supportée sur ce navigateur.");
|
| 169 |
+
return;
|
| 170 |
+
}
|
| 171 |
+
const utterance = new SpeechSynthesisUtterance(text);
|
| 172 |
+
utterance.lang = "fr-FR";
|
| 173 |
+
window.speechSynthesis.cancel();
|
| 174 |
+
window.speechSynthesis.speak(utterance);
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
function handleRosalindaSend(text) {
|
| 178 |
+
const value = (text ?? rosalindaInput.value).trim();
|
| 179 |
+
if (!value) return;
|
| 180 |
+
addRosalindaMsg(value, "me");
|
| 181 |
+
rosalindaInput.value = "";
|
| 182 |
+
const reply = rosalindaBrain(value);
|
| 183 |
+
lastAIText = reply;
|
| 184 |
+
addRosalindaMsg(reply, "ai");
|
| 185 |
+
rosalindaSpeak(reply);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
rosalindaSendBtn.onclick = () => handleRosalindaSend();
|
| 189 |
+
rosalindaInput.addEventListener("keydown", (e) => {
|
| 190 |
+
if (e.key === "Enter") handleRosalindaSend();
|
| 191 |
+
});
|
| 192 |
+
|
| 193 |
+
rosalindaSpeakBtn.onclick = () => lastAIText && rosalindaSpeak(lastAIText);
|
| 194 |
+
|
| 195 |
+
// Micro (STT)
|
| 196 |
+
let rosalindaRec = null;
|
| 197 |
+
let rosalindaListening = false;
|
| 198 |
+
|
| 199 |
+
function setupRosalindaSTT() {
|
| 200 |
+
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
| 201 |
+
if (!SpeechRecognition) return null;
|
| 202 |
+
const recognition = new SpeechRecognition();
|
| 203 |
+
recognition.lang = "fr-FR";
|
| 204 |
+
recognition.interimResults = true;
|
| 205 |
+
recognition.continuous = false;
|
| 206 |
+
return recognition;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
rosalindaRec = setupRosalindaSTT();
|
| 210 |
+
|
| 211 |
+
rosalindaMicBtn.onclick = async () => {
|
| 212 |
+
if (!rosalindaRec) {
|
| 213 |
+
alert("Reconnaissance vocale non disponible ici. Essaie Chrome/Edge.");
|
| 214 |
+
return;
|
| 215 |
+
}
|
| 216 |
+
if (rosalindaListening) return;
|
| 217 |
+
|
| 218 |
+
rosalindaListening = true;
|
| 219 |
+
rosalindaStatus.textContent = "Micro: écoute…";
|
| 220 |
+
let finalText = "";
|
| 221 |
+
|
| 222 |
+
rosalindaRec.onresult = (e) => {
|
| 223 |
+
let transcript = "";
|
| 224 |
+
for (let i = e.resultIndex; i < e.results.length; i++) {
|
| 225 |
+
transcript += e.results[i][0].transcript;
|
| 226 |
+
if (e.results[i].isFinal) finalText += e.results[i][0].transcript + " ";
|
| 227 |
+
}
|
| 228 |
+
rosalindaInput.value = (finalText || transcript).trim();
|
| 229 |
+
};
|
| 230 |
+
|
| 231 |
+
rosalindaRec.onerror = () => {
|
| 232 |
+
rosalindaListening = false;
|
| 233 |
+
rosalindaStatus.textContent = "Micro: erreur";
|
| 234 |
+
};
|
| 235 |
+
|
| 236 |
+
rosalindaRec.onend = () => {
|
| 237 |
+
rosalindaListening = false;
|
| 238 |
+
rosalindaStatus.textContent = "Micro: prêt";
|
| 239 |
+
if (rosalindaInput.value.trim()) handleRosalindaSend(rosalindaInput.value);
|
| 240 |
+
};
|
| 241 |
+
|
| 242 |
+
try { rosalindaRec.start(); } catch (e) {
|
| 243 |
+
rosalindaListening = false;
|
| 244 |
+
rosalindaStatus.textContent = "Micro: prêt";
|
| 245 |
+
}
|
| 246 |
+
};
|
| 247 |
+
|
| 248 |
+
// Message de démarrage
|
| 249 |
+
addRosalindaMsg("Bonjour 👋 Je suis Rosalinda. Clique 🎤 pour parler ou écris-moi.", "ai");
|
| 250 |
+
</script>
|
| 251 |
+
<script src="components/navbar.js"></script>
|
| 252 |
+
<script src="script.js"></script>
|
| 253 |
+
</body>
|
| 254 |
+
</html>
|
|
@@ -160,14 +160,20 @@ body {
|
|
| 160 |
border: 1px solid var(--border);
|
| 161 |
color: var(--text-muted);
|
| 162 |
}
|
| 163 |
-
|
| 164 |
.nav-label {
|
| 165 |
flex: 1;
|
| 166 |
white-space: nowrap;
|
| 167 |
overflow: hidden;
|
| 168 |
text-overflow: ellipsis;
|
|
|
|
| 169 |
}
|
| 170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
.sidebar-footer {
|
| 172 |
display: flex;
|
| 173 |
justify-content: space-between;
|
|
|
|
| 160 |
border: 1px solid var(--border);
|
| 161 |
color: var(--text-muted);
|
| 162 |
}
|
|
|
|
| 163 |
.nav-label {
|
| 164 |
flex: 1;
|
| 165 |
white-space: nowrap;
|
| 166 |
overflow: hidden;
|
| 167 |
text-overflow: ellipsis;
|
| 168 |
+
color: var(--text-light);
|
| 169 |
}
|
| 170 |
|
| 171 |
+
.nav-label a {
|
| 172 |
+
color: inherit;
|
| 173 |
+
text-decoration: none;
|
| 174 |
+
display: block;
|
| 175 |
+
width: 100%;
|
| 176 |
+
}
|
| 177 |
.sidebar-footer {
|
| 178 |
display: flex;
|
| 179 |
justify-content: space-between;
|