Files

36 lines
1.4 KiB
Python

"""앱 원문 101개를 pinned edge-tts로 새로 생성하는 명령 진입점.
import에는 부작용이 없다. 원문은 앱의 renderSentence를 그대로 호출하며
네트워크 생성·검증·원자 교체는 neural_audio가 담당한다. 빌드는 생성기를 호출하지 않는다.
"""
import json
import subprocess
import sys
from neural_audio import ROOT, generate
def main():
source = subprocess.check_output([
"node", "--experimental-strip-types", "--input-type=module", "-e",
"import {INTRO,PATTERNS,WORDS,renderSentence} from './src/content.ts'; "
"console.log(JSON.stringify([{file:'intro.wav',text:INTRO},"
"...PATTERNS.flatMap(p=>WORDS.map(w=>({file:p.id+'-'+w.id+'.wav',"
"text:renderSentence(p,w)})))]));",
], cwd=ROOT, text=True, timeout=10)
manifest = generate(json.loads(source), ROOT / "public/audio")
print(f"{len(manifest['files'])}개 신규 WAV 원자 교체 완료, "
f"합계 {sum(e['bytes'] for e in manifest['files']):,} 바이트")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("음성 생성 중단; 완성 전 공개 자산 변경 없음", file=sys.stderr)
sys.exit(130)
except Exception as error:
# 인증 응답이 섞일 수 있는 외부 예외는 adapter에서 안전한 메시지로 바뀐다.
print(f"음성 생성 실패: {error}", file=sys.stderr)
sys.exit(1)