1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If you had a PIAF Forum account in the vBulletin days, log in with your old credentials. Otherwise, sign up again and we'll get you back in business as soon as we can.

Exploring Speech to Text

Discussion in 'Developers' Corner' started by wardmundy, Jan 12, 2012.

  1. lgaetz Pundit

    All hail lzaf.
  2. tm1000 Guru

    I've written a php version of this script if anyone's interested.
  3. wardmundy Nerd Uno

    Always interested. Where can we find it??
  4. tm1000 Guru

    I'm still cleaning it up. Basically it's just a 'script -i test.wav -o string'

    type of file. meaning, send it any audio file and flac will convert and send it to google and get the result back unjsoned...

    Also it kinda requires json wrapper on PHP less than 5.3(which I'd also include)

  5. tm1000 Guru

  6. KUMARULLAL Guru

    Fantastic job. lzap,
    Works perfectly. However, I am getting this error message

    "Use of uninitialized value in length at /var/lib/asterisk/agi-bin/googletts.agi line 117, <STDIN> line 19."

    Any ideas?
  7. lzaf Guru

    Its just a non fatal perl warning. From the top of my head I think its the part of the code that checks for interrupt digits or some other user specified options. Its not a real problem and it doesnt mean that there is some misbehavior.
    If you really want it to go away edit the script and comment out the line 'use warnings;'
    The warnings are enabled by default just to help users and developers since the code is still young and problems might appear.
  8. lzaf Guru

    Good job tm. I would advice you not to bother with sox. I have already removed all sox related code from my script. Sox was used in order to see if sound normalising (and some other tricks like low/highpass filtering etc) would improve detection rates. In all my tests this didn't happen. I think googles engine is already highly optimised for this kind of input (telephone recorded voice data) and trying to edit the voice data before sending it doesn't really help.
    And another note, in its current form your script accepts only raw sound data, I think it would be more practical if it could work with wav files.
  9. KUMARULLAL Guru

    Thanks for the work around lzaf. No more errors.
  10. lgaetz Pundit

    Has anyone tried out lzaf's googletts script that uses google's text to speech? I am curious to know if the quality of speech is any better than flite?
  11. lzaf Guru

    There is a cli application (under the folder cli ;) ) that you can use to get an idea of the produced speech quality without involving asterisk.
    Having worked a lot with speech synthesis and developed many asterisk tts modules that work with differed engines I have to admit that google's engine gives by far the best results. The sound is very natural and as close to a natural voice as possible, plus the fact that it supports a wide variety of languages. To my ears it even beats most of the expensive commercial engines available for telephony applications.
    Possible drawbacks are the facts that the terms of use are not yet clearly defined and that you have to contact a remote server to get the voice data.
    I would not suggest to be used in a production environment yet, at least until google defines the exact terms of use for that service, but for home/hobbyist/hackish :biggrin5: use i think its the best free available option.
  12. lgaetz Pundit

    I gave it a try on PIAF 1.7.5.6 purple but I am missing something. Googletts requirements:
    Code:
    ------------
    Requirements 
    ------------
    Perl         The Perl Programming Language
    perl-libwww  The World-Wide Web library for Perl
    sox          Sound eXchange, sound processing program
    mpg123       MPEG Audio Player and decoder
    format_sln   Raw slinear module for asterisk
    
    Can anyone tell me how to determine if the above are installed and how to install the missing ones? I shamefully admit my Linux skills are weak.
  13. KUMARULLAL Guru

    I was using older PBIAF. Some of the things I installed it manually.
    To install mpg123 you need to download the rpm package
    Code:
    w-g-e-t ftp://195.220.108.108/linux/dag/redhat/el5/en/i386/dag/RPMS/mpg123-1.9.1-1.el5.rf.i386.rpm
    

    Then install rpm by rpm -ivh mpg123*.rpm

    You also need to
    Code:
    yum install libesd.so.0
    
    sox must be installed, if not
    Code:
    yum install sox
    
    To install perl-libwww
    Code:
    yum install perl-libwww-perl
    
    You also need
    Code:
    yum install perl-XML-Simple
    
    You need to download googtts from lzaf's website
    Hope this helps
  14. lgaetz Pundit

    I have hijacked this thread, mods please feel free to split off all posts from #50 onward to another thread.

    KUMARULLAL's post gets all the dependencies working and copying googlets.agi to /var/lib/asterisk/agi-bin/ installs the script. I did a quick side by side comparison with flite and google tts is the bomb. Lots of languages to choose from too.

    Give it a try!
  15. wardmundy Nerd Uno

    Nooooooooo. I'm enjoying every minute. Can't wait to try it. This is what the Developer's Corner is for!

    FYI: All of the dependencies outlined above already are included in PIAF2 with the exception of perl-XML-Simple. It was added to new installs a few days ago.

    Here is the download syntax to get the current release of Googletts:

    Code:
    w-g-e-t --no-check-certificate https://github.com/downloads/zaf/asterisk-googletts/asterisk-googletts-0.5.tar.gz

    And here is an excerpt from the documentation showing dialplan usage:


  16. mvoip New Member

    This is my first post here. This forum and PIAF application itself is great. Thank you all for your time.
    I am trying to use lzaf's googletts for google tts for iRiss (instead of flite). Everything works fine until foo variable is passed to googletts AGI. For some reason, googletts AGI cannot process text in foo variable (/tmp/results.txt). I see that the value has been passed in asterisk log file and even see *.sln file in temp folder but it does not play back. Any suggestions?:banghead:

    Thank you guys for your great work.
  17. lzaf Guru

    The idea of passing a text file as input to an agi script has some shortcomings. Newlines, quotes and some special characters might confuse the agi script and the way it handles stdin to get its arguments. As a first step i would suggest you to strip newlines and quotes from your text (results.txt) before passing it to googletts.agi
  18. wardmundy Nerd Uno

    Code:
    exten => 444,1,Answer()
    exten => 444,n,Wait(1)
    exten => 444,n,agi(googletts.agi,"As Rick Perry would say, Ooops! Something went haywire. Please try your call again later.",en)
    exten => 444,n,hangup
    
    If this code doesn't work, then you're missing one or more of the dependencies. sox or mpg123 are likely culprits. HINT: There are no problems on default PIAF2 systems.
  19. mvoip New Member

    Thanks for your feedback. I have, however, tried putting plain sentence without any punctuation on result.txt file and then pass that file as variable, but still not getting anywhere. Here is the piece of code from extension_custom.conf file:

    ;code for wolfram alpha answerer
    ;added 2012-01-15
    ;begin
    exten => 4747,1,Answer()
    exten => 4747,2,Wait(1)
    exten => 4747,3,agi(googletts.agi,"How can Eye Riss help you? Press the pound key when you're finished.",en)
    exten => 4747,4(record),agi(speech-recog.agi,en-US)
    exten => 4747,5,Noop(= Script returned: ${status} , ${id} , ${confidence} , ${utterance} =)
    exten => 4747,6,agi(googletts.agi,"${utterance}",en)
    exten => 4747,7,Background(vm-star-cancel)
    exten => 4747,8,Background(continue-english-press)
    exten => 4747,9,Background(digits/1)
    exten => 4747,10,Read(PROCEED,beep,1)
    exten => 4747,11,GotoIf($["foo${PROCEED}" = "foo1"]?12:14)
    exten => 4747,12,Set(FILE(/tmp/query.txt)=${utterance})
    exten => 4747,13,Background(one-moment-please)
    exten => 4747,14,System(/var/lib/asterisk/agi-bin/iriss)
    exten => 4747,15,Set(foo=${FILE(/tmp/results.txt)})
    ;exten => 4747,16,flite("${foo}")
    exten => 4747,16,agi(googletts.agi,"${foo}",en)

    ;exten => 4747,17,flite("Have a nice day! Good bye.")
    exten => 4747,17,agi(googletts.agi,"Have a nice day! Good bye.",en)
    exten => 4747,18,hangup
    ;end

    The one with red colour does not work with gogletts. It works fine with flite (flite is commented for testing). All the rest work fine.

    Any help is appreciated. Thanks.
  20. mvoip New Member

    Thanks Ward. The text enclosed in quotes work fine. I was trying to pass it as a variable to read content of result.txt file.

Share This Page