make destructor call client.close in PlayHT service

This commit is contained in:
Moishe Lettvin
2024-02-14 12:53:20 -05:00
parent 97a4cb8b7f
commit dcbd79333a
2 changed files with 4 additions and 1 deletions

View File

@@ -31,7 +31,7 @@ class PlayHTAIService(TTSService):
quality="higher",
format=Format.FORMAT_WAV)
def close(self):
def __del__(self):
self.client.close()
async def run_tts(self, sentence):

View File

@@ -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 main(room_url):
await transport.stop_when_done()
await transport.run()
del(tts)
if __name__ == "__main__":