From 5583ded358095261a92e0348eb876348f5cf8048 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Mon, 2 Dec 2024 18:13:37 +0900 Subject: [PATCH] =?UTF-8?q?#30=20=E3=83=8B=E3=82=B8=E3=82=AB=E3=81=8C?= =?UTF-8?q?=E5=96=8B=E3=81=A3=E3=81=A6=E3=81=8F=E3=82=8C=E3=81=AA=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/main.py b/main.py index d076a43..91c1f61 100644 --- a/main.py +++ b/main.py @@ -250,21 +250,7 @@ class Main: time.sleep (1.5) - # 返答の読上げを WAV ディタとして生成,取得 - wav: bytearray | None - try: - wav = Aques.main (answer, goatoh_talking) - except: - wav = None - - # 読上げを再生 - if wav is not None: - with open ('./nizika_talking.wav', 'wb') as f: - f.write (wav) - - playsound ('./nizika_talking.wav') - - time.sleep (1) + cls.read_out (answer, goatoh_talking) if not double_mode or random.random () < .5: break @@ -306,16 +292,39 @@ class Main: kita, jojoko, sunrise_start, sunrise_end, sunset_start, sunset_end, sun_alt, sun_az, moon_alt, moon_az, moon_days_old) + answer = Talk.main (query).replace ('\n', ' ') cls.draw_talking (screen, balloon, user_font, nizika_font, - query, Talk.main (query).replace ('\n', ' ')) + query, answer) noon.play () time.sleep (1.5) + cls.read_out (answer) for event in pygame.event.get (): if event.type == QUIT: pygame.quit () sys.exit () + @staticmethod + def read_out ( + answer: str, + goatoh: bool = False, + ) -> None: + # 返答の読上げを WAV ディタとして生成,取得 + wav: bytearray | None + try: + wav = Aques.main (answer, goatoh) + except: + wav = None + + # 読上げを再生 + if wav is not None: + with open ('./nizika_talking.wav', 'wb') as f: + f.write (wav) + + playsound ('./nizika_talking.wav') + + time.sleep (1) + @staticmethod def draw_talking ( screen: pygame.Surface, @@ -376,7 +385,6 @@ class Main: pygame.display.update () - @classmethod def draw_bg ( cls,