def enqueue_tts(self, vchan: discord.Channel,
text: str,
vol: int=None,
priority: int=5,
tchan: discord.Channel=None,
language: str=None):
if vol is None:
vol = self.tts_volume
if language is None:
language = self.language
tts = gTTS(text=text, lang=language)
path = self.temp_filepath + ''.join(random.choice(
'0123456789ABCDEF') for i in range(12)) + ".mp3"
tts.save(path)
try:
item = {'cid': vchan.id, 'path': path, 'vol': vol,
'priority': priority, 'delete': True, 'tchan': tchan}
self.master_queue.put_nowait(item)
return True
except asyncio.QueueFull:
return False
评论列表
文章目录