views:

994

answers:

4

Hi

Is it possible to record the end user by mic?

And what kid of actions can I do with the recording?

Can I get for example the volume of the sound (decibels) in real time?

Can I save the record on a file?

Thanks.

A: 

There is a setting on the client side to turn on access to the webcam and Mic, but there is no way that you are going to have control of that in your application itself. The user would have to opt to have this turned on. If you must do something like this, you are better to implement an Active X control of some form, which the user might unwittingly accept access to this function.

mondaysgeek
+2  A: 

Yes, Flash allows (with user permission) the ability to record from the microphone.

This is how countless sites like Stickam work to provide videoconferencing capability.

You cannot take actual (accurate) sound pressure readings in dB--that is an absolute measurement of sound pressure that would depend on a hundred factors you have no control of on the user's machine (mic type, location, positioning, trim, frequency response, A/D conversion, hardware compression, etc.). However, you can sample the relative amplitude of the incoming signal.

richardtallent
A: 

Yes, you can record audio, using the flash.media.Microphone class.

No, you can't save to a file from Flash, because Flash won't let you write to disk. Well, you could save to an LSO, but that's limited to 100 KB by default, and isn't a plain file anyway. You can probably do it with AIR. I see in the docs for the Microphone class that you can stream the audio back to a Flash Media Server (or compatible, as noted in comment below), but that's not exactly "saving to a file".

As for processing the audio, technically, yes you can do what you're proposing, but it may be impractical. ActionScript is an interpreted language, and doesn't have particularly strong numerical processing abilities. It would probably be 10-50x slower to do this in Flash than in native code. Accepting this speed hit would be like sending yourself back in time 10-15 years, and having to do this using the technology of the day. So, whatever you'd want to do, you'd have to ask yourself if they were doing it in real time in the mid to late 90's. If not, Flash will probably be too slow. Speaker-independent large-vocabulary speech recognition, for example, probably won't be practical.

ActionScript works best when you're only using it to script calls into the Flash Player, which is written in native code. Until Flash gets voice recognition (or whatever audio features you're looking to have), I'd give up on this project.

Warren Young
Several corrections: First, you can stream audio data to any of a variety of media servers, including free ones like red5. Second, Flash is by no means too slow to do anything the question mentioned. There's no reason for the OP to "give up on this project" if he simply wants to do the things listed in his question.
fenomas
I've fixed the FMS commentary above. As for the questions of Flash being too slow, I don't want to ruffle any feathers, I'm just trying to point out that if you want to do something that takes a beefy computer and native code to do well today -- like my one concrete example above, voice recognition -- Flash is probably not the right answer until Flash gets that feature internally. That's it. Can I have my +1 back now? :)
Warren Young
Warren - you are ignorant of what is possible in Flash. http://theflashblog.com/?p=197 here is a list of audio spectrum analyzers that visualize a soundform by processing sound data. This is one example of what *is* possible using Flash.
James Fassett
These things were being done in real-time 10-15 years ago, so they fall under my qualifications above. To be clear: I'm not saying "you can't do audio processing in Flash". I'm saying that you can't expect to do the things with it that currently require the full capacity of a computer running native code. That's all.
Warren Young
Warren, it's probably true that AS3 is too slow for voice recognition, but nobody asked about that. You might more reasonably answer that Flash is fine for the things the OP asked about, but that he should beware of attempting any more advanced processing, but even that's misleading, since (as the other better answers explain), current APIs don't expose the data necessary for such processing yet anyway.
fenomas
+2  A: 

As far as I know, you can't access its waveform or volume... there is an activityLevel property with some kind of information on the activity levels, but you can't access the raw spectrum or anything similar. To record the audio file, you can send it to a server via FMS, and eventually you could proccess it there, but this would depend on the connection latency and such, so it would be quite hard to give accurate responses to the user... See this: http://theflashblog.com/?p=829

Cay