调用的是百度翻译的接口,成品会生成到软件目录,文件名为文字的前10个字。
# -*- coding: utf-8 -*- """ ------------------------------------------------- @ Author :Lan @ Blog :www.lanol.cn @ Date : 2020/6/21 @ Description:I'm in charge of my Code ------------------------------------------------- """ import requests word = input("请输入要转换的文字:") speed = input("请输入语音的速度:") url = f'https://fanyi.baidu.com/gettts?lan=zh&text={word}&spd={speed}&source=web' result = requests.get(url).content with open(f'{word[:10]}.mp3', 'wb') as f: f.write(result) input(f"【{word}】语音成品已生成在软件根目录")
评论 (0)