如何使用谷歌文本转语音我可以保存到MP3文件2使用不同语言的变量? 请帮我。到处都只写一种语言。 这是我的代码:
from gtts import gTTS
import os
import pickle
import pandas as pd
frame = pd.read_csv('file.csv', header=0, sep = '\t', encoding='cp1251')
print(frame)
text1 = list()
text2 = list()
for a, b in zip(frame['English'], frame['Русский']):
text1.append(a)
text2.append(b)
print(text1,
text2)
text1 = str(text1)
text2 = str(text2)
tts1 = gTTS(text=text1, lang='en')
tts2 = gTTS(text=text2, lang='ru')
# tts2.save("from_file.mp3") it work just for one Variable!
with open('from_file.mp3', 'wb') as pickle_file:
pickle.dump([tts1, tts2], pickle_file)
# with pickle it doesn't work!
os.system("from_file.mp3")
文件内容:
English Русский
tell говорить
fly летать
sit сидеть
act действовать
答案 0 :(得分:0)
A