Skip to main content

Convert PDF into Audio Book in any language using python

 Convert PDF into Audio Book in any language using Python

We have to convert the pdf into the audio book

Properties-

We translate the text of pdf in required language


Step 1-

Import library-


from gtts import gTTS

import PyPDF2

from googletrans import Translator

from tkinter.filedialog import *

Step 2-

Read the text of pdf using PyPDF2 

Using for loop add all the text in one text file 


Step 3-

Translate the text to the given language

Eg.English to French

 English to hindi

But for this project we translate into hindi



Step 4-

Using gTTS convert the text into mp3 file

Complete code-

from gtts import gTTS
import PyPDF2
from googletrans import Translator
from tkinter.filedialog import *
 
book=askopenfilename()
pd=PyPDF2.PdfFileReader(book)
total=''
pages=pd.numPages
for num in range(0,pages):
page=pd.getPage(num)
txt=page.extractText()
total+=txt
trans=Translator()
t=trans.translate(total,dest='hi')
obj=gTTS(text=t.text,,lang='hi')
obj.save("mi.mp3")


Thanks for watching

Please subscribe 


For Complete –Project visit

https://cp-algorithms.blogspot.com/2020/09/convert-pdf-into-audio-book-in-any.html



Comments

Popular posts from this blog

Write a code simulating ARP /RARP protocols

   Write a code simulating ARP /RARP protocols . Aim:        To write a java program for simulating ARP/RARP protocols ALGORITHM: server 1. Create a server socket and bind it to port. 2. Listen for new connection and when a connection arrives, accept it. 3. Send server ‟ s date and time to the client. 4. Read client ‟ s IP address sent by the client. 5. Display the client details. 6. Repeat steps 2-5 until the server is terminated. 7. Close all streams. 8. Close the server socket. 9. Stop. Client 1. Create a client socket and connect it to the server ‟ s port number. 2. Retrieve its own IP address using built-in function. 3. Send its address to the server. 4. Display the date & time sent by the server. 5. Close the input and output streams. 6. Close the client socket. 7. Stop. Program Program for Address Resolutuion Protocol (ARP) using TCP Client: import java.io.*; import java.net.*; impor...

Importants Links of Leetcode

  Here are all the important discussion posts which contain brief descriptions about a topic with its problem list. Recursion:- A.   https://leetcode.com/tag/recursion/discuss/1733447/Become-Master-In-Recursion Binary Tree and Binary Search Tree:- A.   https://leetcode.com/tag/binary-tree/discuss/1212004/Binary-Trees-study-guide B.   https://leetcode.com/tag/binary-tree/discuss/1820334/Become-Master-in-Tree C.   https://leetcode.com/tag/binary-tree/discuss/1094690/Views-and-Traversal-of-binary-tree-or-Important-topics-or-Must-Read-%3A- ) Dynamic Programming:- A.   https://leetcode.com/discuss/study-guide/458695/Dynamic-Programming-Patterns B.   https://leetcode.com/tag/dynamic-programming/discuss/1437879/Dynamic-Programming-Patterns C.   https://leetcode.com/tag/dynamic-programming/discuss/662866/DP-for-Beginners-Problems-or-Patterns-or-Sample-Solutions D.   https://leetcode.com/tag/dynamic-programming/discuss/1050391/Must-do-Dynamic-programm...

Write a JSP which insert the details of the 3 or 4 users who register with the web site by using registration form. Authenticate the user when he submits the login form using the user name and password from the database

Write a JSP which does the following job   Insert the details of the 3 or 4 users who register with the web site (week9) by using registration form. Authenticate the user when he submits the login form using the user name and password from      the database (similar to week8 instead of cookies). Description JSP scripting elements let you insert Java code into the servlet that will be generated from the current JSP page. There are three forms: Expressions of the form  <%= expression %>  that are evaluated and inserted into the output, Scriptlets of the form  <% code %>  that are inserted into the servlet's  service  method, and Declarations of the form  <%! code %>  that are inserted into the body of the servlet class, outside of any existing methods. Each of these is described in more detail below. JSP Expressions A JSP  expression  is used to insert Java values directly...