Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define synthesizer.py main #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions vietTTS/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
from .nat.config import FLAGS
from .nat.text2mel import text2mel

parser = ArgumentParser()
parser.add_argument("--text", type=str)
parser.add_argument("--output", default="clip.wav", type=Path)
parser.add_argument("--sample-rate", default=16000, type=int)
parser.add_argument("--silence-duration", default=-1, type=float)
parser.add_argument("--lexicon-file", default=None)
args = parser.parse_args()


def nat_normalize_text(text):
text = unicodedata.normalize("NFKC", text)
Expand All @@ -31,9 +23,18 @@ def nat_normalize_text(text):
return text.strip()


text = nat_normalize_text(args.text)
print("Normalized text input:", text)
mel = text2mel(text, args.lexicon_file, args.silence_duration)
wave = mel2wave(mel)
print("writing output to file", args.output)
sf.write(str(args.output), wave, samplerate=args.sample_rate)
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("--text", type=str)
parser.add_argument("--output", default="clip.wav", type=Path)
parser.add_argument("--sample-rate", default=16000, type=int)
parser.add_argument("--silence-duration", default=-1, type=float)
parser.add_argument("--lexicon-file", default=None)
args = parser.parse_args()

text = nat_normalize_text(args.text)
print("Normalized text input:", text)
mel = text2mel(text, args.lexicon_file, args.silence_duration)
wave = mel2wave(mel)
print("writing output to file", args.output)
sf.write(str(args.output), wave, samplerate=args.sample_rate)