How to convert audio stream to .wav file and save - java

I am having some trouble figuring out how to convert audio data stream captured as 128 byte by a device to a .wav file and then how to save that .wav file. I am using eclipse with JRE8 to create a java project. Please let me know if any additional information would be helpful.
Here is the code I have thus far:
public void StartStreaming(){
{if(device !=null)}
{device.startAudioInput();}}
public void ConvertToWav()
{
//NEED HELP HERE
}
public void SaveWav()
{
//NEED HELP HERE TOO
}}
I have reviewed the tutorial on capturing sound but I cannot figure out how to convert the data to a .wav file and then save it.
I am not a coder by training so I would greatly appreciate if you could explain things as if you were talking to a beginner/non-coder/idiot. Thanks in advance for your help!

Here's a strategy you could take:
Find a command line tool which can do the conversion for you. The tool doesn't have to be written in java, but it can be executed from the command line (dos shell, bash shell, etc). Try it from the command line first and make sure it works as you expect. You'll have to research a little and find a tool which works for your purposes. If this is going to run in production on a different operating system than your development computer, make sure the tool works in all OS. Here's just one example. I am not advocating it as I've never used it. http://www.coolutils.com/CommandLine/TotalAudioConverter
You can invoke native commands from java, ie, the tool you just found in #1. Warning, this is not beginner java programming. However, it will accomplish your task. Here's an example:http://www.mkyong.com/java/how-to-execute-shell-command-from-java/

Related

Java Audio file read and Creating Echo effect

I have just started learning Java and I have to deliver a assignment in Which I have to read an Audio (.wav) File and Create echo effect of the audio file and save it without using any external library. Kindly guide me from where exactly to start. Although I have a basic knowledge about C++ upto functions and a little about Classes & Objects. Looking forward for the right direction as I am short of time!
Thanks.
You can find a working example here : http://www.java2s.com/Code/Java/Development-Class/Anexampleofplayingasoundwithanechofilter.htm

Copying all the DATA from SD card/USB pendrive

I've been learning Java for a month now. I've already managed to code some very simple stuff like prime number generator and a simple calculator. Now i'd love to try working on something more complex.
Here's my idea - I'd love to make a program that can copy pictures from SD card or USB with a single click (something that my parents can use very easily to copy all their photos to a folder without my help)
I was brainstorming quite a bit about it and before i start i want to ask following questions:
1. Are there any inbuilt Java methods that can help me with the following task?
2. What are the other (non-beginner) Java features that i'd need to read about?
I want to start it from the scratch, make it simple at first and progressively add more features to practice and learn some more.
Any pointers or tips much appreciated.
I'd suggest doing this as a script. The script can invoke java if you'd like to improve your java skills. However, scripting languages can also copy/move files very easily. If you choose java, read about file I/O, reading files, writing files, etc.
Here's a link for windows. Not sure what your operating system is, but you could create an executable script on mac, linux, etc.
http://www.wikihow.com/Write-a-Batch-File

How to get Acoustid (Chromaprint) from Java to identify mp3/m4a/etc

Has anyone managed to use acoustid (http://acoustid.org/chromaprint) in an Java application? Accessing the chromaprint clib should be easy but I can't just pass in the audio file. I requires the raw uncompressed audio data.
I've tried using xuggler to get the uncompressed audio but didn't get anywhere. Basically I have no idea how to get the raw audio from encoded files like mp3/m4a/etc
Has anybody managed to make this work? Anyone mind sharing their code?
I suggest you use the fpcalc command line tool (included in Chromaprint, binaries for Windows/Mac/Linux are included on the website), run it in a subprocess from your Java application. You get output like this, which should be easy to parse:
FILE=/path/to/file.mp3
DURATION=398
FINGERPRINT=AQADtEqkRIkkrQ...
That's how most programs integrate AcoustID and I believe it's the easiest way.

Android app that called external .exe

I am about to make an app on android but I have 0 experience about it.
This project is important and kind of a big challenge to me.
With that being said, I will try my best to explain about it so you guyz can give me an accurate approach
So assuming I have a program written in C,C++. Either an .exe or bunch of library.
What this executable do is to process the data and generate a file with bunch of binary and weird output. This process is called pre-processing.
Then result file will then be fed into Matlab or python and the graphical result will be generated. This is called post-processing and also the final goal.
Right now I can't afford to get matlab installed so my boss only asked me to go up to the pre-processing part.
The project will be displaying the pre-processing on the screen of a android device even if it might be unreadable.
I have done some research and found several ways to accomplish this:
1/ write a simple app using java and use JNI to call the main function of the .exe
2/ write a simple app using c++ and get the result straight from the .exe
That's all i can come up with, can any expert give me some suggestions please.
I am looking for a solution that would get me pass the pre-processing phase but also be efficient and easy if I get a chance to work on post-processing phase later.
Thank you very much

Java phonetics or language pronounciation

I am currently making a project for school, where I am going to make a program which teaches children how to read. My basic idea for the program was produce the sentence and then get Windows Anna to say it. My question to you is, how can I access Winodws Anna through Java? and is there a better way of doing this?
Thanks
If having the program access internet is acceptable, then you could use iSpeech.
You can use their API, but the problem with that is that it is limited to 200 uses/day.
iSpeech has decently sounding voices, generally more polished than other TTS engines I've tired like espeak or FreeTTS, because it actually pronounces the words more fluently. Sure, it might pronounce 'Wind', relating with air, as 'Wind', relating to twisting, but other than that, it speaks quite well.
Also, while I haven't had any prior experience with this, I found an article that shows you how to access the MS Speech with command line (which can obviously be commanded through Java[if you do not know how, here is a good article]). It is located here. In command line, all you do is type in 'SayDynamic.exe* the text you want to speak".
*Or SayStatic, the other download available on the page.
This method seems to be better in terms of speed and not relying on internet access, but it definitely does NOT pronounce things as well as iSpeech. I guess the ideal thing for your program to have would be to use iSpeech when online, and use the Say*.exe when offline.
The site also provides the source code of the program. As you might notice, it is NOT Microsoft Anna's voice, but you can specify that in the source and recompile it.
Hope I helped!
You can use command line utiity NirCmd that uses text-to-speech API installed on Windows.
So, supply this utility together with your java application and run it with appropriate command line.
You can try FreeTTS : a speech synthesizer written in java.
You can try to call the Microsoft Speech API (SAPI) but I don't know how to do it in java.
Can you tell us how you invoke NirCmd ?
Altenatively to NirCmd, you can build your own tool in C# that will read the text. The text could be within a txt and your tool invoked with the path to that txt as argument. You can easily adapt a demo project like this one : http://www.codeproject.com/Articles/19334/Text-to-Speech-using-Windows-SAPI
There is the Speech platform of Windows
http://www.microsoft.com/en-us/download/details.aspx?id=27226
The Speech runtime
http://www.microsoft.com/en-us/download/details.aspx?id=27225
You can use JNA (not JNI) to interact with dll from java
https://github.com/twall/jna

Categories

Resources