http://dict.youdao.com/speech?audio=keyword
import sys import requests result=[] #打开生词txt文件 with open('C:\\Users\\11310\\Desktop\\Word List\\txt\\words.txt','r') as f: for line in f: result.append(list(line.strip('\n').split(','))) for i in result: var='http://dict.youdao.com/speech?audio=' word=''.join(i) var1=var[:36]+word res=requests.get(var1).content path0='C:\\Users\\11310\\Desktop\\Word List\\mp3\\' path1=path0[:37]+word path1=path1+'.mp3' print(path1) f = open(path1, 'wb') f.write(res) f.close()
在txt文件中写入单词,一行一个,输出mp3格式的单词音频,使用有道翻译接口,未检查单词拼写是否错误,拼写错误也会有音频文件。音频为网易机器生成,不能完全代表单词读音。仅供学习交流使用,请勿滥用。