Skip to content

Commit

Permalink
hash
Browse files Browse the repository at this point in the history
  • Loading branch information
jordimas committed Dec 21, 2024
1 parent e7bc7dd commit f78f8da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions open_dubbing/utterance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down
18 changes: 9 additions & 9 deletions tests/utterance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
},
]

Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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",
},
]

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit f78f8da

Please sign in to comment.