import argparse
from covering_m import covering_m
from covering_p import covering_p
import os.path
import sys

parser = argparse.ArgumentParser(
	description="This program synthesizes a user-specific natural speech by inputting the username and a script to be synthesized.",
	epilog="Thanks for using our program.")
parser.add_argument('-u', nargs='?', type=str, default='abk', 
					help="username, default is 'abk'")                  
parser.add_argument('-f', nargs='?', type=str, required=True, 
					help="input_file - the file to be synthesized")
parser.add_argument('-o', nargs='?', type=str, help="output_file - name the output file")
parser.add_argument('-align', choices=['m','p','b'], default='b',
					help="pick the user library generated by which aligner, [m-Montreal, p-Prosody, b-both(default)]") 
parser.add_argument('-cost', choices=[0,1,2],
					help="three different cost matrices according to three different ways of grouping")
parser.add_argument('-rate', nargs='?', type=float, choices=range(0,1),
					help="different weights to the concatenation cost and the phoneme cost") #additional problems may be introduced

args = parser.parse_args()
username = args.u
input_file = args.f
output_file = args.o
aligner = args.align
cost = args.cost
rate = args.rate

#check if the user library exists
if not os.path.isdir(username):
	print("The user library - {} doesn't exist!".format(username))

print(aligner)
if aligner == 'b':
	print("Covering by Montreal ... ... ")
	covering_m(username, input_file)
	print("Covering by Prosody ... ... ")
	covering_p(username, input_file)
elif aligner == 'm':
	print("Covering by Montreal ... ... ")
	covering_m(username, input_file)
else:
	print("Covering by Prosody ... ... ")
	covering_p(username, input_file)