Skip to content

Commit

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

Expand Down
2 changes: 2 additions & 0 deletions tests/utterance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def test_hash_utterances(self):
{
"start": 1.26,
"end": 3.94,
"_private_not_hashed": "0",
},
{
"start": 5.24,
Expand All @@ -86,6 +87,7 @@ def test_hash_utterances(self):
{
"start": 1.26,
"end": 3.94,
"_private_not_hashed": "0",
"_hash": "2fa6f80e0c81fb8e142f2dbbad0bceff7c21a031833b5752bc1cfd799f6b3bc6",
},
{
Expand Down

0 comments on commit 61770e0

Please sign in to comment.