From f78f8da55af9c26b1e70f19186fa96b508eb3d9e Mon Sep 17 00:00:00 2001 From: Jordi Mas Date: Sat, 21 Dec 2024 10:49:45 +0100 Subject: [PATCH] hash --- open_dubbing/utterance.py | 6 +++--- tests/utterance_test.py | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/open_dubbing/utterance.py b/open_dubbing/utterance.py index e53a4c6..c3ab7cf 100644 --- a/open_dubbing/utterance.py +++ b/open_dubbing/utterance.py @@ -106,7 +106,7 @@ def _hash_utterances(self, utterance_metadata): for utterance in utterance_metadata: dict_str = json.dumps(utterance, sort_keys=True) _hash = hashlib.sha256(dict_str.encode()).hexdigest() - utterance["hash"] = _hash + utterance["_hash"] = _hash return utterance_metadata @@ -132,8 +132,8 @@ def get_files_paths(self, utterance_metadata) -> Tuple[List[str], List[str]]: def get_modified_utterances(self, utterance_metadata): modified = [] for utterance in utterance_metadata: - _hash_utterance = utterance["hash"] - del utterance["hash"] + _hash_utterance = utterance["_hash"] + del utterance["_hash"] dict_str = json.dumps(utterance, sort_keys=True) _hash = hashlib.sha256(dict_str.encode()).hexdigest() diff --git a/tests/utterance_test.py b/tests/utterance_test.py index 3e758ab..f283094 100644 --- a/tests/utterance_test.py +++ b/tests/utterance_test.py @@ -50,13 +50,13 @@ def testrun_save_utterance(self): "id": 1, "start": 1.26, "end": 3.94, - "hash": "26d514d9ce21021f51bd010d9946db0f31555ef7145067d4fe5a3b1bdcd84ce7", + "_hash": "26d514d9ce21021f51bd010d9946db0f31555ef7145067d4fe5a3b1bdcd84ce7", }, { "id": 2, "start": 5.24, "end": 6.629, - "hash": "157dc7fb355c7dc13a0ea687e9fd4a6f6c5c03526a959a64dfe1fa7562fedff4", + "_hash": "157dc7fb355c7dc13a0ea687e9fd4a6f6c5c03526a959a64dfe1fa7562fedff4", }, ], "metadata": { @@ -86,12 +86,12 @@ def test_hash_utterances(self): { "start": 1.26, "end": 3.94, - "hash": "2fa6f80e0c81fb8e142f2dbbad0bceff7c21a031833b5752bc1cfd799f6b3bc6", + "_hash": "2fa6f80e0c81fb8e142f2dbbad0bceff7c21a031833b5752bc1cfd799f6b3bc6", }, { "start": 5.24, "end": 6.629, - "hash": "34cd5da78cb163ad18996aefffcfeae864727257defc7ae68818a245ca269951", + "_hash": "34cd5da78cb163ad18996aefffcfeae864727257defc7ae68818a245ca269951", }, ] @@ -101,13 +101,13 @@ def test_get_modified_utterances(self): "id": 1, "start": 1.26, "end": 3.94, - "hash": "26d514d9ce21021f51bd010d9946db0f31555ef7145067d4fe5a3b1bdcd84ce7", + "_hash": "26d514d9ce21021f51bd010d9946db0f31555ef7145067d4fe5a3b1bdcd84ce7", }, { "id": 2, "start": 5.25, "end": 6.629, - "hash": "157dc7fb355c7dc13a0ea687e9fd4a6f6c5c03526a959a64dfe1fa7562fedff4", + "_hash": "157dc7fb355c7dc13a0ea687e9fd4a6f6c5c03526a959a64dfe1fa7562fedff4", }, ] dubbing = Utterance( @@ -178,7 +178,7 @@ def _get_master_utterances(self): "assigned_voice": "ca-ES-EnricNeural", "speed": 1.0, "dubbed_path": "output/jordi.central.edge.update/dubbed_chunk_1.26284375_3.94596875.mp3", - "hash": "b01b399ac50f80f87e704918e290ffc5ee0a1962683ba946c627124ea903480d", + "_hash": "b01b399ac50f80f87e704918e290ffc5ee0a1962683ba946c627124ea903480d", }, { "id": 2, @@ -193,7 +193,7 @@ def _get_master_utterances(self): "assigned_voice": "ca-ES-EnricNeural", "speed": 1.0, "dubbed_path": "output/jordi.central.edge.update/dubbed_chunk_5.24534375_6.629093750000001.mp3", - "hash": "629484afdecb7641e35d686d6348cee4445611690f2f77831e892d52c3128bdd", + "_hash": "629484afdecb7641e35d686d6348cee4445611690f2f77831e892d52c3128bdd", }, ] @@ -241,7 +241,7 @@ def test_update_utterances_operation_update(self): "assigned_voice": "ca-ES-EnricNeural", "speed": 1.0, "dubbed_path": "output/jordi.central.edge.update/dubbed_chunk_5.24534375_6.629093750000001.mp3", - "hash": "629484afdecb7641e35d686d6348cee4445611690f2f77831e892d52c3128bdd", + "_hash": "629484afdecb7641e35d686d6348cee4445611690f2f77831e892d52c3128bdd", } def test_load_utterances(self):