Alicehy commited on
Commit
fae9682
·
1 Parent(s): f81c461

use /tmp cache

Browse files
Files changed (1) hide show
  1. public/index.html +108 -18
public/index.html CHANGED
@@ -1,18 +1,108 @@
1
- <!doctype html><meta charset="utf-8"><title>Borôro TTS</title>
2
- <textarea id="t" rows="3" style="width:100%">Aru ebaradoge iwadure boe...</textarea>
3
- <button id="go">Convert</button>
4
- <audio id="aud" controls></audio>
5
- <script>
6
- document.getElementById('go').onclick = async () => {
7
- const text = document.getElementById('t').value;
8
- const r = await fetch('/api/tts', {
9
- method:'POST',
10
- headers:{'Content-Type':'application/json'},
11
- body: JSON.stringify({ text: document.getElementById('t').value })
12
- });
13
- const b = await r.blob();
14
- const url = URL.createObjectURL(b);
15
- const a = document.getElementById('aud');
16
- a.src = url; a.play();
17
- };
18
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <title>Borôro TTS</title>
7
+ <style>
8
+ :root { --bg:#f1f3f4; --card:#fff; --text:#202124; --muted:#5f6368; --primary:#1a73e8; --primary-hover:#1765c1; }
9
+ *{box-sizing:border-box} body{margin:0;background:var(--bg);color:var(--text);font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu}
10
+ .wrap{max-width:820px;margin:40px auto;padding:0 16px}
11
+ .card{background:var(--card);border-radius:16px;box-shadow:0 2px 8px rgba(0,0,0,.08)}
12
+ .head{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #e6e8eb}
13
+ .title{font-weight:600}
14
+ .muted{color:var(--muted);font-size:14px}
15
+ .body{padding:20px}
16
+ label{display:block;font-size:14px;color:var(--muted);margin:0 0 6px}
17
+ textarea{width:100%;min-height:140px;resize:vertical;border:1px solid #dadce0;border-radius:12px;padding:12px;outline:none}
18
+ textarea:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(26,115,232,.12)}
19
+ .row{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:14px}
20
+ button{border:0;border-radius:10px;padding:10px 16px;cursor:pointer;font-weight:600}
21
+ .primary{background:var(--primary);color:#fff}
22
+ .primary:disabled{opacity:.6;cursor:not-allowed}
23
+ .primary:not(:disabled):hover{background:var(--primary-hover)}
24
+ .ghost{background:#eef3fe;color:var(--primary)}
25
+ .counter{margin-left:auto;color:var(--muted);font-size:13px}
26
+ .status{margin-top:10px;height:20px;color:var(--muted);font-size:14px}
27
+ .audio{margin-top:10px}
28
+ .spinner{width:16px;height:16px;border:2px solid #c6dafc;border-top-color:var(--primary);border-radius:50%;display:inline-block;animation:spin .8s linear infinite;margin-right:8px;vertical-align:-3px}
29
+ @keyframes spin{to{transform:rotate(360deg)}}
30
+ .footer{padding:14px 20px;border-top:1px solid #e6e8eb;color:var(--muted);font-size:13px;text-align:right}
31
+ </style>
32
+ </head>
33
+ <body>
34
+ <div class="wrap">
35
+ <div class="card">
36
+ <div class="head">
37
+ <div class="title">Borôro → Audio</div>
38
+ <div class="muted">Text-to-Speech demo</div>
39
+ </div>
40
+ <div class="body">
41
+ <label for="t">Enter Borôro text</label>
42
+ <textarea id="t" placeholder="Type Borôro here…">Aru ebaradoge iwadure boe, imedu ji boe ugoa, aro re mara boe ba, imedu kuro boe ekure.</textarea>
43
+ <div class="row">
44
+ <button id="go" class="primary">Convert</button>
45
+ <button id="clear" class="ghost" type="button">Clear</button>
46
+ <button id="example" class="ghost" type="button">Example</button>
47
+ <span class="counter" id="count">0 / 500</span>
48
+ </div>
49
+ <div class="status" id="status"></div>
50
+ <div class="audio"><audio id="aud" controls style="width:100%"></audio></div>
51
+ </div>
52
+ <div class="footer">Non-commercial use only (CC-BY-NC model)</div>
53
+ </div>
54
+ </div>
55
+
56
+ <script>
57
+ const MAX = 500;
58
+ const t = document.getElementById('t');
59
+ const go = document.getElementById('go');
60
+ const statusEl = document.getElementById('status');
61
+ const aud = document.getElementById('aud');
62
+ const count = document.getElementById('count');
63
+ const clearBtn = document.getElementById('clear');
64
+ const exampleBtn = document.getElementById('example');
65
+
66
+ function updateCount(){ count.textContent = `${t.value.length} / ${MAX}`; }
67
+ updateCount();
68
+ t.addEventListener('input', () => {
69
+ if (t.value.length > MAX) t.value = t.value.slice(0, MAX);
70
+ updateCount();
71
+ });
72
+
73
+ clearBtn.onclick = () => { t.value = ''; updateCount(); t.focus(); };
74
+ exampleBtn.onclick = () => {
75
+ t.value = 'Aru ebaradoge iwadure boe, imedu ji boe ugoa, aro re mara boe ba, imedu kuro boe ekure.';
76
+ updateCount(); t.focus();
77
+ };
78
+
79
+ go.onclick = async () => {
80
+ const text = t.value.trim();
81
+ if (!text){ t.focus(); return; }
82
+ go.disabled = true;
83
+ statusEl.innerHTML = '<span class="spinner"></span>Generating audio…';
84
+ try {
85
+ const ctrl = new AbortController();
86
+ const timeout = setTimeout(() => ctrl.abort(), 60000);
87
+ const r = await fetch('/api/tts', {
88
+ method: 'POST',
89
+ headers: { 'Content-Type': 'application/json' },
90
+ body: JSON.stringify({ text }),
91
+ signal: ctrl.signal
92
+ });
93
+ clearTimeout(timeout);
94
+ if (!r.ok) throw new Error(`Server ${r.status}`);
95
+ const b = await r.blob();
96
+ const url = URL.createObjectURL(b);
97
+ aud.src = url;
98
+ await aud.play().catch(()=>{});
99
+ statusEl.textContent = 'Ready';
100
+ } catch (e) {
101
+ statusEl.textContent = `Error: ${e.message || e}`;
102
+ } finally {
103
+ go.disabled = false;
104
+ }
105
+ };
106
+ </script>
107
+ </body>
108
+ </html>