Dec-30-2022, 03:19 PM
(This post was last modified: Dec-30-2022, 04:05 PM by Yoriz.
Edit Reason: Added code tags
)
I'm mostly a micro python guy on ESP32 devices but recently ran across a lot of python programming videos on youtube. One caught my eye and have been trying to get it working in PyCharm. It is a program to convert a PDF file to text and then convert that to an mp3 file which is an audio file speaking the text that was in the PDF. Here is a link to the video... https://www.youtube.com/watch?v=LXsdt6RMNfY she is using oneAPI which also requires visual studio. I have installed them but they are a bit intimidating.
It is mostly working in pycharm... it does print out the text but instead of speaking the text it is saying each letter in the file.
This is my version of her program... hers had some deprecation issues though is was a fairly recent video.
Not sure how I did it but at one point it displayed the output text file and it was only one letter per line which would kind of explain why it is saying each letter instead of the words.
I tired writing the text to a file but got an error.... file must have a 'write' attribute
I've included test_pdf.pdf
It is mostly working in pycharm... it does print out the text but instead of speaking the text it is saying each letter in the file.
This is my version of her program... hers had some deprecation issues though is was a fairly recent video.
Not sure how I did it but at one point it displayed the output text file and it was only one letter per line which would kind of explain why it is saying each letter instead of the words.
I tired writing the text to a file but got an error.... file must have a 'write' attribute
I've included test_pdf.pdf
import pyttsx3,PyPDF2 import pickle from PyPDF2 import PdfReader reader = PdfReader('test_pdf.pdf') speaker = pyttsx3.init() text = reader.pages[0] file = text.extract_text() clean_text = file.strip().replace('\n', ' ') #with open('resume.txt', 'wb') as pickle_file: # pickle.dump(file, 'pickle_file') print(file) #pickle.dump(clean_text, 'resume.txt') #name mp3 file whatever you would like speaker.say(file) #speaker.save_to_file(file, 'story.mp3') speaker.runAndWait() speaker.stop()
Attached Files