Spaces:
Sleeping
Sleeping
fexeak
commited on
Commit
·
312d893
1
Parent(s):
1a28718
add static
Browse files- static/index.html +50 -0
static/index.html
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8"/>
|
| 5 |
+
<title>Higgs Audio 测试页</title>
|
| 6 |
+
</head>
|
| 7 |
+
<body>
|
| 8 |
+
<h2>Higgs Audio 在线测试</h2>
|
| 9 |
+
|
| 10 |
+
<label>文本:</label><br/>
|
| 11 |
+
<textarea id="prompt" rows="4" cols="60">The sun rises in the east.</textarea><br/><br/>
|
| 12 |
+
|
| 13 |
+
<button onclick="generate()">生成语音</button>
|
| 14 |
+
|
| 15 |
+
<br/><br/>
|
| 16 |
+
<audio id="player" controls style="display:none"></audio>
|
| 17 |
+
|
| 18 |
+
<script>
|
| 19 |
+
async function generate() {
|
| 20 |
+
const btn = document.querySelector('button');
|
| 21 |
+
btn.disabled = true;
|
| 22 |
+
btn.textContent = '生成中…';
|
| 23 |
+
|
| 24 |
+
const res = await fetch('/generate-audio', {
|
| 25 |
+
method: 'POST',
|
| 26 |
+
headers: {'Content-Type': 'application/json'},
|
| 27 |
+
body: JSON.stringify({
|
| 28 |
+
user_prompt: document.getElementById('prompt').value,
|
| 29 |
+
max_new_tokens: 1024,
|
| 30 |
+
temperature: 0.3
|
| 31 |
+
})
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
if (!res.ok) {
|
| 35 |
+
alert('生成失败:' + res.statusText);
|
| 36 |
+
btn.disabled = false;
|
| 37 |
+
btn.textContent = '生成语音';
|
| 38 |
+
return;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
const data = await res.json();
|
| 42 |
+
const audio = document.getElementById('player');
|
| 43 |
+
audio.src = 'data:audio/wav;base64,' + data.audio_base64;
|
| 44 |
+
audio.style.display = 'inline';
|
| 45 |
+
btn.disabled = false;
|
| 46 |
+
btn.textContent = '生成语音';
|
| 47 |
+
}
|
| 48 |
+
</script>
|
| 49 |
+
</body>
|
| 50 |
+
</html>
|