[英]How with google text-to-speech (gTTS) I can save to the MP3 file 2 Variables with different languages? (Python)
如何使用 google text-to-speech 我可以保存到 MP3 文件 2 不同语言的变量? 请帮帮我。 Everywhere 仅针对 1 种语言编写。 这是我的代码:
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 действовать
with open('from_file.mp3', 'wb') as ff:
tts1.write_to_fp(ff)
tts2.write_to_fp(ff)
os.system("from_file.mp3")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.