Files
live-radio/gateway/player.html
T
ozan 4924db5617 Add Live Ozan Radio — DeepSeek DJ, Lyria 3, and player chat.
Personal AI station that generates tracks from taste seeds or Spotify; safe to share — secrets and cache are gitignored.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-07 14:15:42 +01:00

393 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Live Ozan Radio</title>
<style>
:root {
--bg: #0a0a0f;
--panel: #14141f;
--accent: #ff6b35;
--accent2: #7b5cff;
--text: #f0f0f5;
--muted: #8888a0;
--glow: rgba(255, 107, 53, 0.35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: "Segoe UI", system-ui, sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-image:
radial-gradient(ellipse 80% 50% at 50% -10%, var(--glow), transparent),
radial-gradient(ellipse 60% 40% at 100% 100%, rgba(123,92,255,0.15), transparent);
}
.radio {
width: min(440px, 92vw);
background: var(--panel);
border: 1px solid #2a2a3a;
border-radius: 20px;
padding: 2rem;
box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.badge {
display: inline-block;
font-size: 0.7rem;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--accent);
border: 1px solid var(--accent);
border-radius: 4px;
padding: 0.2rem 0.5rem;
margin-bottom: 0.75rem;
}
h1 {
font-size: 1.6rem;
font-weight: 700;
margin-bottom: 0.25rem;
}
.tagline {
color: var(--muted);
font-size: 0.85rem;
margin-bottom: 1.5rem;
line-height: 1.4;
}
.viz {
height: 64px;
display: flex;
align-items: flex-end;
justify-content: center;
gap: 4px;
margin-bottom: 1.25rem;
}
.bar {
width: 6px;
background: linear-gradient(to top, var(--accent), var(--accent2));
border-radius: 3px;
animation: bounce 0.8s ease-in-out infinite alternate;
}
.bar:nth-child(1) { height: 20px; animation-delay: 0s; }
.bar:nth-child(2) { height: 36px; animation-delay: 0.1s; }
.bar:nth-child(3) { height: 52px; animation-delay: 0.2s; }
.bar:nth-child(4) { height: 40px; animation-delay: 0.15s; }
.bar:nth-child(5) { height: 28px; animation-delay: 0.05s; }
.bar:nth-child(6) { height: 44px; animation-delay: 0.25s; }
.bar:nth-child(7) { height: 32px; animation-delay: 0.12s; }
@keyframes bounce {
from { transform: scaleY(0.4); opacity: 0.6; }
to { transform: scaleY(1); opacity: 1; }
}
.now-title {
font-size: 1.15rem;
font-weight: 600;
margin-bottom: 0.35rem;
}
.now-mood, .dj-line {
font-size: 0.85rem;
color: var(--muted);
margin-bottom: 0.5rem;
}
.dj-line { font-style: italic; color: #b0b0c8; }
audio {
width: 100%;
margin: 1rem 0;
border-radius: 8px;
}
.controls {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
button {
flex: 1;
min-width: 100px;
padding: 0.65rem 1rem;
border: none;
border-radius: 10px;
font-size: 0.85rem;
font-weight: 600;
cursor: pointer;
transition: transform 0.15s, opacity 0.15s;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.primary {
background: linear-gradient(135deg, var(--accent), #ff8f65);
color: #fff;
}
.secondary {
background: #2a2a3a;
color: var(--text);
border: 1px solid #3a3a50;
}
.status {
margin-top: 1rem;
font-size: 0.75rem;
color: var(--muted);
text-align: center;
}
.stack {
font-size: 0.7rem;
color: #555568;
margin-top: 1.25rem;
padding-top: 1rem;
border-top: 1px solid #2a2a3a;
line-height: 1.6;
}
.chat {
margin-top: 1.25rem;
border-top: 1px solid #2a2a3a;
padding-top: 1rem;
}
.chat h2 {
font-size: 0.8rem;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--muted);
margin-bottom: 0.65rem;
}
.chat-log {
height: 160px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 0.5rem;
margin-bottom: 0.65rem;
padding-right: 0.25rem;
}
.chat-log::-webkit-scrollbar { width: 4px; }
.chat-log::-webkit-scrollbar-thumb { background: #3a3a50; border-radius: 2px; }
.bubble {
max-width: 88%;
padding: 0.55rem 0.75rem;
border-radius: 12px;
font-size: 0.82rem;
line-height: 1.4;
}
.bubble.user {
align-self: flex-end;
background: #2a2a3a;
color: var(--text);
border-bottom-right-radius: 4px;
}
.bubble.dj {
align-self: flex-start;
background: linear-gradient(135deg, rgba(255,107,53,0.15), rgba(123,92,255,0.12));
border: 1px solid #3a3a50;
border-bottom-left-radius: 4px;
}
.chat-form {
display: flex;
gap: 0.5rem;
}
.chat-form input {
flex: 1;
background: #1a1a28;
border: 1px solid #3a3a50;
border-radius: 10px;
padding: 0.6rem 0.75rem;
color: var(--text);
font-size: 0.85rem;
}
.chat-form input:focus {
outline: none;
border-color: var(--accent);
}
.chat-form button {
flex: 0 0 auto;
min-width: 72px;
padding: 0.6rem 1rem;
}
</style>
</head>
<body>
<div class="radio">
<div class="badge">● Live</div>
<h1>Ozan Radio</h1>
<p class="tagline">No Spotify playback. No catalog tracks. DeepSeek picks the vibe — Google Lyria 3 composes it fresh.</p>
<div class="viz" id="viz">
<div class="bar"></div><div class="bar"></div><div class="bar"></div>
<div class="bar"></div><div class="bar"></div><div class="bar"></div><div class="bar"></div>
</div>
<div class="now-title" id="title">Waiting for first track…</div>
<div class="now-mood" id="mood"></div>
<div class="dj-line" id="dj"></div>
<audio id="player" controls></audio>
<div class="controls">
<button class="primary" id="genBtn">Generate next</button>
<button class="secondary" id="skipBtn">Skip</button>
<button class="secondary" id="refreshBtn">Refresh</button>
</div>
<div class="status" id="status">Connecting…</div>
<section class="chat">
<h2>Talk to the DJ</h2>
<div class="chat-log" id="chatLog"></div>
<form class="chat-form" id="chatForm">
<input id="chatInput" type="text" placeholder="Ask for a vibe… e.g. more Sahel, slower, surprise me" maxlength="500" autocomplete="off">
<button type="submit" class="primary" id="chatSend">Send</button>
</form>
</section>
<div class="stack">
DJ: DeepSeek · Music: Google Lyria 3 · Taste: Spotify (read-only)<br>
Optional live layer: Magenta RealTime 2 on Apple Silicon
</div>
</div>
<script>
const API = window.location.origin;
const player = document.getElementById('player');
const titleEl = document.getElementById('title');
const moodEl = document.getElementById('mood');
const djEl = document.getElementById('dj');
const statusEl = document.getElementById('status');
const genBtn = document.getElementById('genBtn');
const skipBtn = document.getElementById('skipBtn');
const refreshBtn = document.getElementById('refreshBtn');
const chatLog = document.getElementById('chatLog');
const chatForm = document.getElementById('chatForm');
const chatInput = document.getElementById('chatInput');
const chatSend = document.getElementById('chatSend');
function addBubble(role, text) {
const el = document.createElement('div');
el.className = `bubble ${role}`;
el.textContent = text;
chatLog.appendChild(el);
chatLog.scrollTop = chatLog.scrollHeight;
}
async function loadChat() {
try {
const res = await fetch(`${API}/api/chat`);
const data = await res.json();
chatLog.innerHTML = '';
for (const m of data.messages || []) {
addBubble(m.role, m.content);
}
} catch (_) {}
}
async function sendChat(text) {
chatSend.disabled = true;
chatInput.disabled = true;
addBubble('user', text);
try {
const res = await fetch(`${API}/api/chat`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message: text }),
});
const data = await res.json();
if (data.reply) addBubble('dj', data.reply);
if (data.generating) {
statusEl.textContent = 'DJ is composing your request…';
pollForNewTrack();
}
} catch (_) {
addBubble('dj', 'Signal lost — try again.');
} finally {
chatSend.disabled = false;
chatInput.disabled = false;
chatInput.focus();
}
}
let pollTimer = null;
function pollForNewTrack() {
let n = 0;
clearInterval(pollTimer);
pollTimer = setInterval(async () => {
n += 1;
await refreshNow();
if (n > 60) clearInterval(pollTimer);
}, 5000);
}
async function refreshNow() {
try {
const res = await fetch(`${API}/api/now`);
const data = await res.json();
if (data.status === 'idle') {
titleEl.textContent = 'Queue empty';
moodEl.textContent = '';
djEl.textContent = 'Hit Generate to compose the first track.';
statusEl.textContent = data.message || 'Idle';
return;
}
const t = data.track;
titleEl.textContent = t.title;
moodEl.textContent = t.mood ? `Mood: ${t.mood}` : '';
djEl.textContent = t.dj_line ? `"${t.dj_line}"` : '';
if (t.audio_url && player.src !== `${API}${t.audio_url}`) {
player.src = `${API}${t.audio_url}`;
player.play().catch(() => {});
}
statusEl.textContent = `Playing · ${t.track_id}`;
} catch (e) {
statusEl.textContent = 'Server offline — start: python -m ozan_radio';
}
}
async function generate() {
genBtn.disabled = true;
statusEl.textContent = 'DeepSeek is planning… Lyria is composing…';
try {
const res = await fetch(`${API}/api/generate`, { method: 'POST' });
const data = await res.json();
if (data.status === 'busy') {
statusEl.textContent = data.message;
} else if (data.status === 'ok') {
await refreshNow();
} else {
statusEl.textContent = 'Generation failed — check server logs';
}
} catch (e) {
statusEl.textContent = 'Request failed';
} finally {
genBtn.disabled = false;
}
}
async function skip() {
skipBtn.disabled = true;
try {
await fetch(`${API}/api/skip`, { method: 'POST' });
await refreshNow();
} finally {
skipBtn.disabled = false;
}
}
genBtn.addEventListener('click', generate);
skipBtn.addEventListener('click', skip);
refreshBtn.addEventListener('click', refreshNow);
player.addEventListener('ended', () => { skip(); });
chatForm.addEventListener('submit', (e) => {
e.preventDefault();
const text = chatInput.value.trim();
if (!text) return;
chatInput.value = '';
sendChat(text);
});
refreshNow();
loadChat();
setInterval(refreshNow, 15000);
</script>
</body>
</html>