-
Notifications
You must be signed in to change notification settings - Fork 381
Open
Labels
Description
It works great for smaller chunk of texts. But if I try to convert pdfs like a 7 page pdf it always fails after a very long wait. it would run for hours and fail, wanted to know if this is meant only for smaller texts? what's the alternative??
The error would usually be a connection error.,, but that's expected if it runs for few hours to convert a seven page pdf right??
gtts.tts.gTTSError: 500 (Internal Server Error) from TTS API. Probable cause: Uptream API error. Try again later.
My code is very simple and straight-forward :
import pdftotext
from gtts import gTTS
from os.path import splitext
filelocation = "C:\\Users\\vna\\Downloads\\catch22.pdf"
with open(filelocation, "rb") as f: # open the file in reading (rb) mode and call it f
pdf = pdftotext.PDF(f) # store a text version of the pdf file f in pdf variable
string_of_text = ''
for text in pdf:
string_of_text += text
final_file = gTTS(text=string_of_text, lang='en') # store file in variable
outname = splitext(filelocation)[0] + '.mp3'
final_file.save(outname) # save file to computer