| Conditions | 5 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | #!/usr/bin/python |
||
| 17 | def tts(bot, update, args): |
||
|
|
|||
| 18 | text = "".join(args) |
||
| 19 | if len(text) == 0: |
||
| 20 | update.message.reply_text("Type in some text ^^") |
||
| 21 | return |
||
| 22 | update.message.chat.send_action(ChatAction.RECORD_AUDIO) |
||
| 23 | lang="en" |
||
| 24 | tts = gTTS(text, lang) |
||
| 25 | tts.save(path + "voice.mp3") |
||
| 26 | with open(path + "voice.mp3", "rb") as f: |
||
| 27 | linelist = list(f) |
||
| 28 | linecount = len(linelist) |
||
| 29 | if linecount == 1: |
||
| 30 | update.message.chat.send_action(ChatAction.RECORD_AUDIO) |
||
| 31 | lang = "ru" |
||
| 32 | tts = gTTS(text, lang) |
||
| 33 | tts.save(path + "voice.mp3") |
||
| 34 | with open(path + "voice.mp3", "rb") as speech: |
||
| 35 | update.message.reply_voice(speech, quote=False) |
||
| 36 | print(datetime.datetime.now(), ">>>", "Done tts", ">>>", update.message.from_user.username) |