Find Jobs
Hire Freelancers

Fix ebook PDF/TXT Parsing code

$30-250 USD

Completed
Posted 9 months ago

$30-250 USD

Paid on delivery
i have an ebook site, where the ebook will be converted to audio, im running into error during the parsing of the ebook into json so it can be made into ssml, so that text to speech can read it, below is the code that needs to be fixed. code works somewhat, it just isnt getting past 3rd and 4th chapters. 1. i need it to be able to be able to replace the words "Project Gutenberg" with "[login to view URL]" 2. it needs to be able to distinguish chapters, 1. Title, Author, Forward, Preface, Acknowledgments, Introduction, Prologue, Sub-chapters, Sections, Epilogue, Conclusion, Summary, Appendix, Appendices, Endnotes, Footnotes, Glossary) correctly, with correct breaks 3. needs to be able tp parse entire book 4. open to suggestions from anyone that has worked on ebooks and audio books before 5. also i am using Mimic 3, text to speech engine on my godaddy dedicated server, just in case one needs to know <?php require '/vendor/[login to view URL]'; use Smalot\PdfParser\Parser; // Add hooks to check and parse downloadable files when a product is accessed add_action('template_redirect', 'check_and_parse_downloadable_file'); add_action('admin_init', 'check_and_parse_downloadable_file'); function check_and_parse_downloadable_file() { global $post; // Exit if it's not a product or book_json meta is already set if (!$post || get_post_type($post) !== 'product' || get_post_meta($post->ID, 'book_json', true)) { return; } $product = wc_get_product($post->ID); if ($product && $product->is_virtual() && $product->is_downloadable()) { $downloads = $product->get_downloads(); foreach ($downloads as $download) { $file_path = ABSPATH . ltrim($download->get_file(), '/'); $parsed_content = ''; if (pathinfo($file_path, PATHINFO_EXTENSION) === 'txt') { $file_content = file_get_contents($file_path); $parsed_content = parse_txt_content($file_content); } elseif (pathinfo($file_path, PATHINFO_EXTENSION) === 'pdf') { $file_content = parse_pdf_content($file_path); $parsed_content = parse_txt_content($file_content); } if ($parsed_content) { $upload_dir = wp_upload_dir(); $json_dir = $upload_dir['basedir'] . '/json/'; if (!file_exists($json_dir)) { mkdir($json_dir, 0755, true); } $json_file_path = $json_dir . sanitize_title($post->post_title) . '.json'; file_put_contents($json_file_path, $parsed_content); update_post_meta($post->ID, 'book_json', $json_file_path); } } } } function parse_txt_content($content) { $elements = [ 'Title', 'Author', 'Forward', 'Preface', 'Acknowledgments', 'Introduction', 'Prologue', 'Chapter', 'Sub-chapters', 'Sections', 'Epilogue', 'Conclusion', 'Summary', 'Appendix', 'Appendices', 'Endnotes', 'Footnotes', 'Glossary' ]; $parsed_elements = []; foreach ($elements as $element) { // Adjusted regular expression pattern preg_match("/\b$element\b[:\s]*(.*?)(?=\b" . implode('\b|\b', $elements) . "\b|$)/si", $content, $matches); if (isset($matches[1]) && trim($matches[1])) { $parsed_elements[$element] = trim($matches[1]); } } $parsed_content_with_ssml = apply_ssml_tags(implode("\n", $parsed_elements)); return json_encode($parsed_content_with_ssml); } function apply_ssml_tags($content) { $content = preg_replace('/"(.*?)"/', '<speak><s>"$1"</s></speak>', $content); $content = preg_replace('/!/', '!<break time="1s" />', $content); $content = preg_replace('/,/', ',<break time="500ms" />', $content); $content = preg_replace('/[.!?]\s/', '$0<break time="1s" />', $content); // Add sound effects $sound_effects = [ 'door opens' => '<audio src="[login to view URL]" />', 'glass breaks' => '<audio src="[login to view URL]" />', 'car crash' => '<audio src="[login to view URL]" />' ]; foreach ($sound_effects as $phrase => $effect) { $content = str_replace($phrase, $effect, $content); } return $content; } function parse_pdf_content($file_path) { $parser = new Parser(); $pdf = $parser->parseFile($file_path); return $pdf->getText(); } // Adding a meta box to show the JSON in WP admin function book_json_meta_box() { add_meta_box('book_json_box', 'Book JSON', 'book_json_meta_box_callback', 'product', 'normal', 'default'); } add_action('add_meta_boxes', 'book_json_meta_box'); function book_json_meta_box_callback($post) { $json_file = get_post_meta($post->ID, 'book_json', true); if ($json_file && file_exists($json_file)) { $json_content = file_get_contents($json_file); echo '<textarea style="width:100%; height:300px;">' . esc_textarea($json_content) . '</textarea>'; } else { echo 'No JSON file has been created for this product.'; } }
Project ID: 37045024

About the project

