Lewis saving the day! I meant to link that 😆 You can find the source code here: github.com/TiffinTech/python-pdf-audo github.com/TiffinTech/python-automate-delete-files
@@TiffInTech hey Tiff, just sent u dm on insta , i found your channel today , i have mentioned my project work as well , i can say i can work for just $500 USD , a month . i would request you to please reply.
So I just discovered your channel. One thing many tech channels have in common is the presenter is horrible- fast paced, difficult to understand, and language barrier. This channel is none of those. So glad to find a channel that’s simple and straightforward.
This worked awesome!! I had to do a couple of workarounds but worked like a charm after that, this is so usefull for making audio books HERE IS THE UPDATED CODE THAT WORKED FOR ME: from PyPDF2 import PdfReader import pyttsx3 from gtts import gTTS def extract_text_from_pdf(pdf_path): reader = PdfReader(pdf_path) text = "" for page in reader.pages: text += page.extract_text() return text def convert_text_to_speech(text, output_file): tts = gTTS(text) tts.save(output_file) pdf_path = "book.pdf" all_text = extract_text_from_pdf(pdf_path) output_file = "output.mp3" convert_text_to_speech(all_text, output_file) And there are also options to modify the pitch of the voice in the library if anyone is interested """VOICE""" voices = engine.getProperty('voices') #getting details of current voice #engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male engine.setProperty('voice', voices[1].id) #changing index, changes voices. 1 for female
You finally convinced me to learn Python on my own. I'm a C++ and C# programmer and we don't use Python at work. You have been showing us what we can do with Python and I am amazed. Thanks for the tips. I'm interested in face recognition and fingerprints reading softwares.
So, a really helpful function here would be the os walk function. It'll recursively iterate through every file in a directory. From there, in your loop you could check the file extension and remove based on that or any other condition. From there, you could use the argparse package and take arguments from the cli to ask the user things like what files they want to remove or the file extensions they want to remove. Then after that, you could think about putting everything in functions so as to not pollute the global namespace and use the standard "if __name__ == '__main__'" pattern. Lots of different, cool things you can do here, a great beginner project!
Thank you for the 2 inspiring projects. When trying the first one, I had to spend quite a lot of time debugging, possibly due to the fact that the used modules have been updated since the video has been made and a number of functions had been renamed (even ChatGPT is not updated regarding PyPDF2 3.0.0 !). If you wish to save your time, here is the updated code, with a little correction to the loop: import pyttsx3, PyPDF2 title = input("Which book would you like to listen to? ") + ".pdf" pdfreader = PyPDF2.PdfReader(open(title, 'rb')) speaker = pyttsx3.init() first_page = input("Starting with what page? ") last_page = input("Ending with what page? ") text = "" for page_number in range(int(first_page - 1), int(last_page)): text = text + pdfreader.pages[page_number].extract_text() clean_text = text.strip().replace(' ', ' ') print(clean_text) speaker.save_to_file(clean_text, 'result2.mp3') speaker.runAndWait speaker.stop() Now this version correctly prints out the converted text, but fails to create the mp3 file, don't know why. Chat GPT created this version of the code, which works, and the resulting voice reading is actually surprisingly clear: import fitz # PyMuPDF import pyttsx3 # Get the input file name title = input("Which book would you like to listen to? ") + ".pdf" # Initialize the text-to-speech engine speaker = pyttsx3.init() # User input for page range first_page = int(input("Starting with what page? ")) last_page = int(input("Ending with what page? ")) # Initialize an empty text variable text = "" # Open the PDF file pdf_document = fitz.open(title) # Loop through pages and extract text for page_number in range(first_page - 1, min(last_page, len(pdf_document))): page = pdf_document.load_page(page_number) text += page.get_text() # Close the PDF document pdf_document.close() # Save the MP3 file mp3_output = input("How would you like to call the resulting .mp3 file? ") + ".mp3" speaker.save_to_file(text, mp3_output) speaker.runAndWait() speaker.stop() print(f"Text extracted and saved as {mp3_output}")
Clean up picture duplicates and file them by category or by date if they don't have a category (in a table). Recognize certain categories automagically (sailing pictures, motorcycle pictures, faces). I like the PDF reader! So nice and simple.
1)Make a mouse and key logger, that saves mouse position, and major mouse events as a sequence. Use that to replay the sequence as fast as you want and as many times as u want using python. 2) find a way to put chatGPT talking to it self in python.
I read webnovels and few years ago before Tencent saw the huge western market there were a bunch of different websites for each novel, they were translated into english. So keeping track of them became a bit tiring and if I used a webpage if it was down, well RIP. So I taught myself javascript and made a chrome extension that I can use on my PC and Tablet, using firebase to store my novels database. I love stats so keeping track of what I read, how many words, chapters etc. was fun and useful. Some novels have character names that I don't like or use censorship on words, replacing them is easy, saving it for each novel individually and so on. Using it daily. Another project of mine is a tool to add some data into my spreadsheet, I made a project that does a lot of calculations for me and adds it to the Google spreadsheet. ofc there are others, but those too are my most used and useful ones.
Hi friends! In this video we are going to be building some fun things with Python that can actually help automate tasks in your life! What should we build next?
HI Sister you teach one of the best way i ever heard its very easy to under stand can i request you for a Python DSA with projects It will be very helpful for new comer like me to learn and implement Thank you sooo much
Music creating (or a music generating with a presetup options) in python, and sounds creating too. Need something like that for my first Pygame project because of can not to find any good music with a free licence to use inside a game which I'm trying to make like during last month😁
Just started a Data Science bootcamp - binge watching for tonnes of research. This was a great insight into something a little more interesting than the boring mess I've had thrown at me so far. Cheers.
Great video!!! I would like to suggest a correction at 05:03 :- text = pdfreader.getPage(page_num).extractText() actually works for PDFs that have a single page. But if a PDF has multiple pages, then the text gets overwritten with the contents of the new page. So, to avoid that we can append the new page's content to the current text and then format the text into clean_text after the end of the loop
Also, it seems there may be a limit on how much text can actually be saved as audio using the ".save_to_file()" method. No matter if i place a longer literal string value or use a variable the length of the audio file is always 6 seconds.
I wanted to make a grocery shopping list, by selecting recipes in a database, where the code adds up all the amounts for each common item. Results come out in an Excel spreadsheet!
In regards to project #1, please don't reinvent the bicycle => Android app Moon+ Reader supports PDF files and has TTS support. Can scroll anywhere in the file, confirm proper spelling in case you hear something completely whackaroo, don't have to deal with huge mp3 files.
When you said "if even worse" I knew the downloads folder was coming haha... My work computer's downloads folder is the scariest place on Earth. Great vid!
For Project 2, I really like using pathlib. You can iterate through a dynamic file path if you just did "for file in list(Path(downloads_folder).rglob('*.pdf')): file.unlink()" for pdf files. You can also do it via comprehension list.
This is the way. Pathlib should be the preferred way of dealing with file objects in place of the os library. There might be some niche scenarios where you want the os library, but for the most part PathLib provides what you need and in a superior format (i.e. it can handle various differences which occur between various file systems).
@@jaroslavkrbec582 clean_text += text.strip()... in the for loop (the + sign is adding text from every page to the string instead of rewriting the whole variable every iteration)
This was an inspiring video, I like the first project but I think i want to investigate observing images and attempting to pull text from images. I have a ton of old PDF's of scanned books that are no longer in print, that don't have any digital versions available, so it's just scans or nothing. That would be nice to be able to digitize.
Great job with the video Tiff! 🚀 If anyone’s looking for more Python tutorials, we’ve released Loguru logging, task scheduling, and more to help the community too 💪
if you want to organize the files, like .xlsx into Excel folder, .docx into word folder etc.. Create folders and In windows cmd, > move *.xlsx "Excel folder" > Move *.docx "word folder"
You did a good job with the title and the thumbnail! They actually fooled me into believing that this video had at least a bit of work put into it and it wouldn't be completely useless. This has nothing to do with automation nor with anything life related so good job on the clickbait I guess.
Love what's shared here, however I'm not there yet. Will come back after training myself a bit more with beginner courses. Btw, YT doesn't give me the option to save it to watch later, any idea?!
Permission to come aboard TnT 1st., time viewer of your show I thought that online discovery learning coding, is cool! MerryXmas🎅🏻 & may you have a fantastic holiday season❄,🤘🏼!
It's ok if you want something basic (it has no expressivity, it doesn't consider punctuation, etc.), it's not the old Loquendo, nor some new AI product.
Thank you showin for how Ideas and Phython works together, i want to learn python but i dont know if i can realize my ideas with python....a bit a complicated process. Data Science is interessting but i am not a coder so what can python do? My first idea that follows me is that i want to solve problemes inside linux and windows like errors you dont see (beginner struggle) and asking yourself whats going on here...i thougth python can grab some of the hidden infos and popup a little helper....and so so...like "you forgot using sudo - type in sudo - here is a webpage what shows u hints using it".
There are two convenient small things. I try first code and see the sentences it print, but it can’t save anything. If I just use "speak.say(clean_text)", I can hear it fine. But when I try to "speak.say(clean_text)", then "save_to_file(clean_text, file name.mp3)", the production of mp3 file ends up being ahead of the actual pronunciation.
Nice project! I've just noticed your video as I'm the maintainer of pypdf and PyPDF2. The timing was unfortunate: I've decided to deprecate PyPDF2 and move forward with pypdf. The syntax is pretty much the same. However, you're also using the deprecated PdfFileReader. This will fail with PyPDF2>=3.0.0. As you haven't pinned the version in 3:30 people will stumble over this.
hi how do we solve this issue i keep getting the"sequence indices must be integers" error when i try to do. text = reader.pages[page_num].extractText()
Here is updated code that should work with pypdf and grab all of the pages of a PDF document: import pyttsx3, pypdf pdfreader = pypdf.PdfReader(open('book.pdf', 'rb')) speaker = pyttsx3.init() clean_text = '' for page_num in range(len(pdfreader.pages)): text = pdfreader.pages[page_num].extract_text() clean_text += text.strip().replace(' ', '') print(clean_text) speaker.save_to_file(clean_text, 'story.mp3') speaker.runAndWait() speaker.stop()
Technically, there's nothing wrong with that loop (and it makes it look like the original in the video so it's good that way) but it would be more Pythonic (and readable) to avoid using that list like object to iterate over indices derived from that range. It's clearer to avoid indexing like that altogether since pdfreader.pages (as per above) is a list like object and can be iterated directly. That may not have been possible using PyPDF2 (I'm not sure -I'm sure @Martin Thoma could say). Do something like: for page in pdfreader.pages: text = page.extract_text() clean_text += text.strip().replace(' ', '')
Updated mp3 Code: ``` python import PyPDF2, pyttsx3 reader = PyPDF2.PdfReader(open('Roadside Picnic.pdf', 'rb')) speaker = pyttsx3.init() cleanText = '' for page in range(len(reader.pages)): text = reader.pages[page].extract_text() cleanText += text.strip().replace(' ', ' ') print(cleanText) speaker.save_to_file(cleanText, 'Roadside Picnic.mp3') speaker.runAndWait() speaker.stop() ``` The library had a revamp so all the functions were replaced, also the original code only converted the last paragraph because she overwrote clean text instead of appended lol
Here we are all looking at the code ... And what is the main thing? The main - is that she is a chic and beautiful girl!!! :)) Yes, and fluent in Python! Wow!!! :))
You seem to be a very sharp tech person, and your pdf to speech automation python script seems to be a very handy time saving script, but now, as I'm sure you know, AI like ChatGPT and many others do that, but I guess it's okay for someone who is learning to program. On the other hand, your delete files in download folder seems to take longer than if you just go into the downloads folder and delete them manually. So people are doing it to learn programming I guess it's okay, but it's a fail when it comes to automation. But I'll give you another chance. So go out there and find some automation scripts that really can save time and effort... you can do it!
Very good topic. Spelling mistakes are normal in live coding situations and non scripted sessions. Don’t initiate influence leakage by apologizing about your spellings when it is not a big deal. You have a good topic, good professional presentation however your copy/ script can be rehearsed to improve the flow. It gets better with experience and chatGPT. Good luck.
New to your channel, and I appreciate the production values and simple approach, but I found the video title a bit clickbaity - converting a PDF file to MP3 and deleting one file in your downloads folder isn't anyone's definition of "the ultimate guide" to "automating my life". Yes, you could extend them both a bit, but neither automate much at all - running a Python program still requires you to run it, and converting the MP3 still requires you to both run it and then play the file. I'm not hating, just wishing that people would be more honest in their titles.
Thank you really , can you make a python tutorial for complete beginners by building projects from scratch like 30 days of python , you really know how to teach , all respect and love from Belgium
Hi Tiff, Nice video and well-spoken. The PDF to audio might have a problem. I think that it will only produce the last page as audio, because all previous pages will be overwritten in the for loop.
Hello , the thing I like in ur programming way is that u are not programming like super heroes , but u programme like ordinary people and u do magical things 🌹
OMG. Wanted so much to watch this but I can't concentrate! You are so beautiful. lol Also wanted to ask why are you not a model but just watched your 1st video :)
Python World Peace App? Kidding aside, I did ask Chat GPT about things like that. Maybe a million advanced Quantum computers might help it along a bit.
Gonna need that source code 👀
Lewis saving the day! I meant to link that 😆 You can find the source code here:
github.com/TiffinTech/python-pdf-audo
github.com/TiffinTech/python-automate-delete-files
Hey Lewis! I love your videos by the way :) Have a great day!
@@TiffInTech hey Tiff, just sent u dm on insta , i found your channel today , i have mentioned my project work as well , i can say i can work for just $500 USD , a month . i would request you to please reply.
How to have your email adress?
@@TiffInTech Will it read epub files or is it just going to be PDFs? Also, what text editor have you used, please?
So I just discovered your channel. One thing many tech channels have in common is the presenter is horrible- fast paced, difficult to understand, and language barrier. This channel is none of those. So glad to find a channel that’s simple and straightforward.
This worked awesome!! I had to do a couple of workarounds but worked like a charm after that, this is so usefull for making audio books HERE IS THE UPDATED CODE THAT WORKED FOR ME:
from PyPDF2 import PdfReader
import pyttsx3
from gtts import gTTS
def extract_text_from_pdf(pdf_path):
reader = PdfReader(pdf_path)
text = ""
for page in reader.pages:
text += page.extract_text()
return text
def convert_text_to_speech(text, output_file):
tts = gTTS(text)
tts.save(output_file)
pdf_path = "book.pdf"
all_text = extract_text_from_pdf(pdf_path)
output_file = "output.mp3"
convert_text_to_speech(all_text, output_file)
And there are also options to modify the pitch of the voice in the library if anyone is interested
"""VOICE"""
voices = engine.getProperty('voices') #getting details of current voice
#engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male
engine.setProperty('voice', voices[1].id) #changing index, changes voices. 1 for female
You finally convinced me to learn Python on my own. I'm a C++ and C# programmer and we don't use Python at work. You have been showing us what we can do with Python and I am amazed. Thanks for the tips. I'm interested in face recognition and fingerprints reading softwares.
give me your email to communicate with you please , I am interested in programmimg brave things
So, a really helpful function here would be the os walk function. It'll recursively iterate through every file in a directory. From there, in your loop you could check the file extension and remove based on that or any other condition. From there, you could use the argparse package and take arguments from the cli to ask the user things like what files they want to remove or the file extensions they want to remove. Then after that, you could think about putting everything in functions so as to not pollute the global namespace and use the standard "if __name__ == '__main__'" pattern. Lots of different, cool things you can do here, a great beginner project!
Thank you for the 2 inspiring projects.
When trying the first one, I had to spend quite a lot of time debugging, possibly due to the fact that the used modules have been updated since the video has been made and a number of functions had been renamed (even ChatGPT is not updated regarding PyPDF2 3.0.0 !). If you wish to save your time, here is the updated code, with a little correction to the loop:
import pyttsx3, PyPDF2
title = input("Which book would you like to listen to?
") + ".pdf"
pdfreader = PyPDF2.PdfReader(open(title, 'rb'))
speaker = pyttsx3.init()
first_page = input("Starting with what page?
")
last_page = input("Ending with what page?
")
text = ""
for page_number in range(int(first_page - 1), int(last_page)):
text = text + pdfreader.pages[page_number].extract_text()
clean_text = text.strip().replace('
', ' ')
print(clean_text)
speaker.save_to_file(clean_text, 'result2.mp3')
speaker.runAndWait
speaker.stop()
Now this version correctly prints out the converted text, but fails to create the mp3 file, don't know why. Chat GPT created this version of the code, which works, and the resulting voice reading is actually surprisingly clear:
import fitz # PyMuPDF
import pyttsx3
# Get the input file name
title = input("Which book would you like to listen to?
") + ".pdf"
# Initialize the text-to-speech engine
speaker = pyttsx3.init()
# User input for page range
first_page = int(input("Starting with what page?
"))
last_page = int(input("Ending with what page?
"))
# Initialize an empty text variable
text = ""
# Open the PDF file
pdf_document = fitz.open(title)
# Loop through pages and extract text
for page_number in range(first_page - 1, min(last_page, len(pdf_document))):
page = pdf_document.load_page(page_number)
text += page.get_text()
# Close the PDF document
pdf_document.close()
# Save the MP3 file
mp3_output = input("How would you like to call the resulting .mp3 file?
") + ".mp3"
speaker.save_to_file(text, mp3_output)
speaker.runAndWait()
speaker.stop()
print(f"Text extracted and saved as {mp3_output}")
Clean up picture duplicates and file them by category or by date if they don't have a category (in a table). Recognize certain categories automagically (sailing pictures, motorcycle pictures, faces). I like the PDF reader! So nice and simple.
1)Make a mouse and key logger, that saves mouse position, and major mouse events as a sequence. Use that to replay the sequence as fast as you want and as many times as u want using python.
2) find a way to put chatGPT talking to it self in python.
just call the function with the prompt as the response of the previous function call
I read webnovels and few years ago before Tencent saw the huge western market there were a bunch of different websites for each novel, they were translated into english.
So keeping track of them became a bit tiring and if I used a webpage if it was down, well RIP.
So I taught myself javascript and made a chrome extension that I can use on my PC and Tablet, using firebase to store my novels database.
I love stats so keeping track of what I read, how many words, chapters etc. was fun and useful. Some novels have character names that I don't like or use censorship on words, replacing them is easy, saving it for each novel individually and so on. Using it daily.
Another project of mine is a tool to add some data into my spreadsheet, I made a project that does a lot of calculations for me and adds it to the Google spreadsheet.
ofc there are others, but those too are my most used and useful ones.
Hi friends! In this video we are going to be building some fun things with Python that can actually help automate tasks in your life! What should we build next?
HI Sister you teach one of the best way i ever heard its very easy to under stand can i request you for a Python DSA with projects It will be very helpful for new comer like me to learn and implement Thank you sooo much
Music creating (or a music generating with a presetup options) in python, and sounds creating too. Need something like that for my first Pygame project because of can not to find any good music with a free licence to use inside a game which I'm trying to make like during last month😁
a gui with tkinter would be great, so that opening an IDE is not necessary
She knows her stuff vsn we be freinds
Awesome tutorial and video Tiff!! Thanks for partnering with us on sharing #oneAPI 💙
💙💙💙
Thank you. Inspiring, regardless of the minor critical comments. Will work through it.
Just started a Data Science bootcamp - binge watching for tonnes of research. This was a great insight into something a little more interesting than the boring mess I've had thrown at me so far. Cheers.
Great video!!!
I would like to suggest a correction at 05:03 :-
text = pdfreader.getPage(page_num).extractText() actually works for PDFs that have a single page. But if a PDF has multiple pages, then the text gets overwritten with the contents of the new page. So, to avoid that we can append the new page's content to the current text and then format the text into clean_text after the end of the loop
Also, it seems there may be a limit on how much text can actually be saved as audio using the ".save_to_file()" method. No matter if i place a longer literal string value or use a variable the length of the audio file is always 6 seconds.
@@GrandAmericaMotorcycleRides No. It isn't the case for me. I'm able to save audio files that are even longer than 5 minutes!
@@teja00219 I'm actually getting 41 second files and it's always the last 41 seconds of the text.
Not to mention the clean_text var needs to be declared outside the for loop
Exactly my thoughts when I saw the code: with each iteration the `clean_text` variable will be overwritten (except for the single page case).
I wanted to make a grocery shopping list, by selecting recipes in a database, where the code adds up all the amounts for each common item. Results come out in an Excel spreadsheet!
In regards to project #1, please don't reinvent the bicycle => Android app Moon+ Reader supports PDF files and has TTS support. Can scroll anywhere in the file, confirm proper spelling in case you hear something completely whackaroo, don't have to deal with huge mp3 files.
I love the way you display what music you play!
After years of programming in C, C+, etc., I fell in love with Python, Numpy and Pandas. I sincerely recommend :).
When you said "if even worse" I knew the downloads folder was coming haha... My work computer's downloads folder is the scariest place on Earth. Great vid!
For Project 2, I really like using pathlib. You can iterate through a dynamic file path if you just did "for file in list(Path(downloads_folder).rglob('*.pdf')): file.unlink()" for pdf files. You can also do it via comprehension list.
This is the way. Pathlib should be the preferred way of dealing with file objects in place of the os library. There might be some niche scenarios where you want the os library, but for the most part PathLib provides what you need and in a superior format (i.e. it can handle various differences which occur between various file systems).
I second that. Arjian Codes did a video tutorial for pathlib some time ago, it's worth checking it out.
in the first part, you got my curiosity. second part, you got my attention
happy to hear!
This just what I´m lookig for! Thanks!
Tiff , you are the best !!. I have learned a lot with you !!. Thanks
might be a bug in pdf to mp3. You re only converting the last page of the pdf since you don't concatenate each page together in your loop.
Quite funny noone noticed :)
I tried and noticed immediately. Did you manage to solve it?
@@jaroslavkrbec582 clean_text += text.strip()... in the for loop (the + sign is adding text from every page to the string instead of rewriting the whole variable every iteration)
Damn you sir! for beating me to this EXACT comment.
@@firemankoxdi'm getting the error that clean_text is undefined when i do this any way to stop that
Beautiful and Smart! Just starting my Python journey - will be tuning in for more! Thx Tiff, keep 'em coming!
Thanks Andy! I just shared another Python video as welll ❤️ wishing you all the best
Excellent. Thank you, this gets me excited to learn python.
This was an inspiring video, I like the first project but I think i want to investigate observing images and attempting to pull text from images. I have a ton of old PDF's of scanned books that are no longer in print, that don't have any digital versions available, so it's just scans or nothing. That would be nice to be able to digitize.
This was cool!
Filling out forms has really been a livesaver for me. Especially when you can make it dynamic to work for several webpages.
Great job with the video Tiff! 🚀 If anyone’s looking for more Python tutorials, we’ve released Loguru logging, task scheduling, and more to help the community too 💪
if you want to organize the files, like .xlsx into Excel folder, .docx into word folder etc..
Create folders and In windows cmd,
> move *.xlsx "Excel folder"
> Move *.docx "word folder"
A good lesson, if you know the web, then learning python will not be difficult.
Your camera is amazing clear! The video looks so good and you look so good in it!
Would you mind me asking what dslr you are using?
You did a good job with the title and the thumbnail!
They actually fooled me into believing that this video had at least a bit of work put into it and it wouldn't be completely useless.
This has nothing to do with automation nor with anything life related so good job on the clickbait I guess.
Wow you made my life easier! Thanks a lot.
Love what's shared here, however I'm not there yet. Will come back after training myself a bit more with beginner courses. Btw, YT doesn't give me the option to save it to watch later, any idea?!
Great way to apply Python in real life!
Thanks Kevin!
Permission to come aboard TnT 1st., time viewer of your show I thought that online discovery learning coding, is cool! MerryXmas🎅🏻 & may you have a fantastic holiday season❄,🤘🏼!
like the pdf to audio idea. BTW; I believe you are only saving the last page to the mp3. Intended ?
Nice video and tutorial. Thanks. I
Thank you! excellent video
Nicely done!
It's ok if you want something basic (it has no expressivity, it doesn't consider punctuation, etc.), it's not the old Loquendo, nor some new AI product.
Thank you showin for how Ideas and Phython works together, i want to learn python but i dont know if i can realize my ideas with python....a bit a complicated process. Data Science is interessting but i am not a coder so what can python do? My first idea that follows me is that i want to solve problemes inside linux and windows like errors you dont see (beginner struggle) and asking yourself whats going on here...i thougth python can grab some of the hidden infos and popup a little helper....and so so...like "you forgot using sudo - type in sudo - here is a webpage what shows u hints using it".
Cooooool 😇😇😇
Amazing!!!
There are two convenient small things. I try first code and see the sentences it print, but it can’t save anything. If I just use "speak.say(clean_text)", I can hear it fine. But when I try to "speak.say(clean_text)", then "save_to_file(clean_text, file name.mp3)", the production of mp3 file ends up being ahead of the actual pronunciation.
Nice project!
I've just noticed your video as I'm the maintainer of pypdf and PyPDF2. The timing was unfortunate: I've decided to deprecate PyPDF2 and move forward with pypdf.
The syntax is pretty much the same. However, you're also using the deprecated PdfFileReader. This will fail with PyPDF2>=3.0.0. As you haven't pinned the version in 3:30 people will stumble over this.
hi how do we solve this issue i keep getting the"sequence indices must be integers" error when i try to do. text = reader.pages[page_num].extractText()
@@lennyuwaeme I guess page_num is not an integer in your case. Check what it is. Maybe None? Maybe a string?
Here is updated code that should work with pypdf and grab all of the pages of a PDF document:
import pyttsx3, pypdf
pdfreader = pypdf.PdfReader(open('book.pdf', 'rb'))
speaker = pyttsx3.init()
clean_text = ''
for page_num in range(len(pdfreader.pages)):
text = pdfreader.pages[page_num].extract_text()
clean_text += text.strip().replace('
', '')
print(clean_text)
speaker.save_to_file(clean_text, 'story.mp3')
speaker.runAndWait()
speaker.stop()
Technically, there's nothing wrong with that loop (and it makes it look like the original in the video so it's good that way) but it would be more Pythonic (and readable) to avoid using that list like object to iterate over indices derived from that range. It's clearer to avoid indexing like that altogether since pdfreader.pages (as per above) is a list like object and can be iterated directly. That may not have been possible using PyPDF2 (I'm not sure -I'm sure @Martin Thoma could say).
Do something like:
for page in pdfreader.pages:
text = page.extract_text()
clean_text += text.strip().replace('
', '')
@@JeffreyShaffer My maaan! Totally works. Thanks!
Updated mp3 Code:
``` python
import PyPDF2, pyttsx3
reader = PyPDF2.PdfReader(open('Roadside Picnic.pdf', 'rb'))
speaker = pyttsx3.init()
cleanText = ''
for page in range(len(reader.pages)):
text = reader.pages[page].extract_text()
cleanText += text.strip().replace('
', ' ')
print(cleanText)
speaker.save_to_file(cleanText, 'Roadside Picnic.mp3')
speaker.runAndWait()
speaker.stop()
```
The library had a revamp so all the functions were replaced, also the original code only converted the last paragraph because she overwrote clean text instead of appended lol
Great!
thank you!
Hello very good your class of Python
Neat, thanks.
The Intel one API thing sounds good.
It really is!
Chat GPT 4, can summarize and bring out highlights of a PDF as well. No code, unless you need to do it en masse as an integration
Here we are all looking at the code ... And what is the main thing? The main - is that she is a chic and beautiful girl!!! :)) Yes, and fluent in Python! Wow!!! :))
For those who are used to bundling exe files. pyinstaller for Python does a great job.
You seem to be a very sharp tech person, and your pdf to speech automation python script seems to be a very handy time saving script, but now, as I'm sure you know, AI like ChatGPT and many others do that, but I guess it's okay for someone who is learning to program. On the other hand, your delete files in download folder seems to take longer than if you just go into the downloads folder and delete them manually. So people are doing it to learn programming I guess it's okay, but it's a fail when it comes to automation. But I'll give you another chance. So go out there and find some automation scripts that really can save time and effort... you can do it!
I'm sure she was thrilled to get "another chance" from you. What an honor.
what a magic, great
i love it keep going
Very good topic. Spelling mistakes are normal in live coding situations and non scripted sessions. Don’t initiate influence leakage by apologizing about your spellings when it is not a big deal. You have a good topic, good professional presentation however your copy/ script can be rehearsed to improve the flow. It gets better with experience and chatGPT. Good luck.
Thanks for sharing Tiff, the pdf to audio project would create a lot of time savings for me!
Glad it was helpful!
Nice project, I love you.
Cool
New to your channel, and I appreciate the production values and simple approach, but I found the video title a bit clickbaity - converting a PDF file to MP3 and deleting one file in your downloads folder isn't anyone's definition of "the ultimate guide" to "automating my life". Yes, you could extend them both a bit, but neither automate much at all - running a Python program still requires you to run it, and converting the MP3 still requires you to both run it and then play the file. I'm not hating, just wishing that people would be more honest in their titles.
I loved this. Would love to see more projects that youve done!
pdf to mp3, very innovative
this was really cool
Subscribed and like!
Thank you!!
Likewise, thank you@@TiffInTechfor sharing your knowledge and inspire us!!
Thanks for this video....Could you tell me about your camera?....Is it a Sony video camera?
Thank you for sharing ....very helpful. I think that I will spend some time with Python thanks to your video. Very powerful and limitless
Great 👍👍
Thx Tiff, love this!
AMAZING
8:10 You might not know it but the concrete is softest at Sunday 7am.
I was struggling with pdf project so much, you don't have idea, I'm just thinking about more implementations that I can input and all that stuff lmao
would be nice if you could say why you used every syntax, then we could learn something
In the first section the mp3 only contains the last page, I believe, as text is not concatenated with prev. ones !
Thank you really , can you make a python tutorial for complete beginners by building projects from scratch like 30 days of python , you really know how to teach , all respect and love from Belgium
What learning material do you recommend for a beginner who wants to learn Python?
Great video! Can you play the .mp3 clip and/or post more info on how to match a specific voice for the mp3?
Hi Tiff, Nice video and well-spoken. The PDF to audio might have a problem. I think that it will only produce the last page as audio, because all previous pages will be overwritten in the for loop.
A pretty one 💚
the most amazing girl developer in the world! By the way its true ! Thanks greatly aus Deutschland
Thank you! Where in Germany are you from? :)
Hola, muy buen contenido
cool video)
Hi,
Love your videos, what setup (software and hardware) are you using to create them?
very useful video Thanks
😊
Thank you!!
please do never stop making videos. they are awesome
What is the advantage of Python over other languages?
Thanks Tiff, but why don't you run the audio file to check it?
All much easier with Open Interpreter these days!
Yea, I automate everything or create boilerplate code that can be reused over & over.
Amazing video!
I love you Tiffany. This is really cool 😍 😍 🔥
This is so usefull vidéo
so happy to hear!
@@TiffInTech you deserve the best
Hello , the thing I like in ur programming way is that u are not programming like super heroes , but u programme like ordinary people and u do magical things 🌹
great fun project. let us make a code for FB posting automation in python
OMG. Wanted so much to watch this but I can't concentrate! You are so beautiful. lol Also wanted to ask why are you not a model but just watched your 1st video :)
print("You are" + "pretty" + "and smart") .. sorry I couldn't help myself. Thanks for the video
Python World Peace App? Kidding aside, I did ask Chat GPT about things like that. Maybe a million advanced Quantum computers might help it along a bit.