fix: replace blocking play_audio with async generator yielding playback duration in gcloud tts

This commit is contained in:
2025-01-18 14:40:31 +00:00
parent a75a6574ba
commit 9073445368
2 changed files with 8 additions and 5 deletions
+5 -3
View File
@@ -30,16 +30,18 @@ import os
import subprocess
import sys
import pygame
import time
async def play_audio_async(filename)
pygame.mixer.init()
pygame.mixer.music.load(filename)
time_start = time.time()
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
await asyncio.sleep(0.1)
yield
duration = time.time() - time_start
yield duration
def play_audio(filename):