24 proposals
Remote project
Active 9 mos ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hello. I read your requirement and checked the code i will do that. Please come on chat we will discuss more about this. I will waiting your reply.
$50 USD in 1 day
4.8 (14 reviews)
4.0
4.0
24 freelancers are bidding on average $123 USD for this job
User Avatar
Hello I have checked the job description I can help you to Fix ebook PDF/TXT Parsing code and I have some queries about your Project Let me know when you are available to discuss this further Thanks Azad
$140 USD in 7 days
4.8 (179 reviews)
7.4
7.4
User Avatar
Hello Kelvin G., I'm thrilled to offer my WordPress development skills for your project Fix ebook PDF/TXT Parsing code . With expertise in custom themes, plugins, and responsive design, I'll create a captivating and functional website for Fix ebook PDF/TXT Parsing code . With 10+ years of experience, I'm committed to delivering a seamless online presence. Let's build a stunning WordPress site together. Best regards, Farhan Atif
$250 USD in 2 days
4.9 (163 reviews)
6.8
6.8
User Avatar
Hey Kelvin, please send me the audio file which is not working for you? Or send me your server logins so I can try giving you much better feedback. Let me know, thanks.
$200 USD in 2 days
5.0 (3 reviews)
5.5
5.5
User Avatar
Hello Kelvin G., We went through your project description & I am very interesting in your job and it seems like our team is a great fit for this job. We are an expert team which have many years of experience on WordPress Regards Thank You
$140 USD in 7 days
5.0 (6 reviews)
4.9
4.9
User Avatar
Hello, I will help you with this Fix ebook PDF/TXT Parsing code .I have a team of professional developer. We have expertise in frontend designing,back end developement, theme and plugin development and customization, api integration and development. Please connect over chat to discuss in details. Looking forward to hearing from you soon. Thank you!
$100 USD in 1 day
4.9 (25 reviews)
5.1
5.1
User Avatar
i have already worked on similar projects many time . my 7 yr experience will help me to develop this . let chats and begin the development
$30 USD in 1 day
4.8 (12 reviews)
4.5
4.5
User Avatar
Hey, I am interested in your project, " Fix ebook PDF/TXT Parsing code ". I’m an experienced developer in Wordpress. I have extensive experiences in PDF, PHP, WordPress and JSON. I’m ready to discuss your project and start immediately. I can work on your project full time also. Looking forward to hearing you back and discussing all details. Feel free to contact us to discuss your project
$250 USD in 5 days
5.0 (3 reviews)
3.8
3.8
User Avatar
Hello I'm Carmela , an independent software engineer based in philipins, I specialized in PHP for 7 years. After going through your project description , I could potentailly increase your conversion rates by improving the user experience. I can fix your bug within 7 hours Since I am new to freelancing, I am happy to offer a discount, and I am confident that this collaboration would a be positive return of investment for you. If you are open to explore further, I am availalble to be online always. Thank you so much.
$50 USD in 1 day
5.0 (3 reviews)
3.5
3.5
User Avatar
Hello, Kelvin G. As a senior web developer with 7 years of experience, specializing in high quality SPA & Hybrid development. I have experience working as an individual developer and sometimes a team cooperator in many projects providing me with the skills of communicating with clients to satisfy their needs I have strong experience in PHP, PDF, JSON and WordPress If you gieve me a chance, I can deliver the best result you want I can start right now and work full-time on your project And I will show you my previous works Looking forward to working with you. Regards, Piril
$100 USD in 1 day
5.0 (1 review)
3.0
3.0
User Avatar
Hi there, DO NOT PAY ME UNTIL YOU GET COMPLETELY SATISFIED WITH MY WORK I will be glad to start on the project immediately. Will provide you 100% satisfaction. Ping me so that I can share you my previous work and lets create a masterpeice for you and if you will not like my work I will refund you the whole milestone Best Regards, Vijay
$80 USD in 2 days
5.0 (3 reviews)
2.5
2.5
User Avatar
Greetings! I've gone through the "Fix ebook PDF/TXT Parsing code " project and If you are looking for a high-quality and professional design, then I can provide you with a high-quality design that will help your company stand out from your competition and promote its products and services. Please find my relevant work on the link below. https://www.freelancer.com/u/arnicamaredia97 Please open up the chatbox to discuss this further. Best Regards, Arnica M.
$70 USD in 1 day
5.0 (4 reviews)
2.4
2.4
User Avatar
Hi, Kelvin G. I've studied your proposal deeply. It seems that you're looking for a programmer who have rich experiences on PHP, WordPress, JSON and PDF. I've worked with another client in this space, I think you might find it very interesting to have chat. Regards, Kate
$50 USD in 2 days
0.0 (0 reviews)
0.0
0.0
User Avatar
Hi Kelvin G. Good morning! I am excited to submit my proposal for the "Fix ebook PDF/TXT Parsing code " position. I have developed a strong set of skills that make me confident in my ability to deliver high-quality work to your project. My approach to any project is to first gain a deep understanding of the client's needs and requirements. I will work closely with you to ensure that I understand your project goals and objectives, and that I am able to deliver results that meet or exceed your expectations. In terms of technical skills, I have extensive experience in WordPress, JSON, PDF and PHP. '</textarea>' Please contact me to discuss more regarding this project. Thanks for giving opportunity. ❤️Solomiia❤️
$50 USD in 3 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
port orange, United States
5.0
85
Payment method verified
Member since Jun 5, 2015

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.