I am building a web page where i need to do something when a particular sound is caught by the microphone. I searched a lot and found this link :
Write a Program Which Recognizes a Sound and Performs Action
I am stuck at two things:
how to use java based sound recognizers though a webpage or
javascript
how to match two sounds (one from the mic. and other from saved file) using any recognizer
For sound recognizer, I am using Sphinx-4 .
To use java sound recognizers, you will need to: either submit/stream the content recorded in the browser, or use a local processing (applet/javafx).
An applet/javafx might not be a bad idea at all; since recording might yield a large data blob, you can do the processing in the local machine. My bet is that the applet will need to be signed to access the mic. You could also stream the audio data to the server, websockets might be a cool shot.
For Javascript, i think you need to use HTML5 for microphone recording or Flash.
For audio comparison, i think you want audio fingerprinting. That is a summary of the audio file. You need to search your own database for the "best match" from what you got among what you have.
I'm not sure Sphinx is the man here. Both Musicg and MusicUri have audio fingerprinting.
Related
I have two files - audio(mp3 or wav) and video(mp4 or avi) with the same duration. I want to merge them and send to the front.
Which java library will help me to implement that?
If you mean you want to merge the audio and the video on the server side, so that the merged video can then be streamed to the client, then using ffmpeg via a wrapper may be the easiest approach.
The ffmpeg command line is well used and it is quite easy to ask and receive answers to any particular syntax. Using a Java wrapper approach allows you leverage this syntax and give you the flexablity to use other ffmpeg functionality in the future if you need it.
A popular up to date Java Wrapper is available here:
https://github.com/bramp/ffmpeg-cli-wrapper
If you actually want to stream the audio and the video to the browser separately and do the merging there, then, if you are not worried about an exact match (e.g. needing to synch audio to speech to keep it in lip synch), you can actually just start the audio player and video player simultaneously and the browser will play both together. This worked on all major browsers I tested it on for a project several years ago and I am not aware of anything changing to stop this working.
Imagine you watch sports live in your browser. It means you receiving a video stream, right? I need to record this stream and save to disk. The problem is that I don't have a clue from where to start. I'm not new to programming, but have a little experience in live video streaming.
I see this problem divided into this parts:
1) Parse html page and find live source URL. (? sounds silly, I'm not sure it is easy to find URL)
2) When I have URL everything else becomes easy. I would use Java for example, to receive and record stream.
So the main problem is to find live source URL. Does anybody know how to do that?
a) From HTML5 video player
b) From flash player
I had similar concerns before the best think I can suggest would be ;
For the first option :
open browser developer tools or wireshark and monitor the network while watching the video this is the most efficient way of locating the video source than you can just download the stream from the link
The second option :
there are some java libraries(jentpcap,jpcap ) for capturing ip packets after capturing the network adapter a while, you can filter them by type such a mpeg and get destination url note:some servers are sending these video samples as fragments you might need to merge them after downloading.
one more suggestion is gstreamer , as far as I know it has java wrappers and it is very useful for recording live videos to a file.
If the sport you are watching has any sort of value then it will most likely be protected by DRM and you will not be able to do what you are suggesting on your PC/laptop.
You can still capture the file but as it is encrypted you won't be able to play it back.
If it is not protected by DRM then finding the URL from the source can work - it depends on the video file type and whether the server is using any sort of authentication before mapping the URL sent from the browser to the URL of the actual video.
You also likely need to understand the type of URL - not all videos play in all devices, and some video URL's actually point to a manifest or 'index' file which then contains the actual URL's for the individual video and audio streams.
I'm looking to create webpage for record streaming audio from source (like online radio).
At first I thought of doing something like recording from speakers, but solutions like flash, java and javascript refer to recording from microphone and not directly from speakers.
Other alternative is to try capturing the streaming and save to local file, but I couldn't find any way of doing so from a webpage.
Solutions like this refer to iPad platfrom, and not suitable for standard webpage.
Any help will be much appreciated, as any development environment (python, ruby, php..).
The sound coming through the system is generally (1) available through one of the TargetDataLines of the Java Sound (sampled) API. Hook into that TargetDataLine & write the bytes directly to disk.
(Assuming you have the right to do so, of course.)
See the Capturing Audio lesson in the Java Tutorial for details. See my answer to JavaSound mixer with both Port(s) and DataLine(s)? for source to easily explore the available data lines. It is probably the "Primary Sound Capture Driver" that you need for this.
Java code must be trusted (or running with no security manager) to eavesdrop on the sound lines.
On some systems Java Sound does not seem to be able to detect all the lines. For those systems, there is little short of a hardware based audio loop-back (e.g. a cable connecting the speaker output back to the microphone) that will fix the problem.
Hey all, i'm new to web development so i'm really dumb when it comes to tools for working on it. I have .amr files recorded from my BB application that are sent and saved on a server. I want to be able to play these files via a webplayer on a website, I have a couple of questions regarding this:
1) Would it be sound to convert these files to something like mp3 o wav instead of trying to play using the amr format? The sound files are received by a java web service and saved as files on my hard drive with the URL saved on a MySQL database. So if a conversion method is suggested I would prefer it be in Java.
2) What player can I use and how, to play these files? Be it the amr files or converted files
3) How can I create a link that will point to said audio file so people can go to it and hear it? I know this differs a little from my original question line but I have to able to do it as well.
thanks in advance
1) MP3 or wav would be a good idea. You could use something like LAMEonJ (http://openinnowhere.sourceforge.net/lameonj/) for wav -> mp3. And with luck there's something similar for AMR.
2) Is the <audio> tag in HTML5 likely to be an option? The users could then play the file directly in the browser, and you could just render HTML on the website, rather than providing it through a webservice.
I think you are suggesting an applet on a web page, that connects to the server via a webservice, which would certainly be possible but a lot more work.
Otherwise, if you're just serving a music file, you're not going to be able to control what player is used on the client side, once they have your file they can do with it whatever they like.
The only down side of HTML5 is that they'll need a relatively recent browser.
3) If you're using <audio> then this is already taken care of.
If you google for the <audio> tag I think you'll find a lot of information,as well as strategies for providing alternative players to older browsers.
My client needs to let a user record a message from the browser, then export the message as an audio file (e.g., WAV).
How is this best accomplished? Flash, Java, HTML5? By best, I mean something that is straightforward to implement and also broadly supported.
What are people's experiences using HTML5?
Thanks!
Flash is one option but you need a media streaming server (Adobe Media Server, Wowza, Red5). There is no way to capture and store audio on Flash locally to a file.
If you are willing to go with Java applets there are multiple solutions. All of them require access to local filesystem and will ask users for additional permissions. For example try http://www.javasonics.com/ or Google "applet record audio".
Update: since Flash 10.0 there is option to use Microphone with SampleDataEvent.SAMPLE_DATA. This gives access to raw audio data from microphone. See this project for implementation: http://code.google.com/p/micrecorder/
Well I suspect that such a feature of HTML5 would be pretty non-standard, and the browser support would differ a lot (with many browsers not including any).
Java is not as popular as flash and there are many people who don't have JRE's at all.
So all in all I would go for the Flash solution in this case. And maybe with an HTML5 fallback for some limited cases, shall resources allow.
Assuming you mean "export" to a server, here is an open-source Flash solution that does NOT require a flash media server:
https://code.google.com/p/wami-recorder/
The recording is transferred via HTTP post to a server-side technology of your choosing. In the simplest case, you can capture and save audio with 4 lines of PHP code:
<?
$content = file_get_contents('php://input');
$fh = fopen('output.wav', 'w') or die("can't open file");
fwrite($fh, $content);
fclose($fh);
?>
As for HTML5 support, keep an eye on getUserMedia()