伊地知ニジカ放送局だぬ゛ん゛. https://www.youtube.com/@deerjika
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

aques.py 1.2 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
123456789101112131415161718192021222324252627282930313233343536
  1. import subprocess
  2. from ctypes import *
  3. class Aques:
  4. @classmethod
  5. def main (cls, text: str, goatoh_mode: bool = False) -> bytearray | None:
  6. return cls.__synthe_utf8 (text, 100, './phont/ar_m5.phont' if goatoh_mode else './phont/ar_mf2.phont')
  7. @staticmethod
  8. def __synthe_utf8 (text, speed, phont_file = None) -> bytearray | None:
  9. if phont_file is None:
  10. phont = None
  11. else:
  12. with open (phont_file, 'rb') as f:
  13. phont = f.read ()
  14. p = subprocess.Popen ('./aques', stdin = subprocess.PIPE,
  15. stdout = subprocess.PIPE)
  16. koe: str = p.communicate (text.encode ())[0].decode ()
  17. aqtk = cdll.LoadLibrary ('libAquesTalk2Eva.so')
  18. aqtk.AquesTalk2_Synthe_Utf8.restype = POINTER (ARRAY (c_ubyte, 0))
  19. size = c_int (0)
  20. wav_p = aqtk.AquesTalk2_Synthe_Utf8 (koe.encode ('utf-8'), speed,
  21. byref (size), phont)
  22. if not bool (wav_p):
  23. return None
  24. wav_p = cast (wav_p, POINTER (ARRAY (c_ubyte, size.value)))
  25. wav = bytearray (wav_p.contents)
  26. aqtk.AquesTalk2_FreeWave (wav_p)
  27. return wav