Advertisement
Fsoky

Из текста в голос | Fsoky

Sep 8th, 2020
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. import pyttsx3 as pt
  2. from gtts import gTTS
  3. from tqdm import tqdm as bar
  4. from time import sleep
  5.  
  6. path = input("Введите путь к файлу: ")
  7.  
  8.  
  9. def convert(path):
  10.     engine = pt.init()
  11.  
  12.     with open(path, "r") as file:
  13.         txt = file.read()
  14.        
  15.         engine.say(txt)
  16.         engine.runAndWait()
  17.  
  18.     for i in bar(range(100)):
  19.         sleep(0.01)
  20.  
  21.     tts = gTTS(text = txt, lang = "ru")
  22.     tts.save("filename.mp3")
  23.  
  24.     print("File saved!")
  25.  
  26.  
  27. conver(path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement