Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 29

Thread: Need to convert PDF to Audio MP3

  1. #11
    Join Date
    Jan 2010
    Beans
    10

    Re: Need to convert PDF to Audio MP3

    nice that it works with english voice!

    how to use a different language i don't know. i need need the german voice, but it's not very urgent for me now. when i spend time on installing and using the german voice, i'll add the option to the script. but currently it seems that it's up to you to find out how to install and use a different language with festival.

    good luck!

  2. #12
    Join Date
    Dec 2008
    Beans
    5

    Re: Need to convert PDF to Audio MP3

    sorry, Idont want the german lang but the other american and british voices......

  3. #13
    Join Date
    Jan 2010
    Beans
    10

    Re: Need to convert PDF to Audio MP3

    and i must again say that it seems that it's up to you to get festival working with other voices.

    it would be nice if you can post your success here (in case you have some...)

    PS: once you have installed a different language (or set a different language as default) the pdf2mp3.py script still does the right job.

  4. #14
    Join Date
    Jan 2010
    Beans
    10

    Re: Need to convert PDF to Audio MP3

    for those who don't want to make an account here and want to have the script, here it is (please follow instructions on how to make it work - it's very simple and on new ubuntu linux computers very reliable):

    Code:
    #!/usr/bin/python
    # ###################################################
    # pdf2mp3.py - little script/program to convert a
    # pdf-file or ascii-file (.dat, .txt) into a mp3 audio file
    #
    # Copyright (C) 2010 Hannes Rennau
    # kontakt-hannes@hannijanni.de
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the
    # Free Software Foundation, Inc.,
    # 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    # ###################################################
    
    # LIST OF PACKAGES NEEDED:
    # you need to install the following packages:
    # sudo apt-get install python poppler-utils festival festvox-rablpc16k lame
    
    # HOW TO USE:
    # 1.create a file with the name pdf2mp3.py and copy the content of
    #   the whole text in there
    # 2.make the file an executable via:
    #   >>> chmod +x pdf2mp3.py
    # 3.copy file to /usr/bin to make usage of program possible from everywhere on your computer:
    #   >>> sudo cp pdf2mp3.py /usr/bin/
    # 4.after that just call script via: 
    #   >>> pdf2mp3.py yourfilename.pdf
    #   or:
    #   >>> pdf2mp3.py yourfilename.dat
    #   or:
    #   >>> pdf2mp3.py yourfilename.txt
    #
    #   and a file called yourfilename.mp3 is being created
    
    # ADDITONAL INFO:
    # in case you've lots of tables, equations or whatever else in your pdf,
    # it's a nice think if you delete all strange symbol character stuff in
    # in the yourfilename.txt-file and then run the script again but call it via:
    # pdf2mp3.py yourfilename.txt
    
    import os,sys
    import string
    
    # get filenname
    ifpdf=1
    filename_inp = sys.argv[1]
    
    if filename_inp[-4:]=='.dat' or filename_inp[-4:]=='.txt':
        ifpdf=0
    
    if filename_inp[-4:]=='.pdf' or filename_inp[-4:]=='.dat' or filename_inp[-4:]=='.txt':
        filename = filename_inp[:-4]
        if os.path.isfile(str(filename_inp)):
            if ifpdf:
                print 'converting pdf to ascii...'
                os.popen('pdftotext ' + str(filename) + '.pdf ' + str(filename) + '.txt')
            print 'start converting ascii to wav...'
            os.popen('cat ' + str(filename) + '.txt\
                   |sed \'s/[^a-zA-Z .,!?]//g\'|text2wave -o ' + str(filename) + '.wav')
            print 'converting to mp3...'
            os.popen('lame -f ' + str(filename) + '.wav ' + str(filename) + '.mp3')
            os.popen('rm -f ' + str(filename) + '.wav')
            print 'finished. don\'t forget to delete txt file if you don\'t need it'
        else:
            print '*** file does not exist ***'
    else:
        print '*** please give extension of your file (.dat, .txt or .pdf)'
        print '*** or your file called: ' + str(filename_inp) + '\n*** does not exist'
       
    
    # that's it. have fun!!! :)
    Last edited by rennau80; January 13th, 2010 at 04:09 PM.

  5. #15
    Join Date
    Feb 2010
    Beans
    1

    Smile Re: Need to convert PDF to Audio MP3

    Thanks the script was of great help !!

  6. #16
    Join Date
    Jan 2010
    Beans
    1
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Need to convert PDF to Audio MP3

    Thank you so much for putting this together! I spent a few hours online trying to find a solution and this was by far the best option. At first, I found the voice a little hard to understand with some of the words, but the more I listen to it, the easier it gets.

  7. #17
    Join Date
    Dec 2005
    Location
    Western Australia
    Beans
    11,479
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Need to convert PDF to Audio MP3

    Why don't you package it up? I'm going to put a simple packaging HOWTO onto my site shortly.
    I try to treat the cause, not the symptom. I avoid the terminal in instructions, unless it's easier or necessary. My instructions will work within the Ubuntu system, instead of breaking or subverting it. Those are the three guarantees to the helpee.

  8. #18
    Join Date
    Jan 2010
    Beans
    10

    Re: Need to convert PDF to Audio MP3

    very nice that it has helped you much! at the beginning i had the same problem because there is a lot of rubbish windows software around and lots of advertisement you get via google search for this topic.

    feel free to share!

    it should be very easy to adapt the code via commenting lines by the #-symbol such that it can also be named pdf2ascii or pdf2wav...
    Last edited by rennau80; May 20th, 2010 at 11:04 AM.

  9. #19
    Join Date
    Jan 2010
    Beans
    10

    Re: Need to convert PDF to Audio MP3

    Quote Originally Posted by aiiaalla View Post
    sorry, Idont want the german lang but the other american and british voices......
    now with multilingual conversion and new command line options. here are some examples:

    Code:
     ./pdf2mp3.py -v en -f input.pdf -o output.mp3  (pdf->mp3 engish voice)

    Code:
     ./pdf2mp3.py -v de -f input.pdf -o output.mp3  (pdf->mp3 german voice)
    or:

    Code:
     ./pdf2mp3.py -v it -f input.txt -o output.mp3  (txt->mp3 italian voice)

    Code:
     ./pdf2mp3.py -v fr -f input.dat -o output.wav  (dat->wav french voice)
    don't forget to make the file executable in the shell via command:
    Code:
    chmod +x pdf2mp3.py

    there are lots of other languages available now, here only a few:
    afrikaans (af), bosnian (bs), danish (da), spanish (es), french (fr), italian (it), norwegian (no), swedish (sv), turkish (tr), Mandarin (zh), ...


    please note that now these packages are necessary:
    Code:
    sudo apt-get install python poppler-utils festival festvox-rablpc16k lame espeak wavbreaker
    the code is attached with this post.
    Attached Files Attached Files
    Last edited by rennau80; July 20th, 2010 at 01:59 PM.

  10. #20
    Join Date
    Oct 2010
    Beans
    1

    Re: Need to convert PDF to Audio MP3

    Thanks for such a nice script.

    I have downloaded the OGI modules as it is mentioned in the discussion before.
    How can we change the voice or speed?? Please give the command.

    I am using your first script. I am interested in English voices.

Page 2 of 3 FirstFirst 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •