From dcbd79333abef1abc896bf8798874ecfd4014995 Mon Sep 17 00:00:00 2001 From: Moishe Lettvin Date: Wed, 14 Feb 2024 12:53:20 -0500 Subject: [PATCH] make destructor call client.close in PlayHT service --- src/dailyai/services/playht_ai_service.py | 2 +- src/examples/foundational/01-say-one-thing.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dailyai/services/playht_ai_service.py b/src/dailyai/services/playht_ai_service.py index ed09f8679..350e5cb88 100644 --- a/src/dailyai/services/playht_ai_service.py +++ b/src/dailyai/services/playht_ai_service.py @@ -31,7 +31,7 @@ def __init__( quality="higher", format=Format.FORMAT_WAV) - def close(self): + def __del__(self): self.client.close() async def run_tts(self, sentence): diff --git a/src/examples/foundational/01-say-one-thing.py b/src/examples/foundational/01-say-one-thing.py index cb81f023e..9df54d708 100644 --- a/src/examples/foundational/01-say-one-thing.py +++ b/src/examples/foundational/01-say-one-thing.py @@ -27,6 +27,7 @@ async def main(room_url): meeting_duration_minutes, mic_enabled=True ) + """ tts = ElevenLabsTTSService( aiohttp_session=session, @@ -42,6 +43,7 @@ async def main(room_url): # Register an event handler so we can play the audio when the participant joins. @transport.event_handler("on_participant_joined") async def on_participant_joined(transport, participant): + nonlocal tts if participant["info"]["isLocal"]: return @@ -54,6 +56,7 @@ async def on_participant_joined(transport, participant): await transport.stop_when_done() await transport.run() + del(tts) if __name__ == "__main__":