Google翻訳の音声データAPI???
認証情報なしで、なぜかが下記のGoogle翻訳の音声データAPIを使えます
しかも、制限なし
https://translate.google.com/translate_tts?ie=UTF-&&client=tw-ob&tl=en&q=
PythonでGoogle翻訳APIから音声データを取得
import requests
import os
def download_mp3(url, filepath):
response = requests.get(url, stream=True)
if response.status_code == 200:
with open(filepath, 'wb') as file:
for chunk in response.iter_content(1024):
file.write(chunk)
print("音声はダウンロードできました!")
else:
print("音声はダウンロードできませんでした!")
# 呼び出し
with open('toeic(1).txt') as f:
lines = f.readlines()
lines_strip = [line.strip() for line in lines]
# print(lines_strip)
word = "begin"
mp3_url = 'https://translate.google.com/translate_tts?ie=UTF-&&client=tw-ob&tl=en&q='
filename = "begin.mp3"
download_mp3(mp3_url+word, filename)
参考サイト