INNER CODE UNIT · Python
convert_to_epub
DrewThomasson/VoxNovel · 2GPU_Audio_generation.py:129
def convert_to_epub(input_path, output_path):
# Convert the ebook to EPUB format using Calibre's ebook-convert
try:
subprocess.run(['ebook-convert', input_path, output_path], check=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred while converting the eBook: {e}")
return False
return True
def save_chapters_as_text(epub_path):
# Create the directory if it doesn't exist
directory = "Working_files/temp_ebook"
#Clean up the text chapter folders by wiping it before creating chapters for selected ebook.
#Lazily done by just deleting the directly and everything in it.
if os.path.exists(directory):
shutil.rmtree(directory)
ensure_directory(directory)