Skip to content

Commit

Permalink
Merge pull request neonbjb#68 from space-pope/fix-default-arg
Browse files Browse the repository at this point in the history
avoid mutable default in aligner
  • Loading branch information
neonbjb authored May 26, 2022
2 parents f56f3d5 + 5b0e50e commit 3f7386d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tortoise/utils/wav2vec_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
from tortoise.utils.audio import load_audio


def max_alignment(s1, s2, skip_character='~', record={}):
def max_alignment(s1, s2, skip_character='~', record=None):
"""
A clever function that aligns s1 to s2 as best it can. Wherever a character from s1 is not found in s2, a '~' is
used to replace that character.
Finally got to use my DP skills!
"""
if record is None:
record = {}
assert skip_character not in s1, f"Found the skip character {skip_character} in the provided string, {s1}"
if len(s1) == 0:
return ''
Expand Down Expand Up @@ -145,4 +147,3 @@ def redact(self, audio, expected_text, audio_sample_rate=24000):
start, stop = nri
output_audio.append(audio[:, alignments[start]:alignments[stop]])
return torch.cat(output_audio, dim=-1)

0 comments on commit 3f7386d

Please sign in to comment.