pyht
pyht copied to clipboard
Stop running after done generating
Hi, I'm using this code:
with open(f'{x}.wav', 'wb') as f:
for chunk in client.tts("Can you tell me your account email or, ah your phone number?", options):
if not chunk:
break
print(type(chunk))
f.write(chunk)
However it does not terminate the script after the audio has finished generating, how can I detect when the audio is done generating and stop? Thank you!
cc @NCarrollPlay @mahmoudfelfel
You don't really need that break statement in there. You are getting out of the loop when it's done writing.
The reason your script does not stop executing is because the client is holding it open. If you add client.close() after your loop, your program should terminate correctly!
Probably should update the example code.