Sep-22-2023, 10:15 AM
Hi there !
this is an exercise to just save an audio file from a pdf. I want this file to be moved to a specific folder.
this is an exercise to just save an audio file from a pdf. I want this file to be moved to a specific folder.
import pyttsx3, PyPDF2, os,os.path, glob
from PyPDF2 import PdfReader
from typing import List
speaker = pyttsx3.init()
#i deleted part of the path in the example for privacy matter
program_path = "C:\\ . . \\Python learning center\\automating_1"
save_path = "C:\\ . . \\Python learning center\\automating_1\\Audio"
for files in glob.glob("*.pdf"):
print(files)
#here we enter the name of the pdf file that we want to be used for audio file
bookname = input("choose a file. . ")
reader = PdfReader(bookname, "rb")
number_of_pages = len(reader.pages)
page = reader.pages[0]
text = page.extract_text()
clean_text = text.strip().replace('\n', '')
print(clean_text)
audio_name = input("name the audio file: ")
audio_file = speaker.save_to_file(clean_text, audio_name + '.mp3')
move_file = os.path.join(program_path, save_path, audio_file)
speaker.runAndWait()
speaker.stop()so the paths AND the audio file name are str type. but here's what i get : Error:join() argument must be str, bytes, or os.PathLike object, not 'NoneType'where is my mistake ?
