Converting Pdf Text in to Audio Files

 Converting Pdf Text in to Audio Files:


Libraries:-

Here we are using PyPDF library to read text from the pdf file and then we are converting the text into speech and save it as an audio file.

Program:

import pyttsx3,PyPDF2
pdfrReader=PyPDF2.PdfFileReader(open('File_1.pdf','rb'))
audio=pyttsx3.init()
for page_num in range(pdfrReader.numPages):
text=pdfrReader.getPage(page_num).extractText()
cleanText=text.strip().replace('\n',' ')
print(cleanText)
audio.say(cleanText)
audio.save_to_file(cleanText,'File_1.mp3')
audio.runAndWait()
audio.stop()
THANKS!!

Comments

Popular posts from this blog

Python namespaces & LEGB rule in Python