调用部分一与二,完成文本至MP3文件的转化。
interface.py
# 20190526
import sys
import url2txt # 网址提取文本
import TTS_API # 文本信息转换为语音
# 自动播放模块未写
import math
root_path = sys.path[0]
txt_path = root_path+'\\'+'txt_file'
audio_path = root_path+'\\'+'audio_file'
chunk = 500 # 字节
url = 'https://zhuanlan.zhihu.com/p/61617200'
txt_data = url2txt.url2txt(url,txt_path,'content')
len_data = len(txt_data)
num_audio = math.ceil(len_data/chunk)
x = 0
y = chunk
for single in range(0,num_audio):
TTS_API.TTS(txt_data[x:y],audio_path,str(single))
x = y
y = y+chunk