mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-28 09:08:54 +00:00
Entirely reworked text handling pipeline
This breaks the text pipeline into the following pieces: - input parsing (split known bracketed phoneme sections out first) - normalization (fix spacing, numbers, abbreviations, etc.) - phonetization (do CMUdict lookup or g2p prediction) - sequencing (convert the symbolic representation to integer representation) Each "pipeline" can have a unique combination of operations for each of these pipeline steps. This will grow over time.
This commit is contained in:
+28
-1
@@ -1,4 +1,5 @@
|
||||
import sys
|
||||
|
||||
sys.path.append('waveglow/')
|
||||
import shutil
|
||||
import json
|
||||
@@ -29,6 +30,11 @@ import subprocess
|
||||
import magic
|
||||
import os
|
||||
|
||||
from text.pipeline.english_pipeline_v1 import EnglishPipelineV1
|
||||
from text.pipeline.legacy_fakeyou_pipeline import LegacyFakeYouPipeline
|
||||
from text.pipeline_components.phonetization.cmudict import DEFAULT_CMUDICT_PATH, CMUDict
|
||||
from text.pipeline_components.phonetization.english_phonetization import EnglishPhonetization
|
||||
|
||||
def print_gpu_info():
|
||||
print('========================================')
|
||||
print('Python interpreter', sys.executable)
|
||||
@@ -82,7 +88,27 @@ def load_hifigan_model(checkpoint_path, super_resolution = False):
|
||||
denoiser = HifiDenoiser(hifigan, mode="normal")
|
||||
return hifigan, h, denoiser
|
||||
|
||||
def preprocess_text(text, raw_input=True):
|
||||
ENGLISH_PIPELINE_V1 = EnglishPipelineV1(EnglishPhonetization(CMUDict(DEFAULT_CMUDICT_PATH)))
|
||||
LEGACY_FAKEYOU_PIPELINE = LegacyFakeYouPipeline()
|
||||
|
||||
def preprocess_text(raw_user_text: str):
|
||||
integer_sequence = []
|
||||
|
||||
# TODO/NB: This word-based flag is for testing the rollout
|
||||
if "this" in raw_user_text:
|
||||
print("\n\n>>> ENGLISH V1\n\n")
|
||||
integer_sequence = ENGLISH_PIPELINE_V1.user_input_to_sequence(raw_user_text)
|
||||
else:
|
||||
print("\n\n>>> LEGACY\n\n")
|
||||
integer_sequence = LEGACY_FAKEYOU_PIPELINE.user_input_to_sequence(raw_user_text)
|
||||
|
||||
with torch.no_grad():
|
||||
# save VRAM by not including gradients
|
||||
sequence = np.array(integer_sequence)[None, :]
|
||||
sequence = torch.autograd.Variable(torch.from_numpy(sequence)).cuda().long()
|
||||
return sequence
|
||||
|
||||
def preprocess_text_old(text, raw_input=True):
|
||||
# TODO: Handle ARPAbet
|
||||
pre_sequence = ""
|
||||
for line in text.split("\n"):
|
||||
@@ -96,6 +122,7 @@ def preprocess_text(text, raw_input=True):
|
||||
pass
|
||||
pre_sequence += line
|
||||
|
||||
print(pre_sequence)
|
||||
with torch.no_grad():
|
||||
# save VRAM by not including gradients
|
||||
sequence = np.array(text_to_sequence(pre_sequence, ['english_cleaners']))[None, :]
|
||||
|
||||
Reference in New Issue
Block a user