You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
import subprocess
|
|
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
letter_year = sys.argv[1]
|
|
|
|
|
wav_path = sys.argv[2]
|
|
|
|
|
|
|
|
|
|
fn = f"./{letter_year}/bh-annual-letter-{letter_year}.txt"
|
|
|
|
|
|
|
|
|
|
output_dir = f"./{letter_year}/"
|
|
|
|
|
subprocess.run(['mkdir', '-p', output_dir])
|
|
|
|
|
|
|
|
|
|
with open(fn) as f:
|
|
|
|
|
lines = f.readlines()
|
|
|
|
|
all_text = ''.join(lines)
|
|
|
|
|
sentences = re.matches(r"(\w\w+\.)[\s\n]", all_text)
|
|
|
|
|
sentences = re.split(r"(\w\w+\.)[\s\n]", all_text)
|
|
|
|
|
count = len(sentences)
|
|
|
|
|
|
|
|
|
|
for (i, sentence) in enumerate(sentences):
|
|
|
|
|
if (sentence[0] == '('):
|
|
|
|
|
sentence = sentence[1:]
|
|
|
|
|
if (sentence[-1] == ')'):
|
|
|
|
|
sentence = sentence[:-1]
|
|
|
|
|
|
|
|
|
|
subprocess.run([
|
|
|
|
|
"tts",
|
|
|
|
|
"--text", f"{sentence}",
|
|
|
|
|
"--model_name", "tts_models/multilingual/multi-dataset/your_tts",
|
|
|
|
|
"--speaker_wav", wav_path,
|
|
|
|
|
#"--reference_wav", ref,
|
|
|
|
|
# "--use_cuda", "0",
|
|
|
|
|
"--out_path", f"{output_dir}/bh-{letter_year}-{str(i).zfill(3)}.wav",
|
|
|
|
|
"--language_idx", "en"
|
|
|
|
|
])
|
|
|
|
|
|