Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Recording Sound File

by the_0ne (Pilgrim)
on May 18, 2005 at 15:34 UTC ( #458250=perlquestion: print w/ replies, xml ) Need Help??
the_0ne has asked for the wisdom of the Perl Monks concerning the following question:

Greetings fellow monks. I ask for your wisdom again. I am in need of some way that will allow me to record a sound file using a normal computer microphone. I know there are many modules out there that can do the easiest part, recording, however, my main problem is I need to be able to then modify the sound file. For instance, the user needs the ability to go back 10 - 15 seconds and either insert a part they missed or even overwrite some of the sound file they just recorded.

The other pre-requisite is that this needs to not only work in the linux world, it needs to work on the latest version of Mac OSX (which I think is Tiger verion 10) and also windows 2000/XP. So, I guess I could have just said cross-platform.

This is for a dictation system I am writing for our attorneys. The old system is in Visual Basic (cringes) and uses a WAV control. I wrote it over 5 years ago and it's worked great since then, however we are switching everybody in the company over to linux machines and/or mac mini's and the dictation system needs to be replaced.

Thanks in advance for any wisdom you can shed upon my query.

Comment on Recording Sound File
Re: Recording Sound File
by Anonymous Monk on May 18, 2005 at 15:44 UTC
    Have you been to CPAN?
      Actually I have...

      I know there are many modules out there that can do the easiest part, recording, however, my main problem is I need to be able to then modify the sound file.

      I guess I should have been more clear, "out there" meant I looked through cpan, searched for "audio" and "sound". My main problem is all of them did not seem to answer the question of modifying the recording while still recording.
Re: Recording Sound File
by Roy Johnson (Monsignor) on May 18, 2005 at 15:45 UTC
    You might start by looking at audio modules in CPAN. Audio::DSP looks particularly promising.

    Caution: Contents may have been coded under pressure.
      Yep, searched audio modules in cpan, but couldn't answer my above question, whether I could modify the recording while still recording.

      The Audio::DSP modules seems only to work with OSS, which they have this quote in the cpan article...

      OSS is available for many popular Unices

      This needs to work in linux, windows 2000/xp and possibly mac osx 10.

      Thanks.
        Since you have such extreme cross-platform requirements for something that is very system-specific, your best bet is probably Java's Sound API.

        Caution: Contents may have been coded under pressure.
Re: Recording Sound File
by ww (Bishop) on May 18, 2005 at 16:49 UTC
    'fraid I'm impelled to offer some un-perl-ish solutions, after viewing your issues with most of the replies below

    I'm infering/guessing that you want to have the system more or less resemble the operations of old-tyme cassete dictation (eg, to replace something: Stop (NOT pause), rewind, find start of erroneous section, cue to just before, re-start recording....). Might you consider writing a perl wrapper for controls around two different audio packages (one for *n*x, including tiger10) and one for 'doze?

    • Con: two audio packages (both, however, mp3 or similar and selection transparent to user); cost if you use OSS proprietary for the audio
    • Pro: Coding minimized (though some would consider that a con).

    Aare you doing this mostly for the challenge/bragging rights? (I'm not implying 'fault' if so; but ignore the rest of this.)
    Why not go with direct speech to text? Someone -- usually clerical -- is going to have to proofread/re-listen to the saved audio to get it anywhere near the dictator's intent.

    Or, let the dictator resume/continue use of dictaphone, cassette, or electro-mechanical device (if s/he can't cope with complexities of "re-winding" digital audio or a text file) and feed output to a speech-to-text package required ONLY on a single OS, shared by clerical folks.

    Sometimes, it's a good idea to just find a way to make something work, when the help offered doesn't fit.

      'fraid I'm impelled to offer some un-perl-ish solutions, after viewing your issues with most of the replies below

      No problem, any help is appreciated. I was just hoping to stay away from Java, knowing very little about it in the first place.

      Might you consider writing a perl wrapper for controls around two different audio packages (one for *n*x, including tiger10) and one for 'doze?

      Just might have to do that. Mostly why I posted here was to see if anybody had done what I'm am trying to accomplish, to save me the time of having to write 2 different scripts/programs. But, as I am finding so far, it looks like this might be the way to go. The 2 python packages I posted above, one is very old, not much activity. The other I posted a question to their list yesterday and still haven't gotten a response. If I would have problems with the package, not sure I'd receive any kind of help in a timely fashion. I must admit also, I have a bias for Perl, not too fond of Python, but have used it before. :(

      Why not go with direct speech to text? Someone -- usually clerical -- is going to have to proofread/re-listen to the saved audio to get it anywhere near the dictator's intent.

      You are exactly write. I wrote the system using VB consisting of 3 parts. A recorder, which works through activex controls. A daemon that processes the recording once the actual recording is converted to an asf and transferred to a network drive. And then the transcriptionist, which streams the processed asf file to the transcriber, which is the person that would be doing the proofreading/listening. We have talked over the speech-to-text pathway before, however, this would still require my pre-requisites of the original recording functionality.

      Thanks for your post.
        Not sure I agree that "the speech-to-text pathway ... would still require my pre-requisites of the original recording functionality."

        If the individual doing the dictation is sufficiently tech savvy to use an ability (as part of the proposed wrapper) to read the TEXT of what's been dictated to any given (stopping) point, that individual can then ANNOTATE the beginning of the substituted section with a "start skip here" marker (the selection of which is left as an exercise for the OP).

        Or, see also what I hoped was a clear example of the elements of using "old-tyme" procedure. Is there some reason you cannot , in effect, "rewind" the audio, and start overwriting? Use the wrapper to truncate a copy of the audio file at some user-selected point, and send the orig to /dev/nul only when the user starts again from that point, at which time, you can mv the copy to the original filename.

Re: Recording Sound File
by Joost (Canon) on May 18, 2005 at 18:11 UTC
      I actually did just use Audio::Wav in a script (just last week) where I needed to pull the length of a wav in minutes and seconds. I did see the Audio::Wav::Write and I don't see how you pull information from the microphone. I see that they are writing to a WAV file, however, I am confused on what they are writing from? How would I go about opening up the sound device and writing from it to use this module?
Re: Recording Sound File
by zentara (Archbishop) on May 18, 2005 at 18:31 UTC
    Just some ideas:

    Have you tried running your old VB app with WINE? Audio support in wine is getting pretty good. I can run CoolEdit under it.

    There are also a few things I would mention, like SDL::Mixer and Mhwaveedit.


    I'm not really a human, but I play one on earth. flash japh
      Thanks for the idea, the boss wants it rewritten to a brand-spankin new system. The VB system is very old, even though it works fine, there's lots more we'd like to do with the system and just couldn't do with VB. The other thing would be that we are moving away from Microsoft and trying to go either linux workstations or mac mini's. Most everything we do is now moved over to linux, this is one of our last apps and it's probably going to be the hardest to move over.
Re: Recording Sound File
by SciDude (Friar) on May 20, 2005 at 20:37 UTC

    Any sufficiently simple technology (like recording sound) is bound to be made more complex through the application of programming complexity.

    I suggest that you keep the simple things, simple.

    The tool you need is already written and available for Linux/Unix, Windows, and Mac OS 9 or OS X. See Audacity.

    As a special bonus, the source code is available under GNU|GPL.

    I realize this is not a perlish solution, but the requirements you mention (1. recording 2. modification via rewinding and 3. Overwriting recent recorded information and 4. cross platform issues) are all covered.

    As a special bonus, you can change the speed of a recording with Audacity. This greatly assists the transcriptionst.

    Your project may also benefit from text to speech technology but perhaps only after you get the recording requirements nailed down first.

    No suggestion will be useful unless the software actually works. I have found Audacity extremely stable on Linux where editing single sound files the size of seven standard CDs is a simple task.


    SciDude
    The first dog barks... all other dogs bark at the first dog.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://458250]
Approved by ZlR
Front-paged by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2014-07-25 12:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (170 votes), past polls