mirror of
https://github.com/tiennm99/loto.git
synced 2026-09-10 00:17:38 +00:00
chore(audio): generate Vietnamese clips for both voices
- Run scripts/generate-audio.py to produce 184 MP3 clips (92 each for vi-VN-HoaiMyNeural and vi-VN-NamMinhNeural), ~2.2 MB total. - Cap edge-tts concurrency at 4 with 4-attempt exponential retry on NoAudioReceived — earlier all-at-once gather() hit the upstream rate limit and bailed mid-voice. - .gitignore: add .venv/ + __pycache__/ for the local generator venv.
This commit is contained in:
@@ -5,3 +5,5 @@ build/
|
||||
.env.local
|
||||
.env*.local
|
||||
repomix-output.xml
|
||||
.venv/
|
||||
__pycache__/
|
||||
|
||||
@@ -57,10 +57,37 @@ def display_label(short_name: str, gender: str) -> str:
|
||||
return f"{given} ({gender_vi})"
|
||||
|
||||
|
||||
# Microsoft's TTS endpoint rate-limits aggressive concurrency and
|
||||
# occasionally returns empty streams. Cap parallelism + retry transient
|
||||
# failures so one voice run doesn't bail halfway through.
|
||||
CONCURRENCY = 4
|
||||
MAX_RETRIES = 4
|
||||
RETRY_BACKOFF_SEC = 1.5
|
||||
|
||||
_sem: asyncio.Semaphore | None = None
|
||||
|
||||
|
||||
def _semaphore() -> asyncio.Semaphore:
|
||||
global _sem
|
||||
if _sem is None:
|
||||
_sem = asyncio.Semaphore(CONCURRENCY)
|
||||
return _sem
|
||||
|
||||
|
||||
async def synth(text: str, voice: str, out: str) -> None:
|
||||
import edge_tts
|
||||
await edge_tts.Communicate(text, voice).save(out)
|
||||
print(f" {out} ← \"{text}\"")
|
||||
from edge_tts.exceptions import NoAudioReceived
|
||||
|
||||
async with _semaphore():
|
||||
for attempt in range(1, MAX_RETRIES + 1):
|
||||
try:
|
||||
await edge_tts.Communicate(text, voice).save(out)
|
||||
print(f" {out} ← \"{text}\"")
|
||||
return
|
||||
except NoAudioReceived:
|
||||
if attempt == MAX_RETRIES:
|
||||
raise
|
||||
await asyncio.sleep(RETRY_BACKOFF_SEC * attempt)
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,4 +13,4 @@
|
||||
"gender": "male"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user