mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-17 00:23:14 +00:00
remote false start
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
"""
|
||||
Base class for Arpabet Sequence Transformers.
|
||||
"""
|
||||
|
||||
class ArpabetTransformer:
|
||||
|
||||
def transform_text(self, text):
|
||||
"""
|
||||
Input: String text sequence
|
||||
Output: 2-dimensional tensor sequence
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import torch
|
||||
import numpy as np
|
||||
|
||||
from base import ArpabetTransformer
|
||||
|
||||
class EnglishMixedArpabetTransformerV1(ArpabetTransformer):
|
||||
|
||||
def transform_text(self, text):
|
||||
pre_sequence = self._handle_multi_lines(text)
|
||||
return self._convert_to_sequence(pre_sequence)
|
||||
|
||||
def _handle_multi_lines(self, text):
|
||||
# NB: This code is adapted from vanilla Tacotron. It's not very graceful.
|
||||
pre_sequence = ''
|
||||
for line in text.split("\n"):
|
||||
if len(line) < 1:
|
||||
continue
|
||||
if line[-1] != ";":
|
||||
line = line + ";"
|
||||
pre_sequence += line
|
||||
|
||||
return pre_sequence
|
||||
|
||||
def _convert_to_sequence(self, pre_sequence_text):
|
||||
with torch.no_grad():
|
||||
# save VRAM by not including gradients
|
||||
sequence = np.array(text_to_sequence(pre_sequence_text, ['english_cleaners']))[None, :]
|
||||
sequence = torch.autograd.Variable(torch.from_numpy(sequence)).cuda().long()
|
||||
return sequence
|
||||
Reference in New Issue
Block a user