Spaces:
Paused
Paused
Commit ·
e278ccc
1
Parent(s): 44fbd0d
feat: upload pre-generated audio and copy to runtime cache on startup
Browse files- Generated all 17 paragraphs for Puss in Boots story
- Upload hash-named files to audio_cache/ in Space repo
- Upload story-based named files to pregen_audio/ for reference
- Add startup logic to copy bundled audio_cache/ to runtime AUDIO_CACHE_DIR
(handles HF Space where runtime cache is on /data bucket)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_01.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_02.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_03.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_04.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_05.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_06.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_07.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_08.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_09.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_10.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_11.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_12.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_13.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_14.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_15.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_16.wav +3 -0
- pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_17.wav +3 -0
- tts.py +14 -1
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_01.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:08bfcbdb235ef97aa35bf998f69de2dd9dec1863acd3d1468f03a86e3eb4a881
|
| 3 |
+
size 111404
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_02.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dab3604e46c3f93ad14f07c8858d4ced78417f47aa4860b88aee3067c1c3b0f3
|
| 3 |
+
size 514604
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_03.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:35e641b7463453c91079e9d5972ad2194f149f3c423cb475d7c2f4d236f49410
|
| 3 |
+
size 599084
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_04.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f690fca3cfe3c87240bb84ff906a655b06ddde3459a6d63292558d54fa1cc59
|
| 3 |
+
size 510764
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_05.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fad367161d48976e9968061a1e2b4394ef1c3a37ab25ca5a94567ee14e22db30
|
| 3 |
+
size 564524
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_06.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a141fbabd307b344911656de651acad683a8ef67da2554ce3b9b493e774d6b3e
|
| 3 |
+
size 526124
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_07.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:abc2703d9c77636068736356be317004e9510abd2e186e22a1138774ae76759d
|
| 3 |
+
size 553004
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_08.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0701054dbfc0fafd2887acd78dfa54ad325b6f18837510bf3e2822f94ea89100
|
| 3 |
+
size 572204
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_09.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8a8b1a30402b186ff9ac2bf72319c56cb380b53502001c6440030a6736ef66a3
|
| 3 |
+
size 583724
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_10.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2e281373dd3eb1e872c1a149a3736f0005653616d3c1fb4b7a3da2c39f233c0b
|
| 3 |
+
size 614444
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_11.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:32327d1d425e7750e0c7b1adfa13df6ede1c9a923ab58daddba2e88b62196c8e
|
| 3 |
+
size 495404
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_12.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f6d28f6bc16478c618fcda366af660774a72e1ab2425f6844deeaaeaf0f484bd
|
| 3 |
+
size 568364
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_13.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:68644f78643edb3920d033d809ffb3c1e2be846af8ed807d99347a1f16bea921
|
| 3 |
+
size 533804
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_14.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a429975e61f32bc4243a31d89a2b2da46c2fc1af0c60d9d08a9b0bae2ab4e31a
|
| 3 |
+
size 553004
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_15.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ddcede3cfa7dfd5b08bc4ffca2472289fa41ee86dc3d103aa6e80423dd894547
|
| 3 |
+
size 503084
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_16.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:90351cc2644fed8477674ac2958fedd4e5b53a0cdb9c918e394e65abc276cbaa
|
| 3 |
+
size 506924
|
pregen_audio/The_Adventures_of_Puss_in_Boots/The_Adventures_of_Puss_in_Boots_para_17.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cdda5b8bc426640caea48ece5ae3b516dc627eb23a8eadef0ffc27544e733805
|
| 3 |
+
size 549164
|
tts.py
CHANGED
|
@@ -27,7 +27,7 @@ from collections import OrderedDict
|
|
| 27 |
import numpy as np
|
| 28 |
import soundfile as sf
|
| 29 |
|
| 30 |
-
from runtime_config import AUDIO_CACHE_DIR, GPU_INFERENCE_LOCK
|
| 31 |
|
| 32 |
logger = logging.getLogger(__name__)
|
| 33 |
|
|
@@ -42,6 +42,19 @@ _MAX_CHUNK_CHARS = 120
|
|
| 42 |
_CACHE_DIR = str(AUDIO_CACHE_DIR)
|
| 43 |
os.makedirs(_CACHE_DIR, exist_ok=True)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
# Transition chime (soft sine fade, 0.3s at 24kHz)
|
| 46 |
_CHIME_SR = 24000
|
| 47 |
_CHIME_DURATION = 0.3
|
|
|
|
| 27 |
import numpy as np
|
| 28 |
import soundfile as sf
|
| 29 |
|
| 30 |
+
from runtime_config import AUDIO_CACHE_DIR, GPU_INFERENCE_LOCK, APP_ROOT
|
| 31 |
|
| 32 |
logger = logging.getLogger(__name__)
|
| 33 |
|
|
|
|
| 42 |
_CACHE_DIR = str(AUDIO_CACHE_DIR)
|
| 43 |
os.makedirs(_CACHE_DIR, exist_ok=True)
|
| 44 |
|
| 45 |
+
# Copy pre-generated audio from app bundle to runtime cache (HF Space: repo → /data)
|
| 46 |
+
_BUNDLED_CACHE = APP_ROOT / "audio_cache"
|
| 47 |
+
if _BUNDLED_CACHE.is_dir() and str(_BUNDLED_CACHE) != _CACHE_DIR:
|
| 48 |
+
import shutil
|
| 49 |
+
_copied = 0
|
| 50 |
+
for _wav in _BUNDLED_CACHE.glob("*.wav"):
|
| 51 |
+
_dest = os.path.join(_CACHE_DIR, _wav.name)
|
| 52 |
+
if not os.path.exists(_dest):
|
| 53 |
+
shutil.copy2(str(_wav), _dest)
|
| 54 |
+
_copied += 1
|
| 55 |
+
if _copied:
|
| 56 |
+
logger.info("Copied %d pre-generated audio files to runtime cache.", _copied)
|
| 57 |
+
|
| 58 |
# Transition chime (soft sine fade, 0.3s at 24kHz)
|
| 59 |
_CHIME_SR = 24000
|
| 60 |
_CHIME_DURATION = 0.3
|