Added parsing of command line arguments

This commit is contained in:
Heiko J Schick
2022-08-30 20:42:27 +02:00
parent 494b15fd91
commit 27837b270b
+9 -2
View File
@@ -4,6 +4,7 @@
# — https://huggingface.co/facebook/fastspeech2-en-ljspeech
# — https://github.com/AI-Guru/arxiv-reader
import argparse
from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
import scipy
@@ -15,6 +16,12 @@ def main():
Defined starting point of source code.
"""
# Parsing command line arguments
parser = argparse.ArgumentParser(description='Convert teext to speech.')
parser.add_argument('-i','--input', help='Input filename', required=True)
parser.add_argument('-o','--output', help='Output filename', required=True)
args = vars(parser.parse_args())
models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
"facebook/fastspeech2-en-ljspeech",
arg_overrides={"vocoder": "hifigan", "fp16": False}
@@ -28,7 +35,7 @@ def main():
sentences = []
# Read input file
with open(f"input.txt", "r") as f:
with open(args['input'], "r") as f:
lines = f.readlines()
# Convert to sentences
@@ -60,7 +67,7 @@ def main():
full_wave_file.extend(wav)
full_wave_file = np.array(full_wave_file, dtype=np.float32)
scipy.io.wavfile.write("test.wav", rate, full_wave_file)
scipy.io.wavfile.write(args['output'], rate, full_wave_file)
if __name__ == "__main__":
main()