伊地知ニジカ放送局だぬ゛ん゛. 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 928 B

12345678910111213141516171819202122232425262728293031
  1. from ctypes import *
  2. class Aques:
  3. @classmethod
  4. def main (cls, text: str) -> bytearray | None:
  5. return cls.__synthe_utf8 (text, speed = 100)
  6. @staticmethod
  7. def __synthe_utf8 (text, speed, phont_file = None) -> bytearray | None:
  8. if phont_file is None:
  9. phont = None
  10. else:
  11. with open (phont_file, 'rb') as f:
  12. phont = f.read ()
  13. aqtk = cdll.LoadLibrary ('libAquesTalk2Eva.so')
  14. aqtk.AquesTalk2_Synthe_Utf8.restype = POINTER (ARRAY (c_ubyte, 0))
  15. size = c_int (0)
  16. wav_p = aqtk.AquesTalk2_Synthe_Utf8 (text.encode ('utf-8'), speed,
  17. byref (size), phont)
  18. if not bool (wav_p):
  19. return None
  20. wav_p = cast (wav_p, POINTER (ARRAY (c_ubyte, size.value)))
  21. wav = bytearray (wav_p.contents)
  22. aqtk.AquuesTalk2_FreeWave (wav_p)
  23. return wav