Skip to content

Commit

Permalink
Update gradio_app.py
Browse files Browse the repository at this point in the history
Remove extra whitespaces to prevent unwanted intonation
  • Loading branch information
Approximetal committed Jun 13, 2024
1 parent 013a21c commit 82d5676
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gradio_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
MODELS_PATH = os.getenv("MODELS_PATH", "./pretrained_models")
device = "cuda" if torch.cuda.is_available() else "cpu"
whisper_model, align_model, voicecraft_model = None, None, None

_whitespace_re = re.compile(r"\s+")

def get_random_string():
return "".join(str(uuid.uuid4()).split("-"))
Expand Down Expand Up @@ -270,7 +270,7 @@ def run(seed, left_margin, right_margin, codec_audio_sr, codec_sr, top_k, top_p,
target_transcript = sentence

inference_transcript += target_transcript + "\n"

target_transcript = re.sub(_whitespace_re, " ", target_transcript)
prompt_end_frame = int(min(audio_dur, prompt_end_time) * info.sample_rate)
_, gen_audio = inference_one_sample(voicecraft_model["model"],
voicecraft_model["config"],
Expand All @@ -296,7 +296,7 @@ def run(seed, left_margin, right_margin, codec_audio_sr, codec_sr, top_k, top_p,
target_transcript = sentence

inference_transcript += target_transcript + "\n"

target_transcript = re.sub(_whitespace_re, " ", target_transcript)
morphed_span = (max(edit_start_time - left_margin, 1 / codec_sr), min(edit_end_time + right_margin, audio_dur))
mask_interval = [[round(morphed_span[0]*codec_sr), round(morphed_span[1]*codec_sr)]]
mask_interval = torch.LongTensor(mask_interval)
Expand Down

0 comments on commit 82d5676

Please sign in to comment.