Droidchatts / index.html
Mashbox41's picture
Update index.html
e5949c2 verified
Raw History Blame Contribute Delete
1.26 kB
<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1"><title>Droidchatts</title></head>
<body>
<h1>Droid Chat + TTS</h1>
<textarea id="chat" placeholder="Say something..."></textarea><br>
<button onclick="sendChat()">Send Chat</button><br>
<p id="reply"></p>
<textarea id="speak" placeholder="Text to speak..."></textarea><br>
<button onclick="sendTTS()">Speak</button><br>
<audio id="audio" controls></audio>
<script>
async function sendChat() {
const text = document.getElementById("chat").value;
const res = await fetch("/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ prompt: text })
});
const data = await res.json();
document.getElementById("reply").innerText = data.response;
}
async function sendTTS() {
const text = document.getElementById("speak").value;
const res = await fetch("/tts", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text })
});
const blob = await res.blob();
document.getElementById("audio").src = URL.createObjectURL(blob);
}
</script>
</body>
</html>