I want to convert the numpy.pdf file to audio format and play along but I keep getting segmentation fault. I posted wrong code before.Here is the actual one.It worked if I play it but get segmentation error while saving the file outside the loop and the loops never stops if I tried to save the file inside the loop or it would just steps after sometime.Help would be appreciated.I am just begning my python carer.
import pyttsx3
import PyPDF2
engine = pyttsx3.init()
user_file = input("Plz enter filename ")
file_object = open(user_file, 'rb')
reader = PyPDF2.PdfFileReader(file_object)
count = reader.numPages
new_page = []
format_choose = int(input("Enter 1 or 2")
if format_choose == 1:
user_input = int(input("Enter the page to begin.> "))
for i in range(count):
page = reader.getPage(i)
new_page.append(page.extractText())
text = "".join(new_page)
engine.setProperty('rate', 125)
engine.say(text)
engine.runAndWait()
elif format_choose == 2:
output_file = input("Enter the file name")
for i in range(count):
page = reader.getPage(i)
new_page.append(page.extractText())
text = "".join(new_page)
engine.setProperty('rate', 125)
engine.save_to_file(text, output_file)
engine.runAndWait()