調(diào)用部分一與二,完成文本至MP3文件的轉(zhuǎn)化。
interface.py
# 20190526
import sys
import url2txt # 網(wǎng)址提取文本
import TTS_API # 文本信息轉(zhuǎn)換為語(yǔ)音
# 自動(dòng)播放模塊未寫
import math
root_path = sys.path[0]
txt_path = root_path+'\\'+'txt_file'
audio_path = root_path+'\\'+'audio_file'
chunk = 500 # 字節(jié)
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