From 61770e0fc93e5305e30d9e2c260ef507cba741e7 Mon Sep 17 00:00:00 2001 From: Jordi Mas Date: Sat, 21 Dec 2024 10:56:36 +0100 Subject: [PATCH] Do not hash _ --- open_dubbing/utterance.py | 8 +++++++- tests/utterance_test.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/open_dubbing/utterance.py b/open_dubbing/utterance.py index c3ab7cf..cf570d3 100644 --- a/open_dubbing/utterance.py +++ b/open_dubbing/utterance.py @@ -104,7 +104,13 @@ def save_utterances( def _hash_utterances(self, utterance_metadata): for utterance in utterance_metadata: - dict_str = json.dumps(utterance, sort_keys=True) + filtered_dict = { + key: value + for key, value in utterance.items() + if not key.startswith("_") + } + + dict_str = json.dumps(filtered_dict, sort_keys=True) _hash = hashlib.sha256(dict_str.encode()).hexdigest() utterance["_hash"] = _hash diff --git a/tests/utterance_test.py b/tests/utterance_test.py index f283094..b6ffa02 100644 --- a/tests/utterance_test.py +++ b/tests/utterance_test.py @@ -70,6 +70,7 @@ def test_hash_utterances(self): { "start": 1.26, "end": 3.94, + "_private_not_hashed": "0", }, { "start": 5.24, @@ -86,6 +87,7 @@ def test_hash_utterances(self): { "start": 1.26, "end": 3.94, + "_private_not_hashed": "0", "_hash": "2fa6f80e0c81fb8e142f2dbbad0bceff7c21a031833b5752bc1cfd799f6b3bc6", }, {