Added parsing of command line arguments
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
# — https://huggingface.co/facebook/fastspeech2-en-ljspeech
|
# — https://huggingface.co/facebook/fastspeech2-en-ljspeech
|
||||||
# — https://github.com/AI-Guru/arxiv-reader
|
# — https://github.com/AI-Guru/arxiv-reader
|
||||||
|
|
||||||
|
import argparse
|
||||||
from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
|
from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
|
||||||
from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
|
from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
|
||||||
import scipy
|
import scipy
|
||||||
@@ -15,6 +16,12 @@ def main():
|
|||||||
Defined starting point of source code.
|
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(
|
models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
|
||||||
"facebook/fastspeech2-en-ljspeech",
|
"facebook/fastspeech2-en-ljspeech",
|
||||||
arg_overrides={"vocoder": "hifigan", "fp16": False}
|
arg_overrides={"vocoder": "hifigan", "fp16": False}
|
||||||
@@ -28,7 +35,7 @@ def main():
|
|||||||
sentences = []
|
sentences = []
|
||||||
|
|
||||||
# Read input file
|
# Read input file
|
||||||
with open(f"input.txt", "r") as f:
|
with open(args['input'], "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
|
|
||||||
# Convert to sentences
|
# Convert to sentences
|
||||||
@@ -60,7 +67,7 @@ def main():
|
|||||||
full_wave_file.extend(wav)
|
full_wave_file.extend(wav)
|
||||||
|
|
||||||
full_wave_file = np.array(full_wave_file, dtype=np.float32)
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
Reference in New Issue
Block a user