Spaces:
Sleeping
Sleeping
use /tmp cache
Browse files- app.py +3 -1
- public/index.html +1 -1
app.py
CHANGED
|
@@ -19,7 +19,7 @@ TOK = AutoTokenizer.from_pretrained("facebook/mms-tts-bor", cache_dir=CACHE)
|
|
| 19 |
|
| 20 |
|
| 21 |
app = FastAPI()
|
| 22 |
-
|
| 23 |
|
| 24 |
class Inp(BaseModel):
|
| 25 |
text: str
|
|
@@ -31,3 +31,5 @@ def tts(inp: Inp):
|
|
| 31 |
audio = audio / (np.max(np.abs(audio)) + 1e-9)
|
| 32 |
buf = io.BytesIO(); write(buf, MODEL.config.sampling_rate, (audio*32767).astype(np.int16)); buf.seek(0)
|
| 33 |
return StreamingResponse(buf, media_type="audio/wav")
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
app = FastAPI()
|
| 22 |
+
|
| 23 |
|
| 24 |
class Inp(BaseModel):
|
| 25 |
text: str
|
|
|
|
| 31 |
audio = audio / (np.max(np.abs(audio)) + 1e-9)
|
| 32 |
buf = io.BytesIO(); write(buf, MODEL.config.sampling_rate, (audio*32767).astype(np.int16)); buf.seek(0)
|
| 33 |
return StreamingResponse(buf, media_type="audio/wav")
|
| 34 |
+
|
| 35 |
+
app.mount("/", StaticFiles(directory="public", html=True), name="ui")
|
public/index.html
CHANGED
|
@@ -8,7 +8,7 @@ document.getElementById('go').onclick = async () => {
|
|
| 8 |
const r = await fetch('/api/tts', {
|
| 9 |
method:'POST',
|
| 10 |
headers:{'Content-Type':'application/json'},
|
| 11 |
-
body: JSON.stringify({ text })
|
| 12 |
});
|
| 13 |
const b = await r.blob();
|
| 14 |
const url = URL.createObjectURL(b);
|
|
|
|
| 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);
|