Skip to content

Commit

Permalink
make destructor call client.close in PlayHT service
Browse files Browse the repository at this point in the history
  • Loading branch information
Moishe committed Feb 14, 2024
1 parent 97a4cb8 commit dcbd793
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dailyai/services/playht_ai_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions src/examples/foundational/01-say-one-thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ async def main(room_url):
meeting_duration_minutes,
mic_enabled=True
)

"""
tts = ElevenLabsTTSService(
aiohttp_session=session,
Expand All @@ -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

Expand All @@ -54,6 +56,7 @@ async def on_participant_joined(transport, participant):
await transport.stop_when_done()

await transport.run()
del(tts)


if __name__ == "__main__":
Expand Down

0 comments on commit dcbd793

Please sign in to comment.