From 0094e3b95295da4aae6672feb62417b5033b073a Mon Sep 17 00:00:00 2001 From: rany2 Date: Wed, 3 May 2023 22:21:53 +0300 Subject: [PATCH] Exception is now raised in stream() proper --- src/edge_tts/communicate.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/edge_tts/communicate.py b/src/edge_tts/communicate.py index 07c9638..d04e646 100644 --- a/src/edge_tts/communicate.py +++ b/src/edge_tts/communicate.py @@ -449,7 +449,6 @@ class Communicate: """ Save the audio and metadata to the specified files. """ - written_audio: bool = False metadata: Union[TextIOWrapper, ContextManager[None]] = ( open(metadata_fname, "w", encoding="utf-8") if metadata_fname is not None @@ -459,15 +458,9 @@ class Communicate: async for message in self.stream(): if message["type"] == "audio": audio.write(message["data"]) - written_audio = True elif ( isinstance(metadata, TextIOWrapper) and message["type"] == "WordBoundary" ): json.dump(message, metadata) metadata.write("\n") - - if not written_audio: - raise NoAudioReceived( - "No audio was received from the service, so the file is empty." - )