I'm planning to work on a project where there will be a feature like voice capturing and sending it through a socket and playback it on the other side. Now I need to know whether there is any API in Java or C# regarding working with raw formats of voice data.
For C#, you can use NAudio library for sound capturing and playback. For JAVA, You can use javax.sound.sampled Package for audio capturing and playback. If you want to encode it, use 3rd party library like jspeex to encode and decode. Use inbuilt network libraries to send them.
UPDATE:
For C# try SharpDX. Which is a managed version of DirectX and do have all the features you required (Don't know whether it is suitable for your project).
Related
I am developing application that receives media content(.mp3/.mp4/.avi) in form of bytes.
However, as WPF doesn't support playing media from stream, So I started with WMP.dll.
I am creating class library that receives media in form of bytes and media format and play media accordingly.
Referring Creating the WMP Programmatically, however, I didn't find method to pass bytes stream.
So My question is how do I play media from bytes using wmp.dll?
Edit: I am using WMP.dll using COM located at C:\WINDOWS\system32\wmp.dll
I've been through this process a long time ago ...
Basically I would advise you NOT to go down the WMP route at all. It's heavy, cumbersome and not very nice to work with. I encountered lots of issues along the way basically. Least of all it being feature rich (which it isn't).
The best solution I found and the one I'm still using now is a library called BASS from Un4SeenDevelopments.
This library is tiny < 100k and basically it's awesome. Never had a problem with it and it has it's own .NET wrapper that is a free download from the site.
The support is amazing and the compatibility via a massive selection of plugins and additional libraries is staggering.
Highly recommended for what you want to do.
"BASS is an audio library for use in software on several platforms. Its purpose is to provide developers with powerful and efficient sample, stream (MP3, MP2, MP1, OGG, WAV, AIFF, custom generated, and more via OS codecs and add-ons), MOD music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and recording functions. All in a compact DLL that won't bloat your distribution."
I'm trying to capture Microphone sound using C#, and i have searched Google for this thing and all what i am getting is non .Net Libraries , i only get open source ones Like NAudio and other like DirectX and DirectX.DirectSound which are for managed languages like C# but that is not what I'm looking for. and i have tried them both and i used this open source project as a reference in NAudio
http://voicerecorder.codeplex.com/
and i manged to capture sound and then output it on a speaker or a headphone but i am still having problems when saving the Wav file
but i was wondering is there any .Net Built in libraries that can help me with my objective ?
Thanks for your help in advance :)
i was wondering is there any .Net Built in libraries that can help me
with my objective ?
Short answer: No, at least not at the present time.
The .NET framework does not provide any direct support for recording audio. This is the reason libraries like nAudio exist. You would neeed to use Com Interop and the Windows API to acheive this, and it would be no small task. Even the Coding4Fun article on recording sounds at Microsoft's Channel 19 website uses NAudio. Your best bet would be to follow their example.
I need to write a utility in c# that uses Google Speech Api to convert speech from an audio file into text. As far as I know, Google only accepts .flac format for this api. Unfortunately, I have .wav and .mp3 audio files. So I am trying to find out if there is a way for me to convert mp3 to flac in .NET. I looked at NAudio, but it doesn't seem to be working with flac files.
I ended up using Gregory S. Chudov's C# implementation of FLAKE encoder. You can find more information at
http://www.hydrogenaudio.org/forums/index.php?showtopic=74242
There is another project on BitBucket that uses CUETools FLAKE in its Google Speech Api wrapper. It is a good starting point for implementing speech to text using Google speech api. You can find it at
https://bitbucket.org/josephcooney/cloudspeech
I was able to convert wav to flac without much difficulty using the FLAKE encoder. Hope this helps you.
Take a look at http://naudio.codeplex.com/
NAudio is an open source .NET audio and MIDI library, containing dozens of useful audio related classes intended to speed development of audio related utilities in .NET. It has been in development since 2002 and has grown to include a wide variety of features. While some parts of the library are relatively new and incomplete, the more mature features have undergone extensive testing and can be quickly used to add audio capabilities to an existing .NET application. NAudio can be quickly added to your .NET application using NuGet.
Edit
Sadly FLAC is not supported there, as i see in the overview. Try it yourself.
I have a two-way audio chat written in C#. Means: There is a server application, that sends wave-encoded audio as a byte array over UDP. The client-application then decodes and plays the audio. So this works fine. For recording and encoding/ decoding, I use NAudio (library).
Now, the task is a different one, to display the stream on a website. I would prefer to use ASP.NET, so I can receive and decode the string with C# and NAudio. I display a cam image there as well, which works smoothly and without any problem.
Still I don't know how to do this.
Can the UDP-bytestream just be decoded and played? I don't think this is possible, or could javascript be used instead of C#? HTML5 audio tag could also be useful.
Would be very happy to receive answers.
Since you mention you're using ASP.Net, it sounds like you already have a Microsoft server stack. You might look into Windows Media Services and see how you might be able to encode your audio/video into a WM stream and then embed that on your ASP.Net page.
I've written a basic SL4 application to capture audio data from the microphone using CaptureSource. The trouble is, it's raw PCM output - which means huge and uncompressed.
Given that I need this application to run purely within a SL4 environment, how can I compress the PCM audio data into something that can be delivered to a remote server more easily?
Essentially I need a solution that I can also deploy/include in a Windows Phone Series 7 application as well as one that will work in the browser environment - so managed code solutions only, I think?
In conversation, people have suggested Speex and WMA for instance, but I haven't found any libraries or examples that work without requiring reference to DLL's that won't work in a SL4 project.
Just a small addition to Jason's post:
There is another port of Speex to .Net and Silverlight 4 called NSpeex.
Please see the WavFileHelper class in Silverlight 4 Rough Notes: Camera and Microphone Support on Mike Taulty's blog (a bit lower than the middle of the page, but the full article is worthwhile) in which he compresses the PCM file to WAV.
Here's another example of when writing to WAV you can change values such as Mono/Stereo, which will directly change the size of the WAV file: Audio recorder Silverlight 4 sample. And one more that gives more details about writing to WAV: Creating Sound using MediaStreamSource in Silverlight 3 Beta
Take a look at this. It looks like he has ported the Speex encoder to C# for the exact problem you are trying to solve. It is available here. Speex is designed for speech and should perform better than wma, mp3, or other audio codecs that are designed to handle music if you are just encoding speech, which I assume since you are grabbing from the mic.
This article http://alvas.net/alvas.audio,articles.aspx#how-to-save-audio-to-mp3-on-silverlight about save audio on client. To send audio data to a server you can use WebClient, for example.
You can do encoding thru the server, by send all stream to WCF service and do your encoding thru Microsoft Expression Encoding SDK API.
Please, see this url that i have asked before:
http://forums.silverlight.net/forums/t/181141.aspx
Regards