talk2me/templates/index.html
Adolfo Delorenzo d818ec7d73 Major PWA and mobile UI improvements
- Fixed PWA installation on Android by correcting manifest.json icon configuration
- Made UI mobile-friendly with compact layout and sticky record button
- Implemented auto-translation after transcription stops
- Updated branding from 'Voice Translator' to 'Talk2Me' throughout
- Added reverse proxy support with ProxyFix middleware
- Created diagnostic tools for PWA troubleshooting
- Added proper HTTP headers for service worker and manifest
- Improved mobile CSS with responsive design
- Fixed JavaScript bundling with webpack configuration
- Updated service worker cache versioning
- Added comprehensive PWA documentation

These changes ensure the app works properly as a PWA on Android devices
and provides a better mobile user experience.
2025-06-03 12:28:09 -06:00

512 lines
23 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>Talk2Me - Real-time Voice Translation</title>
<!-- Icons for various platforms -->
<link rel="icon" href="/static/icons/favicon.ico" sizes="any">
<link rel="apple-touch-icon" href="/static/icons/apple-icon-180x180.png">
<link rel="apple-touch-icon" sizes="120x120" href="/static/icons/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="152x152" href="/static/icons/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="167x167" href="/static/icons/apple-icon-167x167.png">
<link rel="apple-touch-icon" sizes="180x180" href="/static/icons/apple-icon-180x180.png">
<style>
body {
padding-top: 10px;
padding-bottom: 10px;
background-color: #f8f9fa;
}
/* Mobile-first approach */
@media (max-width: 768px) {
.container {
padding-left: 10px;
padding-right: 10px;
}
h1 {
font-size: 1.5rem;
margin-bottom: 0.5rem !important;
}
.card {
margin-bottom: 10px !important;
}
.card-body {
padding: 0.75rem !important;
}
.card-header {
padding: 0.5rem 0.75rem !important;
}
.card-header h5 {
font-size: 1rem;
margin-bottom: 0;
}
.text-display {
min-height: 60px !important;
max-height: 100px;
overflow-y: auto;
padding: 10px !important;
margin-bottom: 10px !important;
font-size: 0.9rem;
}
.language-select {
padding: 5px 10px !important;
font-size: 0.9rem;
margin-bottom: 10px !important;
}
.btn-action {
padding: 5px 10px !important;
font-size: 0.875rem;
margin: 2px !important;
}
.record-btn {
width: 60px !important;
height: 60px !important;
font-size: 24px !important;
margin: 10px auto !important;
}
.status-indicator {
font-size: 0.8rem !important;
margin-top: 5px !important;
}
/* Hide speaker toolbar on mobile by default */
#speakerToolbar {
position: fixed;
bottom: 70px;
left: 0;
right: 0;
z-index: 100;
border-radius: 0 !important;
}
#conversationView {
position: fixed;
bottom: 0;
left: 0;
right: 0;
top: 50%;
z-index: 99;
border-radius: 15px 15px 0 0 !important;
margin: 0 !important;
}
}
.record-btn {
width: 80px;
height: 80px;
border-radius: 50%; /* This makes the button circular */
display: flex;
align-items: center;
justify-content: center;
font-size: 32px;
margin: 20px auto;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: all 0.3s;
padding: 0; /* Remove padding to ensure perfect circle */
border: none; /* Remove border for cleaner look */
}
.record-btn:active {
transform: scale(0.95);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.recording {
background-color: #dc3545 !important;
animation: pulse 1.5s infinite;
}
.record-btn.btn {
border-radius: 50% !important;
line-height: 1;
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}
.card {
border-radius: 15px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
}
.card-header {
border-radius: 15px 15px 0 0 !important;
}
.language-select {
border-radius: 10px;
padding: 10px;
}
.text-display {
min-height: 100px;
padding: 15px;
background-color: #f8f9fa;
border-radius: 10px;
margin-bottom: 15px;
position: relative;
}
.btn-action {
border-radius: 10px;
padding: 8px 15px;
margin: 5px;
}
.spinner-border {
width: 1rem;
height: 1rem;
margin-right: 5px;
}
.status-indicator {
font-size: 0.9rem;
font-style: italic;
color: #6c757d;
}
/* Ensure record button area is always visible on mobile */
@media (max-width: 768px) {
.record-section {
position: sticky;
bottom: 0;
background: white;
padding: 10px 0;
box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
z-index: 50;
margin-left: -10px;
margin-right: -10px;
padding-left: 10px;
padding-right: 10px;
}
}
</style>
<!-- PWA Meta Tags -->
<meta name="description" content="Real-time voice translation app - translate spoken language instantly">
<meta name="theme-color" content="#007bff">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Talk2Me">
<meta name="application-name" content="Talk2Me">
<meta name="msapplication-TileColor" content="#007bff">
<meta name="msapplication-TileImage" content="/static/icons/icon-192x192.png">
<!-- PWA Icons and Manifest -->
<link rel="manifest" href="/static/manifest.json">
<link rel="icon" type="image/png" sizes="192x192" href="/static/icons/icon-192x192.png">
<link rel="icon" type="image/png" sizes="512x512" href="/static/icons/icon-512x512.png">
<!-- Apple Splash Screens -->
<link rel="apple-touch-startup-image" href="/static/splash/apple-splash-2048-2732.png" media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/static/splash/apple-splash-1668-2388.png" media="(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/static/splash/apple-splash-1536-2048.png" media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/static/splash/apple-splash-1125-2436.png" media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/static/splash/apple-splash-1242-2688.png" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/static/splash/apple-splash-750-1334.png" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/static/splash/apple-splash-640-1136.png" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<!-- Stylesheets -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="stylesheet" href="/static/css/styles.css">
</head>
<body>
<div class="container">
<h1 class="text-center mb-4">Talk2Me</h1>
<!--<p class="text-center text-muted">Powered by Gemma 3, Whisper & Edge TTS</p>-->
<!-- Multi-speaker toolbar -->
<div id="speakerToolbar" class="card mb-3" style="display: none;">
<div class="card-body p-2">
<div class="d-flex align-items-center justify-content-between flex-wrap">
<div class="d-flex align-items-center gap-2 mb-2 mb-md-0">
<button id="addSpeakerBtn" class="btn btn-sm btn-outline-primary">
<i class="fas fa-user-plus"></i> Add Speaker
</button>
<button id="toggleMultiSpeaker" class="btn btn-sm btn-secondary">
<i class="fas fa-users"></i> Multi-Speaker: <span id="multiSpeakerStatus">OFF</span>
</button>
</div>
<div id="speakerList" class="d-flex gap-2 flex-wrap">
<!-- Speaker buttons will be added here dynamically -->
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<div class="card">
<div class="card-header bg-primary text-white">
<h5 class="mb-0">Source</h5>
</div>
<div class="card-body">
<select id="sourceLanguage" class="form-select language-select mb-3">
<option value="auto">Auto-detect</option>
{% for language in languages %}
<option value="{{ language }}">{{ language }}</option>
{% endfor %}
</select>
<div class="text-display" id="sourceText">
<p class="text-muted">Your transcribed text will appear here...</p>
</div>
<div class="d-flex justify-content-between">
<button id="playSource" class="btn btn-outline-primary btn-action" disabled>
<i class="fas fa-play"></i> Play
</button>
<button id="clearSource" class="btn btn-outline-secondary btn-action">
<i class="fas fa-trash"></i> Clear
</button>
</div>
</div>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="card">
<div class="card-header bg-success text-white">
<h5 class="mb-0">Translation</h5>
</div>
<div class="card-body">
<select id="targetLanguage" class="form-select language-select mb-3">
{% for language in languages %}
<option value="{{ language }}">{{ language }}</option>
{% endfor %}
</select>
<div class="text-display" id="translatedText">
<p class="text-muted">Translation will appear here...</p>
</div>
<div class="d-flex justify-content-between">
<button id="playTranslation" class="btn btn-outline-success btn-action" disabled>
<i class="fas fa-play"></i> Play
</button>
<button id="clearTranslation" class="btn btn-outline-secondary btn-action">
<i class="fas fa-trash"></i> Clear
</button>
</div>
</div>
</div>
</div>
</div>
<div class="text-center record-section">
<button id="recordBtn" class="btn btn-primary record-btn">
<i class="fas fa-microphone"></i>
</button>
<p class="status-indicator" id="statusIndicator">Click to start recording</p>
<!-- Queue Status Indicator -->
<div id="queueStatus" class="text-center mt-2" style="display: none;">
<small class="text-muted">
<i class="fas fa-list"></i> Queue: <span id="queueLength">0</span> |
<i class="fas fa-sync"></i> Active: <span id="activeRequests">0</span>
</small>
</div>
<div class="mt-2">
<button id="translateBtn" class="btn btn-outline-secondary btn-sm" disabled title="Translation happens automatically after transcription">
<i class="fas fa-redo"></i> Re-translate
</button>
<small class="text-muted d-block mt-1">Translation happens automatically after transcription</small>
</div>
</div>
<div class="mt-3">
<div class="progress d-none" id="progressContainer">
<div id="progressBar" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%"></div>
</div>
</div>
<!-- Multi-speaker conversation view -->
<div id="conversationView" class="card mt-4" style="display: none;">
<div class="card-header bg-info text-white d-flex justify-content-between align-items-center">
<h5 class="mb-0">Conversation</h5>
<div>
<button id="exportConversation" class="btn btn-sm btn-light">
<i class="fas fa-download"></i> Export
</button>
<button id="clearConversation" class="btn btn-sm btn-light">
<i class="fas fa-trash"></i> Clear
</button>
</div>
</div>
<div class="card-body" style="max-height: 400px; overflow-y: auto;">
<div id="conversationContent">
<!-- Conversation entries will be added here -->
</div>
</div>
</div>
<audio id="audioPlayer" style="display: none;"></audio>
<!-- TTS Server Configuration Alert -->
<div id="ttsServerAlert" class="alert alert-warning d-none" role="alert">
<strong>TTS Server Status:</strong> <span id="ttsServerMessage">Checking...</span>
<div class="mt-2">
<input type="text" id="ttsServerUrl" class="form-control mb-2" placeholder="TTS Server URL">
<input type="password" id="ttsApiKey" class="form-control mb-2" placeholder="API Key">
<button id="updateTtsServer" class="btn btn-sm btn-primary">Update Configuration</button>
</div>
</div>
<!-- Loading Overlay -->
<div id="loadingOverlay" class="loading-overlay">
<div class="loading-content">
<div class="spinner-custom"></div>
<p id="loadingText" class="mt-3">Processing...</p>
</div>
</div>
<!-- Notification Settings -->
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 5">
<div id="notificationPrompt" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<i class="fas fa-bell text-primary me-2"></i>
<strong class="me-auto">Enable Notifications</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Get notified when translations are complete!
<div class="mt-2">
<button type="button" class="btn btn-sm btn-primary" id="enableNotifications">Enable</button>
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="toast">Not now</button>
</div>
</div>
</div>
<!-- Success Toast -->
<div id="successToast" class="toast align-items-center text-white bg-success border-0" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
<i class="fas fa-check-circle me-2"></i>
<span id="successMessage">Settings saved successfully!</span>
</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
<!-- Settings Modal -->
<div class="modal fade" id="settingsModal" tabindex="-1" aria-labelledby="settingsModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="settingsModalLabel">Settings</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<h6>Notifications</h6>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="notificationToggle">
<label class="form-check-label" for="notificationToggle">
Enable push notifications
</label>
</div>
<p class="text-muted small mt-2">Get notified when transcriptions and translations complete</p>
<hr>
<h6>Notification Types</h6>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="notifyTranscription" checked>
<label class="form-check-label" for="notifyTranscription">
Transcription complete
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="notifyTranslation" checked>
<label class="form-check-label" for="notifyTranslation">
Translation complete
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="notifyErrors">
<label class="form-check-label" for="notifyErrors">
Error notifications
</label>
</div>
<hr>
<h6 class="mb-3">Translation Settings</h6>
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="streamingTranslation" checked>
<label class="form-check-label" for="streamingTranslation">
Enable streaming translation
<small class="text-muted d-block">Shows translation as it's generated for faster feedback</small>
</label>
</div>
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="multiSpeakerMode">
<label class="form-check-label" for="multiSpeakerMode">
Enable multi-speaker mode
<small class="text-muted d-block">Track multiple speakers in conversations</small>
</label>
</div>
<hr>
<h6>Offline Cache</h6>
<div class="mb-3">
<div class="d-flex justify-content-between align-items-center mb-2">
<span>Cached translations:</span>
<span id="cacheCount" class="badge bg-primary">0</span>
</div>
<div class="d-flex justify-content-between align-items-center mb-2">
<span>Cache size:</span>
<span id="cacheSize" class="badge bg-secondary">0 KB</span>
</div>
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" id="offlineMode" checked>
<label class="form-check-label" for="offlineMode">
Enable offline caching
</label>
</div>
<button type="button" class="btn btn-sm btn-outline-danger" id="clearCache">
<i class="fas fa-trash"></i> Clear Cache
</button>
</div>
</div>
<div class="modal-footer">
<div id="settingsSaveStatus" class="text-success me-auto" style="display: none;">
<i class="fas fa-check-circle"></i> Saved!
</div>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="saveSettings">Save settings</button>
</div>
</div>
</div>
</div>
<!-- Settings Button -->
<button type="button" class="btn btn-outline-secondary position-fixed top-0 end-0 m-3" data-bs-toggle="modal" data-bs-target="#settingsModal">
<i class="fas fa-cog"></i>
</button>
<!-- Simple Success Notification -->
<div id="successNotification" class="success-notification">
<i class="fas fa-check-circle"></i>
<span id="successText">Settings saved successfully!</span>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script src="/static/js/dist/app.bundle.js"></script>
</body>
</html>