1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| import os from faker import Faker
def file_exists(): file_path = '/root/file' if os.path.exists(file_path): os.remove(file_path)
def create_sentence(i): f = Faker('zh_CN') s = f.sentence(nb_words=i, variable_nb_words=False) return s
def create_document(sentence_list): create_paragraph = '<audio src="询问.wav">{}</audio>{}<audio src="金额.wav">{}</audio>{}<audio src="请您在.wav" >{}</audio>{}<audio src="逾期提醒.wav" >{}</audio>\n'.format(*sentence_list)
with open('/root/file','at',encoding='utf-8') as f: f.write(create_paragraph)
def main(): file_exists()
concurrent_time = int(input("请输入并发次数:")) loop_time = int(input("请输入循环次数:"))
word_list = [21,3,15,1,18,5,33]
for i in range(loop_time*concurrent_time): sentence_list = [] for i in word_list: data = create_sentence(i) sentence_list.append(data) create_document(sentence_list)
main()
|