|
|
@ -8,7 +8,7 @@ from os import path
|
|
|
|
|
|
|
|
|
|
|
|
import markdown
|
|
|
|
import markdown
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
from gtts import gTTS
|
|
|
|
from gtts import gTTS, gTTSError
|
|
|
|
|
|
|
|
|
|
|
|
import config
|
|
|
|
import config
|
|
|
|
import search
|
|
|
|
import search
|
|
|
@ -320,7 +320,12 @@ def prepare_tts():
|
|
|
|
clean_text = ""
|
|
|
|
clean_text = ""
|
|
|
|
for f in files:
|
|
|
|
for f in files:
|
|
|
|
clean_text = get_text_only(f)
|
|
|
|
clean_text = get_text_only(f)
|
|
|
|
tts = gTTS(clean_text, lang=LANGUAGE.split("-")[0])
|
|
|
|
|
|
|
|
_, tail = os.path.split(f)
|
|
|
|
_, tail = os.path.split(f)
|
|
|
|
new_filename = "static/tmp/" + os.path.splitext(tail)[0] + ".mp3"
|
|
|
|
new_filename = "static/tmp/" + os.path.splitext(tail)[0] + ".mp3"
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
tts = gTTS(clean_text, lang=LANGUAGE.split("-")[0])
|
|
|
|
tts.save(new_filename)
|
|
|
|
tts.save(new_filename)
|
|
|
|
|
|
|
|
except gTTSError as e:
|
|
|
|
|
|
|
|
print("Too many request to the google servers. Try it again later.")
|
|
|
|
|
|
|
|
os.remove(new_filename)
|
|
|
|
|
|
|
|
return e
|
|
|
|