Skip to content

converting a longer pdf - of say 7 - 8 pages #297

@vivekna

Description

@vivekna

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions