From 19fca4f2a7b2d2342f49e5719b12b7f2f24a281e Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Wed, 20 Nov 2024 11:51:14 +0100 Subject: [PATCH] do not try to decipher empty audio --- examples/json_to_audio.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/json_to_audio.py b/examples/json_to_audio.py index 032458e..22b6379 100644 --- a/examples/json_to_audio.py +++ b/examples/json_to_audio.py @@ -40,8 +40,9 @@ def encoded_audio_to_sound_file(config, encoded_audio, output_file_path): def get_sf(config): with gzip.open(config.document_gz, 'rt') as fp: document = json.load(fp) - encoded_audio_to_sound_file(config, document["encrypted_audio"], - config.audio_file) + if "encrypted_audio" in document and len(document["encrypted_audio"]) > 0: + encoded_audio_to_sound_file(config, document["encrypted_audio"], + config.audio_file) def sanitize_file_name(s): @@ -84,7 +85,7 @@ def main(): args = parser.parse_args() if os.path.isdir(args.document_gz): documents = [filepath for filepath in os.listdir(args.document_gz) if - filepath.endswith(".json.gz")] + filepath.endswith(".json.gz") and filepath.startswith("yamnet_")] for document in documents: args_cp = copy.copy(args) args_cp.document_gz = os.path.join(args.document_gz, document)