Spaces:
Sleeping
Sleeping
Kennethdotse commited on
Commit Β·
891708a
1
Parent(s): de827b0
made some changes
Browse files- __pycache__/api.cpython-313.pyc +0 -0
- __pycache__/main.cpython-313.pyc +0 -0
- api.py +3 -1
- app.py +0 -701
- assets/gen.png +0 -0
- assets/logo.png +0 -0
- main.py +2 -0
- requirements.txt +2 -1
- static/index.html +165 -58
__pycache__/api.cpython-313.pyc
ADDED
|
Binary file (12.7 kB). View file
|
|
|
__pycache__/main.cpython-313.pyc
ADDED
|
Binary file (374 Bytes). View file
|
|
|
api.py
CHANGED
|
@@ -16,6 +16,7 @@ from fastapi.staticfiles import StaticFiles
|
|
| 16 |
from huggingface_hub import HfApi, create_repo, upload_file
|
| 17 |
from transformers import WhisperForConditionalGeneration, WhisperProcessor
|
| 18 |
|
|
|
|
| 19 |
# ββ Env ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 20 |
load_dotenv()
|
| 21 |
|
|
@@ -279,4 +280,5 @@ async def dataset_entries(limit: int = 50, offset: int = 0):
|
|
| 279 |
|
| 280 |
|
| 281 |
# ββ Static files βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 282 |
-
app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
|
|
|
|
|
|
| 16 |
from huggingface_hub import HfApi, create_repo, upload_file
|
| 17 |
from transformers import WhisperForConditionalGeneration, WhisperProcessor
|
| 18 |
|
| 19 |
+
|
| 20 |
# ββ Env ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
load_dotenv()
|
| 22 |
|
|
|
|
| 280 |
|
| 281 |
|
| 282 |
# ββ Static files βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 283 |
+
app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
|
| 284 |
+
app.mount("/assets", StaticFiles(directory="assets"), name="assets")
|
app.py
DELETED
|
@@ -1,701 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import uuid
|
| 3 |
-
import shutil
|
| 4 |
-
import numpy as np
|
| 5 |
-
import pandas as pd
|
| 6 |
-
import soundfile as sf
|
| 7 |
-
import torch
|
| 8 |
-
import torchaudio
|
| 9 |
-
import gradio as gr
|
| 10 |
-
|
| 11 |
-
import threading
|
| 12 |
-
from dotenv import load_dotenv
|
| 13 |
-
from huggingface_hub import HfApi, create_repo, upload_file
|
| 14 |
-
from transformers import WhisperForConditionalGeneration, WhisperProcessor
|
| 15 |
-
|
| 16 |
-
# =========================================================
|
| 17 |
-
# LOAD ENV VARIABLES
|
| 18 |
-
# =========================================================
|
| 19 |
-
|
| 20 |
-
load_dotenv()
|
| 21 |
-
|
| 22 |
-
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 23 |
-
DATASET_REPO = os.getenv("HF_DATASET_REPO")
|
| 24 |
-
|
| 25 |
-
# =========================================================
|
| 26 |
-
# LOCAL STORAGE
|
| 27 |
-
# =========================================================
|
| 28 |
-
|
| 29 |
-
LOCAL_DATASET_DIR = "hf_dataset"
|
| 30 |
-
LOCAL_AUDIO_DIR = os.path.join(LOCAL_DATASET_DIR, "audio")
|
| 31 |
-
LOCAL_METADATA = os.path.join(LOCAL_DATASET_DIR, "metadata.csv")
|
| 32 |
-
|
| 33 |
-
os.makedirs(LOCAL_AUDIO_DIR, exist_ok=True)
|
| 34 |
-
|
| 35 |
-
# =========================================================
|
| 36 |
-
# HUGGING FACE SETUP
|
| 37 |
-
# =========================================================
|
| 38 |
-
|
| 39 |
-
api = HfApi(token=HF_TOKEN)
|
| 40 |
-
|
| 41 |
-
try:
|
| 42 |
-
create_repo(
|
| 43 |
-
repo_id=DATASET_REPO,
|
| 44 |
-
repo_type="dataset",
|
| 45 |
-
exist_ok=True,
|
| 46 |
-
token=HF_TOKEN
|
| 47 |
-
)
|
| 48 |
-
except Exception as e:
|
| 49 |
-
print("Dataset repo check:", e)
|
| 50 |
-
|
| 51 |
-
# =========================================================
|
| 52 |
-
# LOAD MODEL
|
| 53 |
-
# =========================================================
|
| 54 |
-
|
| 55 |
-
model = WhisperForConditionalGeneration.from_pretrained(
|
| 56 |
-
"Kennethdot/kasanoma_whisper"
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
processor = WhisperProcessor.from_pretrained(
|
| 60 |
-
"Kennethdot/kasanoma_whisper"
|
| 61 |
-
)
|
| 62 |
-
|
| 63 |
-
device = torch.device(
|
| 64 |
-
"cuda" if torch.cuda.is_available() else "cpu"
|
| 65 |
-
)
|
| 66 |
-
|
| 67 |
-
model = model.to(device)
|
| 68 |
-
model.eval()
|
| 69 |
-
|
| 70 |
-
# =========================================================
|
| 71 |
-
# TRANSCRIPTION FUNCTION
|
| 72 |
-
# =========================================================
|
| 73 |
-
|
| 74 |
-
def transcribe_audio(audio_path):
|
| 75 |
-
|
| 76 |
-
if audio_path is None:
|
| 77 |
-
return "", "", None
|
| 78 |
-
|
| 79 |
-
try:
|
| 80 |
-
audio_data, sampling_rate = sf.read(audio_path)
|
| 81 |
-
|
| 82 |
-
# Stereo β mono
|
| 83 |
-
if len(audio_data.shape) > 1:
|
| 84 |
-
audio_data = np.mean(audio_data, axis=1)
|
| 85 |
-
|
| 86 |
-
audio_data = audio_data.astype(np.float32)
|
| 87 |
-
|
| 88 |
-
# Resample
|
| 89 |
-
if sampling_rate != 16000:
|
| 90 |
-
audio_tensor = torch.tensor(
|
| 91 |
-
audio_data,
|
| 92 |
-
dtype=torch.float32
|
| 93 |
-
)
|
| 94 |
-
|
| 95 |
-
resampler = torchaudio.transforms.Resample(
|
| 96 |
-
orig_freq=sampling_rate,
|
| 97 |
-
new_freq=16000
|
| 98 |
-
)
|
| 99 |
-
|
| 100 |
-
audio_data = resampler(audio_tensor).numpy()
|
| 101 |
-
sampling_rate = 16000
|
| 102 |
-
|
| 103 |
-
except Exception as e:
|
| 104 |
-
return f"Error reading audio: {e}", "", None
|
| 105 |
-
|
| 106 |
-
# Normalize
|
| 107 |
-
if np.max(np.abs(audio_data)) > 0:
|
| 108 |
-
audio_data = audio_data / np.max(np.abs(audio_data))
|
| 109 |
-
|
| 110 |
-
# Feature extraction
|
| 111 |
-
input_features = processor.feature_extractor(
|
| 112 |
-
audio_data,
|
| 113 |
-
sampling_rate=sampling_rate,
|
| 114 |
-
return_tensors="pt"
|
| 115 |
-
).input_features.to(device)
|
| 116 |
-
|
| 117 |
-
# Inference
|
| 118 |
-
with torch.no_grad():
|
| 119 |
-
|
| 120 |
-
generated_ids = model.generate(
|
| 121 |
-
input_features,
|
| 122 |
-
task="transcribe",
|
| 123 |
-
language="yo",
|
| 124 |
-
temperature=0.0
|
| 125 |
-
)
|
| 126 |
-
|
| 127 |
-
transcription = processor.batch_decode(
|
| 128 |
-
generated_ids,
|
| 129 |
-
skip_special_tokens=True
|
| 130 |
-
)[0].strip()
|
| 131 |
-
|
| 132 |
-
return transcription, transcription, audio_path
|
| 133 |
-
|
| 134 |
-
# =========================================================
|
| 135 |
-
# SAVE FUNCTION
|
| 136 |
-
# =========================================================
|
| 137 |
-
|
| 138 |
-
# Lock prevents concurrent saves from corrupting the CSV
|
| 139 |
-
_csv_lock = threading.Lock()
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
def _upload_in_background(saved_audio_path, relative_audio_path):
|
| 143 |
-
"""Runs in a daemon thread. Uploads audio then CSV β never blocks the UI."""
|
| 144 |
-
try:
|
| 145 |
-
upload_file(
|
| 146 |
-
path_or_fileobj=saved_audio_path,
|
| 147 |
-
path_in_repo=relative_audio_path,
|
| 148 |
-
repo_id=DATASET_REPO,
|
| 149 |
-
repo_type="dataset",
|
| 150 |
-
token=HF_TOKEN
|
| 151 |
-
)
|
| 152 |
-
with _csv_lock:
|
| 153 |
-
upload_file(
|
| 154 |
-
path_or_fileobj=LOCAL_METADATA,
|
| 155 |
-
path_in_repo="metadata.csv",
|
| 156 |
-
repo_id=DATASET_REPO,
|
| 157 |
-
repo_type="dataset",
|
| 158 |
-
token=HF_TOKEN
|
| 159 |
-
)
|
| 160 |
-
except Exception as e:
|
| 161 |
-
print(f"[Background upload error] {e}")
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
def save_sample(audio_path, corrected_text):
|
| 165 |
-
|
| 166 |
-
if audio_path is None:
|
| 167 |
-
return
|
| 168 |
-
|
| 169 |
-
try:
|
| 170 |
-
unique_id = str(uuid.uuid4())
|
| 171 |
-
|
| 172 |
-
saved_audio_path = os.path.join(
|
| 173 |
-
LOCAL_AUDIO_DIR,
|
| 174 |
-
f"{unique_id}.wav"
|
| 175 |
-
)
|
| 176 |
-
|
| 177 |
-
# Copy audio locally β fast, no network
|
| 178 |
-
shutil.copy(audio_path, saved_audio_path)
|
| 179 |
-
|
| 180 |
-
relative_audio_path = f"audio/{unique_id}.wav"
|
| 181 |
-
|
| 182 |
-
# Write metadata locally β fast, no network
|
| 183 |
-
new_row = pd.DataFrame([{
|
| 184 |
-
"id": unique_id,
|
| 185 |
-
"audio": relative_audio_path,
|
| 186 |
-
"transcription": corrected_text,
|
| 187 |
-
"language": "twi_en"
|
| 188 |
-
}])
|
| 189 |
-
|
| 190 |
-
with _csv_lock:
|
| 191 |
-
if os.path.exists(LOCAL_METADATA):
|
| 192 |
-
existing = pd.read_csv(LOCAL_METADATA)
|
| 193 |
-
updated = pd.concat([existing, new_row], ignore_index=True)
|
| 194 |
-
else:
|
| 195 |
-
updated = new_row
|
| 196 |
-
updated.to_csv(LOCAL_METADATA, index=False)
|
| 197 |
-
|
| 198 |
-
# Fire-and-forget β HuggingFace upload happens in background
|
| 199 |
-
threading.Thread(
|
| 200 |
-
target=_upload_in_background,
|
| 201 |
-
args=(saved_audio_path, relative_audio_path),
|
| 202 |
-
daemon=True
|
| 203 |
-
).start()
|
| 204 |
-
|
| 205 |
-
return
|
| 206 |
-
|
| 207 |
-
except Exception as e:
|
| 208 |
-
print(f"[Save error] {e}")
|
| 209 |
-
return
|
| 210 |
-
|
| 211 |
-
# =========================================================
|
| 212 |
-
# CUSTOM CSS (from the styled version)
|
| 213 |
-
# =========================================================
|
| 214 |
-
|
| 215 |
-
css = """
|
| 216 |
-
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;600;700&family=DM+Mono:wght@400;500&display=swap');
|
| 217 |
-
|
| 218 |
-
:root {
|
| 219 |
-
--navy: #0d1b4b;
|
| 220 |
-
--blue: #1a6fd4;
|
| 221 |
-
--sky: #4db8f0;
|
| 222 |
-
--violet: #7b4fd4;
|
| 223 |
-
--lilac: #b57bee;
|
| 224 |
-
--white: #e8f0ff;
|
| 225 |
-
--card: rgba(255,255,255,0.07);
|
| 226 |
-
--border: rgba(180,160,255,0.2);
|
| 227 |
-
--radius: 16px;
|
| 228 |
-
}
|
| 229 |
-
|
| 230 |
-
/* ββ animated mesh background ββ */
|
| 231 |
-
body, .gradio-container {
|
| 232 |
-
background:
|
| 233 |
-
radial-gradient(ellipse at 15% 10%, #1a3fa8 0%, transparent 55%),
|
| 234 |
-
radial-gradient(ellipse at 85% 5%, #7b3fc4 0%, transparent 45%),
|
| 235 |
-
radial-gradient(ellipse at 50% 50%, #d0e8ff 0%, transparent 60%),
|
| 236 |
-
radial-gradient(ellipse at 80% 80%, #b57bee 0%, transparent 50%),
|
| 237 |
-
radial-gradient(ellipse at 10% 90%, #1a6fd4 0%, transparent 50%),
|
| 238 |
-
#0d1b4b !important;
|
| 239 |
-
font-family: 'Sora', sans-serif !important;
|
| 240 |
-
min-height: 100vh;
|
| 241 |
-
}
|
| 242 |
-
|
| 243 |
-
/* ββ slow drifting orbs ββ */
|
| 244 |
-
.gradio-container::before,
|
| 245 |
-
.gradio-container::after {
|
| 246 |
-
content: '';
|
| 247 |
-
position: fixed;
|
| 248 |
-
border-radius: 50%;
|
| 249 |
-
filter: blur(80px);
|
| 250 |
-
pointer-events: none;
|
| 251 |
-
z-index: 0;
|
| 252 |
-
}
|
| 253 |
-
.gradio-container::before {
|
| 254 |
-
width: 520px; height: 520px;
|
| 255 |
-
top: -120px; left: -100px;
|
| 256 |
-
background: radial-gradient(circle, rgba(74,130,230,0.45), transparent 70%);
|
| 257 |
-
animation: drift1 12s ease-in-out infinite alternate;
|
| 258 |
-
}
|
| 259 |
-
.gradio-container::after {
|
| 260 |
-
width: 480px; height: 480px;
|
| 261 |
-
bottom: -100px; right: -80px;
|
| 262 |
-
background: radial-gradient(circle, rgba(160,100,240,0.4), transparent 70%);
|
| 263 |
-
animation: drift2 15s ease-in-out infinite alternate;
|
| 264 |
-
}
|
| 265 |
-
@keyframes drift1 {
|
| 266 |
-
from { transform: translate(0, 0); }
|
| 267 |
-
to { transform: translate(60px, 80px); }
|
| 268 |
-
}
|
| 269 |
-
@keyframes drift2 {
|
| 270 |
-
from { transform: translate(0, 0); }
|
| 271 |
-
to { transform: translate(-50px, -70px); }
|
| 272 |
-
}
|
| 273 |
-
|
| 274 |
-
/* ββ hero ββ */
|
| 275 |
-
#hero {
|
| 276 |
-
text-align: center;
|
| 277 |
-
padding: 40px 24px 16px;
|
| 278 |
-
position: relative;
|
| 279 |
-
z-index: 1;
|
| 280 |
-
animation: fadeUp 0.8s ease both;
|
| 281 |
-
}
|
| 282 |
-
@keyframes fadeUp {
|
| 283 |
-
from { opacity: 0; transform: translateY(24px); }
|
| 284 |
-
to { opacity: 1; transform: translateY(0); }
|
| 285 |
-
}
|
| 286 |
-
|
| 287 |
-
/* ββ animated orb ββ */
|
| 288 |
-
.orb-wrap {
|
| 289 |
-
display: flex;
|
| 290 |
-
justify-content: center;
|
| 291 |
-
margin-bottom: 22px;
|
| 292 |
-
}
|
| 293 |
-
.orb-stage {
|
| 294 |
-
position: relative;
|
| 295 |
-
width: 110px;
|
| 296 |
-
height: 110px;
|
| 297 |
-
}
|
| 298 |
-
.orb-ring {
|
| 299 |
-
position: absolute;
|
| 300 |
-
border-radius: 50%;
|
| 301 |
-
border: 1.5px solid transparent;
|
| 302 |
-
inset: 0;
|
| 303 |
-
animation: orbSpin 6s linear infinite;
|
| 304 |
-
}
|
| 305 |
-
.orb-ring:nth-child(1) {
|
| 306 |
-
border-top-color: #4db8f0;
|
| 307 |
-
border-right-color: rgba(77,184,240,0.25);
|
| 308 |
-
animation-duration: 5s;
|
| 309 |
-
}
|
| 310 |
-
.orb-ring:nth-child(2) {
|
| 311 |
-
inset: 8px;
|
| 312 |
-
border-top-color: #b57bee;
|
| 313 |
-
border-left-color: rgba(181,123,238,0.25);
|
| 314 |
-
animation-direction: reverse;
|
| 315 |
-
animation-duration: 7s;
|
| 316 |
-
}
|
| 317 |
-
.orb-ring:nth-child(3) {
|
| 318 |
-
inset: 16px;
|
| 319 |
-
border-top-color: #1a6fd4;
|
| 320 |
-
border-bottom-color: rgba(26,111,212,0.25);
|
| 321 |
-
animation-duration: 9s;
|
| 322 |
-
}
|
| 323 |
-
@keyframes orbSpin { to { transform: rotate(360deg); } }
|
| 324 |
-
|
| 325 |
-
.orb-core {
|
| 326 |
-
position: absolute;
|
| 327 |
-
inset: 24px;
|
| 328 |
-
border-radius: 50%;
|
| 329 |
-
background: radial-gradient(circle at 35% 35%,
|
| 330 |
-
rgba(200,220,255,0.95),
|
| 331 |
-
rgba(100,150,240,0.8) 40%,
|
| 332 |
-
rgba(90,55,200,0.9) 75%,
|
| 333 |
-
rgba(25,15,75,1)
|
| 334 |
-
);
|
| 335 |
-
box-shadow:
|
| 336 |
-
0 0 22px 6px rgba(77,184,240,0.45),
|
| 337 |
-
0 0 50px 12px rgba(120,80,220,0.28),
|
| 338 |
-
inset 0 0 14px rgba(255,255,255,0.18);
|
| 339 |
-
animation: orbBreathe 3.5s ease-in-out infinite;
|
| 340 |
-
}
|
| 341 |
-
.orb-core::after {
|
| 342 |
-
content: '';
|
| 343 |
-
position: absolute;
|
| 344 |
-
top: 14%; left: 22%;
|
| 345 |
-
width: 28%; height: 20%;
|
| 346 |
-
border-radius: 50%;
|
| 347 |
-
background: rgba(255,255,255,0.5);
|
| 348 |
-
filter: blur(3px);
|
| 349 |
-
}
|
| 350 |
-
@keyframes orbBreathe {
|
| 351 |
-
0%, 100% {
|
| 352 |
-
transform: scale(1);
|
| 353 |
-
box-shadow: 0 0 22px 6px rgba(77,184,240,0.45), 0 0 50px 12px rgba(120,80,220,0.28), inset 0 0 14px rgba(255,255,255,0.18);
|
| 354 |
-
}
|
| 355 |
-
50% {
|
| 356 |
-
transform: scale(1.1);
|
| 357 |
-
box-shadow: 0 0 34px 12px rgba(77,184,240,0.65), 0 0 70px 20px rgba(120,80,220,0.42), inset 0 0 20px rgba(255,255,255,0.28);
|
| 358 |
-
}
|
| 359 |
-
}
|
| 360 |
-
|
| 361 |
-
.orb-waves {
|
| 362 |
-
position: absolute;
|
| 363 |
-
inset: 24px;
|
| 364 |
-
border-radius: 50%;
|
| 365 |
-
display: flex;
|
| 366 |
-
align-items: center;
|
| 367 |
-
justify-content: center;
|
| 368 |
-
gap: 3px;
|
| 369 |
-
overflow: hidden;
|
| 370 |
-
}
|
| 371 |
-
.orb-wave-bar {
|
| 372 |
-
width: 3px;
|
| 373 |
-
border-radius: 99px;
|
| 374 |
-
background: rgba(255,255,255,0.75);
|
| 375 |
-
animation: waveBar 1.3s ease-in-out infinite;
|
| 376 |
-
}
|
| 377 |
-
.orb-wave-bar:nth-child(1) { height: 8px; animation-delay: 0s; }
|
| 378 |
-
.orb-wave-bar:nth-child(2) { height: 16px; animation-delay: 0.18s; }
|
| 379 |
-
.orb-wave-bar:nth-child(3) { height: 22px; animation-delay: 0.35s; }
|
| 380 |
-
.orb-wave-bar:nth-child(4) { height: 16px; animation-delay: 0.52s; }
|
| 381 |
-
.orb-wave-bar:nth-child(5) { height: 8px; animation-delay: 0.7s; }
|
| 382 |
-
@keyframes waveBar {
|
| 383 |
-
0%, 100% { transform: scaleY(0.3); opacity: 0.45; }
|
| 384 |
-
50% { transform: scaleY(1); opacity: 1; }
|
| 385 |
-
}
|
| 386 |
-
|
| 387 |
-
/* ββ title & subtitle ββ */
|
| 388 |
-
.kasa-title {
|
| 389 |
-
font-size: clamp(2.4rem, 7vw, 4rem);
|
| 390 |
-
font-weight: 700;
|
| 391 |
-
letter-spacing: -0.03em;
|
| 392 |
-
background: linear-gradient(120deg, var(--white) 0%, var(--sky) 40%, var(--lilac) 100%);
|
| 393 |
-
-webkit-background-clip: text;
|
| 394 |
-
-webkit-text-fill-color: transparent;
|
| 395 |
-
background-clip: text;
|
| 396 |
-
margin: 0 0 10px;
|
| 397 |
-
line-height: 1.1;
|
| 398 |
-
}
|
| 399 |
-
.kasa-sub {
|
| 400 |
-
font-size: 0.97rem;
|
| 401 |
-
font-weight: 300;
|
| 402 |
-
color: rgba(220,230,255,0.85);
|
| 403 |
-
max-width: 460px;
|
| 404 |
-
margin: 0 auto 14px;
|
| 405 |
-
line-height: 1.65;
|
| 406 |
-
}
|
| 407 |
-
.kasa-badge {
|
| 408 |
-
display: inline-flex;
|
| 409 |
-
align-items: center;
|
| 410 |
-
gap: 6px;
|
| 411 |
-
padding: 5px 16px;
|
| 412 |
-
border-radius: 999px;
|
| 413 |
-
border: 1px solid rgba(180,160,255,0.3);
|
| 414 |
-
background: rgba(120,100,220,0.12);
|
| 415 |
-
font-size: 0.7rem;
|
| 416 |
-
font-weight: 500;
|
| 417 |
-
letter-spacing: 0.13em;
|
| 418 |
-
text-transform: uppercase;
|
| 419 |
-
color: var(--lilac);
|
| 420 |
-
backdrop-filter: blur(8px);
|
| 421 |
-
}
|
| 422 |
-
|
| 423 |
-
/* ββ divider ββ */
|
| 424 |
-
.kasa-divider {
|
| 425 |
-
border: none;
|
| 426 |
-
border-top: 1px solid var(--border);
|
| 427 |
-
margin: 10px 0 28px;
|
| 428 |
-
position: relative;
|
| 429 |
-
z-index: 1;
|
| 430 |
-
}
|
| 431 |
-
|
| 432 |
-
/* ββ panel labels ββ */
|
| 433 |
-
.kasa-label {
|
| 434 |
-
font-size: 0.7rem;
|
| 435 |
-
font-weight: 600;
|
| 436 |
-
letter-spacing: 0.14em;
|
| 437 |
-
text-transform: uppercase;
|
| 438 |
-
color: #a8d4f8;
|
| 439 |
-
margin-bottom: 10px;
|
| 440 |
-
}
|
| 441 |
-
|
| 442 |
-
/* ββ Gradio field labels ββ */
|
| 443 |
-
label, .gr-form label, .svelte-1gfkn6j {
|
| 444 |
-
color: #c8d8f8 !important;
|
| 445 |
-
font-family: 'Sora', sans-serif !important;
|
| 446 |
-
font-size: 0.82rem !important;
|
| 447 |
-
font-weight: 500 !important;
|
| 448 |
-
}
|
| 449 |
-
|
| 450 |
-
/* ββ WHITE audio widget ββ */
|
| 451 |
-
.gr-audio,
|
| 452 |
-
[data-testid="audio"],
|
| 453 |
-
.gr-audio > div {
|
| 454 |
-
background: #ffffff !important;
|
| 455 |
-
border: 1.5px solid rgba(100,140,240,0.4) !important;
|
| 456 |
-
border-radius: 14px !important;
|
| 457 |
-
box-shadow: 0 4px 28px rgba(26,60,180,0.14) !important;
|
| 458 |
-
overflow: hidden !important;
|
| 459 |
-
}
|
| 460 |
-
|
| 461 |
-
[data-testid="audio"] button,
|
| 462 |
-
.gr-audio button {
|
| 463 |
-
color: #1a6fd4 !important;
|
| 464 |
-
background: transparent !important;
|
| 465 |
-
}
|
| 466 |
-
[data-testid="audio"] svg,
|
| 467 |
-
.gr-audio svg {
|
| 468 |
-
stroke: #1a6fd4 !important;
|
| 469 |
-
fill: none !important;
|
| 470 |
-
}
|
| 471 |
-
[data-testid="audio"] span,
|
| 472 |
-
[data-testid="audio"] .time,
|
| 473 |
-
[data-testid="audio"] .duration,
|
| 474 |
-
.gr-audio span {
|
| 475 |
-
color: #1a3fa8 !important;
|
| 476 |
-
font-family: 'DM Mono', monospace !important;
|
| 477 |
-
}
|
| 478 |
-
[data-testid="audio"] canvas,
|
| 479 |
-
.gr-audio canvas {
|
| 480 |
-
filter: hue-rotate(195deg) saturate(2) brightness(0.85) !important;
|
| 481 |
-
}
|
| 482 |
-
[data-testid="audio"] .tabs button,
|
| 483 |
-
.gr-audio .tabs button {
|
| 484 |
-
color: #1a6fd4 !important;
|
| 485 |
-
font-family: 'Sora', sans-serif !important;
|
| 486 |
-
font-weight: 600 !important;
|
| 487 |
-
}
|
| 488 |
-
[data-testid="audio"] .tabs button.selected,
|
| 489 |
-
.gr-audio .tabs button.selected {
|
| 490 |
-
border-bottom: 2px solid #1a6fd4 !important;
|
| 491 |
-
}
|
| 492 |
-
|
| 493 |
-
/* ββ WHITE textbox ββ */
|
| 494 |
-
textarea, .gr-textbox textarea {
|
| 495 |
-
background: #ffffff !important;
|
| 496 |
-
border: 1.5px solid rgba(100,140,240,0.4) !important;
|
| 497 |
-
border-radius: 12px !important;
|
| 498 |
-
color: #0d1b6e !important;
|
| 499 |
-
font-family: 'Sora', sans-serif !important;
|
| 500 |
-
font-size: 0.95rem !important;
|
| 501 |
-
font-weight: 400 !important;
|
| 502 |
-
padding: 14px !important;
|
| 503 |
-
box-shadow: 0 4px 24px rgba(26,60,180,0.1) !important;
|
| 504 |
-
transition: border-color 0.2s, box-shadow 0.2s !important;
|
| 505 |
-
line-height: 1.75 !important;
|
| 506 |
-
letter-spacing: 0.01em !important;
|
| 507 |
-
}
|
| 508 |
-
textarea::placeholder {
|
| 509 |
-
color: #7a9acc !important;
|
| 510 |
-
font-style: italic;
|
| 511 |
-
font-family: 'Sora', sans-serif !important;
|
| 512 |
-
}
|
| 513 |
-
textarea:focus {
|
| 514 |
-
border-color: #4db8f0 !important;
|
| 515 |
-
box-shadow: 0 0 0 3px rgba(77,184,240,0.2) !important;
|
| 516 |
-
outline: none !important;
|
| 517 |
-
}
|
| 518 |
-
.gr-textbox, [data-testid="textbox"] {
|
| 519 |
-
background: #ffffff !important;
|
| 520 |
-
border: 1.5px solid rgba(100,140,240,0.4) !important;
|
| 521 |
-
border-radius: 14px !important;
|
| 522 |
-
box-shadow: 0 4px 28px rgba(26,60,180,0.14) !important;
|
| 523 |
-
overflow: hidden !important;
|
| 524 |
-
}
|
| 525 |
-
|
| 526 |
-
/* ββ Edit hint text ββ */
|
| 527 |
-
.edit-hint {
|
| 528 |
-
font-size: 0.75rem;
|
| 529 |
-
font-weight: 300;
|
| 530 |
-
color: rgba(200,215,255,0.6);
|
| 531 |
-
margin-top: -6px;
|
| 532 |
-
margin-bottom: 8px;
|
| 533 |
-
font-style: italic;
|
| 534 |
-
letter-spacing: 0.02em;
|
| 535 |
-
}
|
| 536 |
-
|
| 537 |
-
/* ββ Buttons ββ */
|
| 538 |
-
.gr-button-primary, button.primary {
|
| 539 |
-
background: linear-gradient(135deg, #1a6fd4 0%, #7b4fd4 100%) !important;
|
| 540 |
-
border: none !important;
|
| 541 |
-
border-radius: 10px !important;
|
| 542 |
-
font-family: 'Sora', sans-serif !important;
|
| 543 |
-
font-weight: 600 !important;
|
| 544 |
-
font-size: 0.9rem !important;
|
| 545 |
-
padding: 12px 28px !important;
|
| 546 |
-
color: #ffffff !important;
|
| 547 |
-
transition: transform 0.15s, box-shadow 0.15s !important;
|
| 548 |
-
box-shadow: 0 4px 22px rgba(100,80,200,0.4) !important;
|
| 549 |
-
position: relative;
|
| 550 |
-
z-index: 1;
|
| 551 |
-
}
|
| 552 |
-
.gr-button-primary:hover, button.primary:hover {
|
| 553 |
-
transform: translateY(-2px) !important;
|
| 554 |
-
box-shadow: 0 8px 32px rgba(120,80,220,0.55) !important;
|
| 555 |
-
}
|
| 556 |
-
.gr-button-primary:active, button.primary:active {
|
| 557 |
-
transform: translateY(0) !important;
|
| 558 |
-
}
|
| 559 |
-
|
| 560 |
-
/* ββ Save checkmark button ββ */
|
| 561 |
-
#save-btn button {
|
| 562 |
-
width: 52px !important;
|
| 563 |
-
height: 52px !important;
|
| 564 |
-
min-width: 52px !important;
|
| 565 |
-
border-radius: 50% !important;
|
| 566 |
-
padding: 0 !important;
|
| 567 |
-
font-size: 1.5rem !important;
|
| 568 |
-
background: linear-gradient(135deg, #1a6fd4 0%, #7b4fd4 100%) !important;
|
| 569 |
-
border: none !important;
|
| 570 |
-
box-shadow: 0 4px 22px rgba(100,80,200,0.4) !important;
|
| 571 |
-
color: #fff !important;
|
| 572 |
-
transition: transform 0.15s, box-shadow 0.15s !important;
|
| 573 |
-
line-height: 1 !important;
|
| 574 |
-
}
|
| 575 |
-
#save-btn button:hover {
|
| 576 |
-
transform: scale(1.12) translateY(-2px) !important;
|
| 577 |
-
box-shadow: 0 8px 32px rgba(120,80,220,0.55) !important;
|
| 578 |
-
}
|
| 579 |
-
#save-btn button:active {
|
| 580 |
-
transform: scale(0.96) !important;
|
| 581 |
-
}
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
/* ββ footer ββ */
|
| 585 |
-
.kasa-footer {
|
| 586 |
-
text-align: center;
|
| 587 |
-
font-size: 0.72rem;
|
| 588 |
-
color: rgba(180,190,255,0.58);
|
| 589 |
-
padding: 24px 0 32px;
|
| 590 |
-
letter-spacing: 0.05em;
|
| 591 |
-
position: relative;
|
| 592 |
-
z-index: 1;
|
| 593 |
-
}
|
| 594 |
-
|
| 595 |
-
/* ββ pulse dot ββ */
|
| 596 |
-
.pulse-dot {
|
| 597 |
-
display: inline-block;
|
| 598 |
-
width: 9px; height: 9px;
|
| 599 |
-
border-radius: 50%;
|
| 600 |
-
background: #ffffff;
|
| 601 |
-
box-shadow: 0 0 6px 2px rgba(255,255,255,0.6);
|
| 602 |
-
animation: pulse 2s ease-in-out infinite;
|
| 603 |
-
}
|
| 604 |
-
@keyframes pulse {
|
| 605 |
-
0%, 100% { opacity: 1; transform: scale(1); }
|
| 606 |
-
50% { opacity: 0.3; transform: scale(0.65); }
|
| 607 |
-
}
|
| 608 |
-
"""
|
| 609 |
-
|
| 610 |
-
# =========================================================
|
| 611 |
-
# UI
|
| 612 |
-
# =========================================================
|
| 613 |
-
|
| 614 |
-
with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
| 615 |
-
|
| 616 |
-
# ββ Hero ββ
|
| 617 |
-
gr.HTML("""
|
| 618 |
-
<div id="hero">
|
| 619 |
-
<div class="orb-wrap">
|
| 620 |
-
<div class="orb-stage">
|
| 621 |
-
<div class="orb-ring"></div>
|
| 622 |
-
<div class="orb-ring"></div>
|
| 623 |
-
<div class="orb-ring"></div>
|
| 624 |
-
<div class="orb-core"></div>
|
| 625 |
-
<div class="orb-waves">
|
| 626 |
-
<div class="orb-wave-bar"></div>
|
| 627 |
-
<div class="orb-wave-bar"></div>
|
| 628 |
-
<div class="orb-wave-bar"></div>
|
| 629 |
-
<div class="orb-wave-bar"></div>
|
| 630 |
-
<div class="orb-wave-bar"></div>
|
| 631 |
-
</div>
|
| 632 |
-
</div>
|
| 633 |
-
</div>
|
| 634 |
-
<div class="kasa-title">Kasanoma ASR</div>
|
| 635 |
-
<div class="kasa-sub">
|
| 636 |
-
Automatic speech recognition for natural EnglishβTwi
|
| 637 |
-
code-switched conversations. Speak the way you actually speak.
|
| 638 |
-
</div>
|
| 639 |
-
<span class="kasa-badge"><span class="pulse-dot"></span>Live Transcription</span>
|
| 640 |
-
</div>
|
| 641 |
-
""")
|
| 642 |
-
|
| 643 |
-
# ββ Main columns ββ
|
| 644 |
-
with gr.Row(equal_height=True):
|
| 645 |
-
|
| 646 |
-
with gr.Column(scale=1):
|
| 647 |
-
gr.HTML('<div class="kasa-label">Audio Input</div>')
|
| 648 |
-
audio_input = gr.Audio(
|
| 649 |
-
sources=["microphone", "upload"],
|
| 650 |
-
type="filepath",
|
| 651 |
-
label="Record or upload audio"
|
| 652 |
-
)
|
| 653 |
-
transcribe_btn = gr.Button("Transcribe β", variant="primary")
|
| 654 |
-
|
| 655 |
-
with gr.Column(scale=1):
|
| 656 |
-
gr.HTML('<div class="kasa-label">Transcription</div>')
|
| 657 |
-
model_output = gr.Textbox(
|
| 658 |
-
label="",
|
| 659 |
-
placeholder="Transcription will appear hereβ¦",
|
| 660 |
-
lines=3,
|
| 661 |
-
interactive=False
|
| 662 |
-
)
|
| 663 |
-
gr.HTML('<div class="kasa-label" style="margin-top:14px;">Edit</div>')
|
| 664 |
-
gr.HTML('<div class="edit-hint">Type what was actually said β fix any errors the model made, then hit β to save.</div>')
|
| 665 |
-
with gr.Row(equal_height=True):
|
| 666 |
-
corrected_output = gr.Textbox(
|
| 667 |
-
label="",
|
| 668 |
-
placeholder="Correct the transcription if neededβ¦",
|
| 669 |
-
lines=3,
|
| 670 |
-
scale=9
|
| 671 |
-
)
|
| 672 |
-
save_btn = gr.Button("β", elem_id="save-btn", scale=1)
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
hidden_audio_path = gr.State()
|
| 676 |
-
|
| 677 |
-
# ββ Footer ββ
|
| 678 |
-
gr.HTML("""
|
| 679 |
-
<div class="kasa-footer">
|
| 680 |
-
Kasanoma · English–Twi Code-Switching ASR · Project Kasa 2026
|
| 681 |
-
</div>
|
| 682 |
-
""")
|
| 683 |
-
|
| 684 |
-
# ββ Event handlers ββ
|
| 685 |
-
transcribe_btn.click(
|
| 686 |
-
fn=transcribe_audio,
|
| 687 |
-
inputs=audio_input,
|
| 688 |
-
outputs=[model_output, corrected_output, hidden_audio_path]
|
| 689 |
-
)
|
| 690 |
-
|
| 691 |
-
save_btn.click(
|
| 692 |
-
fn=save_sample,
|
| 693 |
-
inputs=[hidden_audio_path, corrected_output]
|
| 694 |
-
)
|
| 695 |
-
|
| 696 |
-
# =========================================================
|
| 697 |
-
# LAUNCH
|
| 698 |
-
# =========================================================
|
| 699 |
-
|
| 700 |
-
if __name__ == "__main__":
|
| 701 |
-
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/gen.png
ADDED
|
assets/logo.png
ADDED
|
main.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
| 1 |
from api import app
|
|
|
|
| 2 |
|
|
|
|
| 3 |
__all__ = ["app"]
|
|
|
|
| 1 |
from api import app
|
| 2 |
+
from fastapi.staticfiles import StaticFiles
|
| 3 |
|
| 4 |
+
app.mount("/assets", StaticFiles(directory="assets"), name="assets")
|
| 5 |
__all__ = ["app"]
|
requirements.txt
CHANGED
|
@@ -8,4 +8,5 @@ datasets>=3.2.0
|
|
| 8 |
torch>=2.0.0
|
| 9 |
torchaudio>=2.0.0
|
| 10 |
librosa>=0.9.2
|
| 11 |
-
python-dotenv>=0.19.0
|
|
|
|
|
|
| 8 |
torch>=2.0.0
|
| 9 |
torchaudio>=2.0.0
|
| 10 |
librosa>=0.9.2
|
| 11 |
+
python-dotenv>=0.19.0
|
| 12 |
+
gradio>=3.38.0
|
static/index.html
CHANGED
|
@@ -13,16 +13,16 @@
|
|
| 13 |
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
| 14 |
|
| 15 |
:root {
|
| 16 |
-
--bg: #
|
| 17 |
-
--surface: #
|
| 18 |
--card: #ffffff;
|
| 19 |
-
--border: rgba(
|
| 20 |
-
--border-md: rgba(
|
| 21 |
-
--text: #
|
| 22 |
-
--muted: #
|
| 23 |
-
--hint: #
|
| 24 |
--accent: #2a5c45;
|
| 25 |
-
--accent-bg:#
|
| 26 |
--red: #c0392b;
|
| 27 |
--red-bg: #fdf0ee;
|
| 28 |
--font-serif: 'Instrument Serif', Georgia, serif;
|
|
@@ -37,7 +37,12 @@
|
|
| 37 |
|
| 38 |
body {
|
| 39 |
font-family: var(--font-sans);
|
| 40 |
-
background:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
color: var(--text);
|
| 42 |
min-height: 100vh;
|
| 43 |
display: flex;
|
|
@@ -90,6 +95,12 @@
|
|
| 90 |
}
|
| 91 |
/* ββ Hero ββ */
|
| 92 |
.hero { margin-bottom: 36px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
.lang-tag {
|
| 94 |
display: inline-flex;
|
| 95 |
align-items: center;
|
|
@@ -382,11 +393,34 @@
|
|
| 382 |
display: flex;
|
| 383 |
align-items: center;
|
| 384 |
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
}
|
| 386 |
.footer-copy { font-size: 0.72rem; color: var(--hint); }
|
| 387 |
.footer-links { display: flex; gap: 18px; }
|
| 388 |
.footer-links a { font-size: 0.72rem; color: var(--hint); text-decoration: none; transition: color 0.2s; }
|
| 389 |
.footer-links a:hover { color: var(--muted); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
|
| 391 |
/* ββ Toast ββ */
|
| 392 |
.toast {
|
|
@@ -413,12 +447,73 @@
|
|
| 413 |
@keyframes blink { 0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.55)} }
|
| 414 |
@keyframes rot { to { transform: rotate(360deg); } }
|
| 415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
@media (max-width: 520px) {
|
| 417 |
body { padding: 28px 14px 60px; }
|
| 418 |
.stats { grid-template-columns: 1fr 1fr; }
|
| 419 |
.stats .stat:last-child { grid-column: span 2; }
|
| 420 |
.nav { display: none; }
|
| 421 |
.footer { flex-direction: column; gap: 10px; }
|
|
|
|
|
|
|
| 422 |
}
|
| 423 |
</style>
|
| 424 |
</head>
|
|
@@ -426,14 +521,16 @@
|
|
| 426 |
|
| 427 |
<div class="page">
|
| 428 |
|
| 429 |
-
<
|
| 430 |
-
<
|
| 431 |
-
|
| 432 |
-
<
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
|
|
|
|
|
|
| 437 |
|
| 438 |
<div class="hero">
|
| 439 |
<div class="lang-tag"><i class="ti ti-language" aria-hidden="true"></i>English Β· Twi code-switching</div>
|
|
@@ -499,7 +596,8 @@
|
|
| 499 |
</button>
|
| 500 |
</div>
|
| 501 |
</div>
|
| 502 |
-
|
|
|
|
| 503 |
<div class="sec">
|
| 504 |
<div class="sec-label">Correct & save</div>
|
| 505 |
<p class="edit-hint">Fix any errors β your correction helps improve the model.</p>
|
|
@@ -511,10 +609,11 @@
|
|
| 511 |
<button class="disc-btn" id="disc-btn">Discard</button>
|
| 512 |
</div>
|
| 513 |
</div>
|
|
|
|
| 514 |
|
| 515 |
-
</div>
|
| 516 |
|
| 517 |
-
<div class="stats">
|
| 518 |
<div class="stat">
|
| 519 |
<div class="stat-v" id="stat-saved">0</div>
|
| 520 |
<div class="stat-l">Saved</div>
|
|
@@ -527,14 +626,20 @@
|
|
| 527 |
<div class="stat-v" style="font-size:1.1rem;font-style:normal;font-family:var(--font-sans);font-weight:500;padding-top:4px;">Twi Β· EN</div>
|
| 528 |
<div class="stat-l">Language</div>
|
| 529 |
</div>
|
| 530 |
-
</div>
|
| 531 |
|
| 532 |
<footer class="footer">
|
| 533 |
-
<
|
| 534 |
-
|
| 535 |
-
<
|
| 536 |
-
|
| 537 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 538 |
</div>
|
| 539 |
</footer>
|
| 540 |
|
|
@@ -697,38 +802,40 @@
|
|
| 697 |
if (t) navigator.clipboard.writeText(t).then(() => toast('Copied', 'ok'));
|
| 698 |
});
|
| 699 |
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
}
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
//
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
|
|
|
|
|
|
| 732 |
</script>
|
| 733 |
</body>
|
| 734 |
</html>
|
|
|
|
| 13 |
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
| 14 |
|
| 15 |
:root {
|
| 16 |
+
--bg: #f4faf6;
|
| 17 |
+
--surface: #fbfdfc;
|
| 18 |
--card: #ffffff;
|
| 19 |
+
--border: rgba(42,92,69,0.10);
|
| 20 |
+
--border-md: rgba(42,92,69,0.18);
|
| 21 |
+
--text: #16261f;
|
| 22 |
+
--muted: #5f7a6c;
|
| 23 |
+
--hint: #9db3a6;
|
| 24 |
--accent: #2a5c45;
|
| 25 |
+
--accent-bg:#e8f5ee;
|
| 26 |
--red: #c0392b;
|
| 27 |
--red-bg: #fdf0ee;
|
| 28 |
--font-serif: 'Instrument Serif', Georgia, serif;
|
|
|
|
| 37 |
|
| 38 |
body {
|
| 39 |
font-family: var(--font-sans);
|
| 40 |
+
background:
|
| 41 |
+
radial-gradient(ellipse 900px 600px at 12% 0%, rgba(154,211,181,0.35), transparent 60%),
|
| 42 |
+
radial-gradient(ellipse 900px 650px at 100% 15%, rgba(210,235,220,0.55), transparent 65%),
|
| 43 |
+
radial-gradient(ellipse 800px 700px at 50% 100%, rgba(180,220,197,0.30), transparent 60%),
|
| 44 |
+
linear-gradient(180deg, #ffffff 0%, #f2f9f5 45%, #eaf6ef 100%);
|
| 45 |
+
background-attachment: fixed;
|
| 46 |
color: var(--text);
|
| 47 |
min-height: 100vh;
|
| 48 |
display: flex;
|
|
|
|
| 95 |
}
|
| 96 |
/* ββ Hero ββ */
|
| 97 |
.hero { margin-bottom: 36px; }
|
| 98 |
+
.hero-logo {
|
| 99 |
+
height: 44px;
|
| 100 |
+
width: auto;
|
| 101 |
+
margin-bottom: 16px;
|
| 102 |
+
display: block;
|
| 103 |
+
}
|
| 104 |
.lang-tag {
|
| 105 |
display: inline-flex;
|
| 106 |
align-items: center;
|
|
|
|
| 393 |
display: flex;
|
| 394 |
align-items: center;
|
| 395 |
justify-content: space-between;
|
| 396 |
+
margin-top: 8px;
|
| 397 |
+
padding-top: 8px;
|
| 398 |
+
}
|
| 399 |
+
.footer-content {
|
| 400 |
+
display: flex;
|
| 401 |
+
align-items: center;
|
| 402 |
+
gap: 24px;
|
| 403 |
}
|
| 404 |
.footer-copy { font-size: 0.72rem; color: var(--hint); }
|
| 405 |
.footer-links { display: flex; gap: 18px; }
|
| 406 |
.footer-links a { font-size: 0.72rem; color: var(--hint); text-decoration: none; transition: color 0.2s; }
|
| 407 |
.footer-links a:hover { color: var(--muted); }
|
| 408 |
+
.footer-logos {
|
| 409 |
+
display: flex;
|
| 410 |
+
gap: 12px;
|
| 411 |
+
align-items: center;
|
| 412 |
+
}
|
| 413 |
+
.footer-logo {
|
| 414 |
+
height: 72px;
|
| 415 |
+
width: 72px;
|
| 416 |
+
border-radius: 10%;
|
| 417 |
+
background: var(--surface);
|
| 418 |
+
transition: transform 0.2s ease, border-color 0.2s ease;
|
| 419 |
+
}
|
| 420 |
+
.footer-logo:hover {
|
| 421 |
+
transform: scale(1.08);
|
| 422 |
+
border-color: var(--accent);
|
| 423 |
+
}
|
| 424 |
|
| 425 |
/* ββ Toast ββ */
|
| 426 |
.toast {
|
|
|
|
| 447 |
@keyframes blink { 0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.55)} }
|
| 448 |
@keyframes rot { to { transform: rotate(360deg); } }
|
| 449 |
|
| 450 |
+
/* ββ Header Logo Section ββ */
|
| 451 |
+
.header-logo-section {
|
| 452 |
+
display: flex;
|
| 453 |
+
align-items: center;
|
| 454 |
+
justify-content: space-between;
|
| 455 |
+
padding: 20px 0 24px;
|
| 456 |
+
margin-bottom: 28px;
|
| 457 |
+
animation: slideDown 0.5s ease;
|
| 458 |
+
}
|
| 459 |
+
.header-logo-container {
|
| 460 |
+
display: flex;
|
| 461 |
+
align-items: center;
|
| 462 |
+
gap: 16px;
|
| 463 |
+
}
|
| 464 |
+
.header-logo-container img {
|
| 465 |
+
height: 64px;
|
| 466 |
+
width: auto;
|
| 467 |
+
transition: transform 0.3s ease;
|
| 468 |
+
}
|
| 469 |
+
.header-logo-container img:hover {
|
| 470 |
+
transform: scale(1.06);
|
| 471 |
+
}
|
| 472 |
+
.header-title {
|
| 473 |
+
font-family: var(--font-serif);
|
| 474 |
+
font-size: 1.15rem;
|
| 475 |
+
font-weight: 400;
|
| 476 |
+
color: var(--text);
|
| 477 |
+
letter-spacing: -0.01em;
|
| 478 |
+
}
|
| 479 |
+
.header-nav {
|
| 480 |
+
display: flex;
|
| 481 |
+
gap: 16px;
|
| 482 |
+
align-items: center;
|
| 483 |
+
}
|
| 484 |
+
.header-nav-link {
|
| 485 |
+
display: inline-flex;
|
| 486 |
+
align-items: center;
|
| 487 |
+
gap: 5px;
|
| 488 |
+
padding: 7px 12px;
|
| 489 |
+
border-radius: 6px;
|
| 490 |
+
border: 1px solid var(--border);
|
| 491 |
+
background: var(--accent-bg);
|
| 492 |
+
color: var(--accent);
|
| 493 |
+
text-decoration: none;
|
| 494 |
+
font-size: 0.8rem;
|
| 495 |
+
font-weight: 500;
|
| 496 |
+
transition: all 0.2s ease;
|
| 497 |
+
font-family: var(--font-sans);
|
| 498 |
+
}
|
| 499 |
+
.header-nav-link:hover {
|
| 500 |
+
border-color: var(--accent);
|
| 501 |
+
background: rgba(42, 92, 69, 0.15);
|
| 502 |
+
color: var(--text);
|
| 503 |
+
}
|
| 504 |
+
@keyframes slideDown {
|
| 505 |
+
from { opacity: 0; transform: translateY(-12px); }
|
| 506 |
+
to { opacity: 1; transform: translateY(0); }
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
@media (max-width: 520px) {
|
| 510 |
body { padding: 28px 14px 60px; }
|
| 511 |
.stats { grid-template-columns: 1fr 1fr; }
|
| 512 |
.stats .stat:last-child { grid-column: span 2; }
|
| 513 |
.nav { display: none; }
|
| 514 |
.footer { flex-direction: column; gap: 10px; }
|
| 515 |
+
.header-nav { gap: 10px; }
|
| 516 |
+
.header-nav-link { font-size: 0.75rem; padding: 6px 10px; }
|
| 517 |
}
|
| 518 |
</style>
|
| 519 |
</head>
|
|
|
|
| 521 |
|
| 522 |
<div class="page">
|
| 523 |
|
| 524 |
+
<div class="header-logo-section">
|
| 525 |
+
<div class="header-logo-container">
|
| 526 |
+
<img src="/assets/logo.png" alt="Kasanoma logo" />
|
| 527 |
+
<div class="header-title">Kasanoma</div>
|
| 528 |
+
</div>
|
| 529 |
+
<div class="header-nav">
|
| 530 |
+
<a href="https://huggingface.co/datasets/Kennethdot/Ghana_English-Twi_Code-switching_ASR" class="header-nav-link">Docs</a>
|
| 531 |
+
<a href="https://github.com/Kennethdotse/project-kasa" class="header-nav-link">GitHub</a>
|
| 532 |
+
</div>
|
| 533 |
+
</div>
|
| 534 |
|
| 535 |
<div class="hero">
|
| 536 |
<div class="lang-tag"><i class="ti ti-language" aria-hidden="true"></i>English Β· Twi code-switching</div>
|
|
|
|
| 596 |
</button>
|
| 597 |
</div>
|
| 598 |
</div>
|
| 599 |
+
|
| 600 |
+
<!-- COMMENTED OUT: Correct & save section
|
| 601 |
<div class="sec">
|
| 602 |
<div class="sec-label">Correct & save</div>
|
| 603 |
<p class="edit-hint">Fix any errors β your correction helps improve the model.</p>
|
|
|
|
| 609 |
<button class="disc-btn" id="disc-btn">Discard</button>
|
| 610 |
</div>
|
| 611 |
</div>
|
| 612 |
+
-->
|
| 613 |
|
| 614 |
+
</div>
|
| 615 |
|
| 616 |
+
<!-- <div class="stats">
|
| 617 |
<div class="stat">
|
| 618 |
<div class="stat-v" id="stat-saved">0</div>
|
| 619 |
<div class="stat-l">Saved</div>
|
|
|
|
| 626 |
<div class="stat-v" style="font-size:1.1rem;font-style:normal;font-family:var(--font-sans);font-weight:500;padding-top:4px;">Twi Β· EN</div>
|
| 627 |
<div class="stat-l">Language</div>
|
| 628 |
</div>
|
| 629 |
+
</div> -->
|
| 630 |
|
| 631 |
<footer class="footer">
|
| 632 |
+
<div class="footer-content">
|
| 633 |
+
<span class="footer-copy">Project Kasa Β· 2026</span>
|
| 634 |
+
<div class="footer-links">
|
| 635 |
+
<a href="#">Privacy</a>
|
| 636 |
+
<a href="#">Terms</a>
|
| 637 |
+
<a href="#">Contact</a>
|
| 638 |
+
</div>
|
| 639 |
+
</div>
|
| 640 |
+
<div class="footer-logos">
|
| 641 |
+
<img src="/assets/logo.png" alt="Kasanoma logo" class="footer-logo" />
|
| 642 |
+
<img src="/assets/gen.png" alt="Gen logo" class="footer-logo" />
|
| 643 |
</div>
|
| 644 |
</footer>
|
| 645 |
|
|
|
|
| 802 |
if (t) navigator.clipboard.writeText(t).then(() => toast('Copied', 'ok'));
|
| 803 |
});
|
| 804 |
|
| 805 |
+
// COMMENTED OUT: Save to dataset functionality
|
| 806 |
+
// $('save-btn').addEventListener('click', async () => {
|
| 807 |
+
// const text = $('edit-ta').value.trim();
|
| 808 |
+
// if (!text) { toast('Nothing to save.', 'err'); return; }
|
| 809 |
+
// if (!audioBlob) { toast('No audio attached.', 'err'); return; }
|
| 810 |
+
// const btn = $('save-btn'); btn.disabled = true;
|
| 811 |
+
// try {
|
| 812 |
+
// const fd = new FormData();
|
| 813 |
+
// fd.append('audio', audioBlob, audioBlob.name || 'audio.webm');
|
| 814 |
+
// fd.append('transcription', text);
|
| 815 |
+
// const res = await fetch('/save', { method: 'POST', body: fd });
|
| 816 |
+
// if (!res.ok) throw new Error(`Server error ${res.status}`);
|
| 817 |
+
// saved++; $('stat-saved').textContent = saved;
|
| 818 |
+
// btn.classList.add('saved');
|
| 819 |
+
// setTimeout(() => btn.classList.remove('saved'), 2000);
|
| 820 |
+
// toast('Saved to dataset', 'ok');
|
| 821 |
+
// } catch (err) {
|
| 822 |
+
// toast('Save failed: ' + err.message, 'err');
|
| 823 |
+
// } finally { btn.disabled = false; }
|
| 824 |
+
// });
|
| 825 |
+
|
| 826 |
+
// COMMENTED OUT: Discard transcription
|
| 827 |
+
// $('disc-btn').addEventListener('click', () => {
|
| 828 |
+
// $('edit-ta').value = '';
|
| 829 |
+
// $('out').classList.remove('has');
|
| 830 |
+
// $('out-txt').textContent = '';
|
| 831 |
+
// toast('Cleared');
|
| 832 |
+
// });
|
| 833 |
+
|
| 834 |
+
// COMMENTED OUT: Load real saved count from backend on page load
|
| 835 |
+
// fetch('/dataset/stats')
|
| 836 |
+
// .then(r => r.json())
|
| 837 |
+
// .then(d => { if (d.total) { saved = d.total; $('stat-saved').textContent = saved; } })
|
| 838 |
+
// .catch(() => {});
|
| 839 |
</script>
|
| 840 |
</body>
|
| 841 |
</html>
|