Browse Source

音声記号列に変換

btc-sounds
みてるぞ 1 year ago
parent
commit
28aae0158f
2 changed files with 14 additions and 3 deletions
  1. +10
    -1
      aques.py
  2. +4
    -2
      main.py

+ 10
- 1
aques.py View File

@@ -14,10 +14,19 @@ class Aques:
with open (phont_file, 'rb') as f: with open (phont_file, 'rb') as f:
phont = f.read () phont = f.read ()


aqkoe = cdll.LoadLibrary ('libAqKanji2Koe.so')
dic_path: str = '.'
err = c_int (0)
aqkoe.AqKanji2Koe_Create.restype = c_void_p
handle = aqkoe.AqKanji2Koe_Create (dic_path, byref (err))
koe: str = ''
aqkoe.AqKanji2Koe_Convert.restype = c_int
aqkoe.AqKanji2Koe_Convert (handle, text.encode ('utf-8'), koe, 4096)

aqtk = cdll.LoadLibrary ('libAquesTalk2Eva.so') aqtk = cdll.LoadLibrary ('libAquesTalk2Eva.so')
aqtk.AquesTalk2_Synthe_Utf8.restype = POINTER (ARRAY (c_ubyte, 0)) aqtk.AquesTalk2_Synthe_Utf8.restype = POINTER (ARRAY (c_ubyte, 0))
size = c_int (0) size = c_int (0)
wav_p = aqtk.AquesTalk2_Synthe_Utf8 (text.encode ('utf-8'), speed,
wav_p = aqtk.AquesTalk2_Synthe_Utf8 (koe.encode ('utf-8'), speed,
byref (size), phont) byref (size), phont)


if not bool (wav_p): if not bool (wav_p):


+ 4
- 2
main.py View File

@@ -47,8 +47,12 @@ class Main:
screen.blit (nizika_font.render ( screen.blit (nizika_font.render (
answer, True, (192, 0, 0)), (100, 150)) answer, True, (192, 0, 0)), (100, 150))


pygame.display.update ()

noon.play () noon.play ()


time.sleep (2)

wav: bytearray | None = Aques.main (answer) wav: bytearray | None = Aques.main (answer)
if wav is not None: if wav is not None:
with open ('./nizika_talking.wav', 'wb') as f: with open ('./nizika_talking.wav', 'wb') as f:
@@ -56,8 +60,6 @@ class Main:


playsound ('./nizika_talking.wav') playsound ('./nizika_talking.wav')


pygame.display.update ()

time.sleep (10) time.sleep (10)


pygame.display.update () pygame.display.update ()


Loading…
Cancel
Save