forked from mrq/tortoise-tts
Merge pull request #68 from space-pope/fix-default-arg
avoid mutable default in aligner
This commit is contained in:
commit
3f7386d442
|
@ -7,13 +7,15 @@ from transformers import Wav2Vec2ForCTC, Wav2Vec2FeatureExtractor, Wav2Vec2CTCTo
|
||||||
from tortoise.utils.audio import load_audio
|
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
|
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.
|
used to replace that character.
|
||||||
|
|
||||||
Finally got to use my DP skills!
|
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}"
|
assert skip_character not in s1, f"Found the skip character {skip_character} in the provided string, {s1}"
|
||||||
if len(s1) == 0:
|
if len(s1) == 0:
|
||||||
return ''
|
return ''
|
||||||
|
@ -145,4 +147,3 @@ class Wav2VecAlignment:
|
||||||
start, stop = nri
|
start, stop = nri
|
||||||
output_audio.append(audio[:, alignments[start]:alignments[stop]])
|
output_audio.append(audio[:, alignments[start]:alignments[stop]])
|
||||||
return torch.cat(output_audio, dim=-1)
|
return torch.cat(output_audio, dim=-1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user