I use this formula to get frequency of a signal but I dont understand how to implement code with complex number? There is "i" in formula that relates Math.Sqrt(-1). How can I code this formula to signal in C# with NAduio library?
If you want to go back to a basic level then:
You'll want to use some form of probabilistic model, something like a hidden Markov model (HMM). This will allow you to test what the user says to a collection of models, one for each word they are allowed to say.
Additionally you want to transform the audio waveform into something that your program can more easily interpret. Something like a fast Fourier transform (FFT) or a wavelet transform (CWT).
The steps would be:
Get audio
Remove background noise
Transform via FFT or CWT
Detect peaks and other features of the audio
Compare these features with your HMMs
Pick the HMM with the best result about a threshold.
Of course this requires you to previously train the HMMs with the correct words.
A lot of languages actually provide Libraries for this that come, built in. One example, in C#.NET, is at this link. This gives you a step by step guide to how to set up a speech recognition program. It also abstracts you away from the low level detail of parsing audio for certain phenomes etc (which frankly is pointless with the amount of libraries there are about, unless you wish to write a highly optimized version).
It is a difficult problem nonetheless and you will have to use a ASR framework to do it. I have done something slightly more complex (~100 words) using Sphinx4. You can also use HTK.
In general what you have to do is:
write down all the words that you want to recognize
determine the syntax of your commands like (direction) (amount)
Then choose a framework, get an acoustic model, generate a dictionary and a language model compatible with that framework. Then integrate the framework into your application.
I hope I have mentioned all important things you need to do. You can google them separately or go to your chosen framework's tutorial.
Your task is relatively simple in terms of speech recognition and you should get good results if you complete it.
Related
I want to create a model for translation, basically input a string of a certain length in one language (like Japanese) and output a string of similar length in another language (like English).
Because I'm not a fan of Python (which most ML uses for some reason) I'm currently looking into ML.Net for this, but as far as I can tell there is no algorithm that supports this kind of data mapping. The closest I found was categorizing (basically string to enum), but that doesn't work as there are virtually infinite categorize.
I'm just really puzzled by this as translation, or chat bots, are quit old usecases for ML. I searched the web, but I still think I'm missing something here.
this is a question related to statistic calculation. The process that I will be going through is sampling survey. I will have a fluctuating sample on a daily basis.
I will write a program to process data. After the data is imported into the database. I will have to assign weighting to each group, to make the sample resemble actual ratio in the .
Can anyone tell me if there is any useful tools/ library that I can make use of for this function? i.e interpolation, extrapolation or weighted sample?
Although i will be writing this program in C#, solution in others language or software is welcomed too, e.g. R etc.
For statistical calculations in C# I recommend ILNumerics library.
ILNumerics home page
i want to record someones voice and then from information i get about his/her voice i recognize if that person speak again! problem is i have no information about what stats(like frequency ) cause difference to human voice, if any one could help me with how i could recognize someones voice?
while i was researching i found various libraries about speech recognition but they could not help me because my problem is very simpler! i just want to recognize The person who speaking not what he is saying.
The problem you describe is not simple since the voice of the same person can sound different (for example if the person has a cold etc.) and/or if the person is speaking louder/faster/slower etc.
Another point is the separation from other sounds (background, other voices etc.).
The quality of the equipment which records the sound is very important - some systems use multiple microphones to achieve good results...
Altogether this is no easy task - esp. if you want to achieve a good detection ratio.
Basically the way to implement this is:
implement robust sound separation
implement a robust sound/voice pattern extraction
create a DB with fingerprint(s) of the voice(s) you want to recognize based on ideal sound setting
define an algorithm for comparison between your stored fingerprint(s) and the extracted/normalized sound/voice pattern (have some thresholds for "probably equal" etc. might be necessary...)
refine your algorithms till you achieve an acceptable detection rate (take the false positive rate into account too!)
For a nice overview see http://www.scholarpedia.org/article/Speaker_recognition
See VoiceID for Linux. It uses Sphinx and other libs and installs pretty easily.
Some help here, maybe: http://www.generation5.org/content/2004/noReco.asp
Based on an open source FFT library ( http://www.exocortex.org/dsp/ ), with some suggestions about how to do speaker verification.
I'm trying to create a Guitar-Hero-like game (something like this) and I want to be able to analyze an audio file given by the user and create levels automatically, but I am not sure how to do that.
I thought maybe I should use BPM detection algorithm and place an arrow on a beat and a rail on some recurrent pattern, but I have no idea how to implement those.
Also, I'm using NAudio's BlockAlignReductionStream which has a Read method that copys byte[] data, but what happens when I read a 2-channels audio file? does it read 1 byte from the first channel and 1 byte from the second? (because it says 16-bit PCM) and does the same happen with 24-bit and 32-bit float?
Beat detection (or more specifically BPM detection)
Beat detection algorithm overview for using a comb filter:
http://www.clear.rice.edu/elec301/Projects01/beat_sync/beatalgo.html
Looks like they do:
A fast Fourier transform
Hanning Window, full-wave rectification
Multiple low pass filters; one for each range of the FFT output
Differentiation and half-wave rectification
Comb filter
Lots of algorithms you'll have to implement here. Comb filters are supposedly slow, though. The wiki article didn't point me at other specific methods.
Edit: This article has information on streaming statistical methods of beat detection. That sounds like a great idea: http://www.flipcode.com/misc/BeatDetectionAlgorithms.pdf - I'm betting they run better in real time, though are less accurate.
BTW I just skimmed and pulled out keywords. I've only toyed with FFT, rectification, and attenuation filters (low-pass filter). The rest I have no clue about, but you've got links.
This will all get you the BPM of the song, but it won't generate your arrows for you.
Level generation
As for "place an arrow on a beat and a rail on some recurrent pattern", that is going to be a bit trickier to implement to get good results.
You could go with a more aggressive content extraction approach, and try to pull the notes out of the song.
You'd need to use beat detection for this part too. This may be similar to BPM detection above, but at a different range, with a band-pass filter for the instrument range. You also would swap out or remove some parts of the algorithm, and would have to sample the whole song since you're not detecting a global BPM. You'd also need some sort of pitch detection.
I think this approach will be messy and will guarantee you need to hand-scrub the results for every song. If you're okay with this, and just want to avoid the initial hand transcription work, this will probably work well.
You could also try to go with a content generation approach.
Most procedural content generation has been done in a trial-and-error manner, with people publishing or patenting algorithms that don't completely suck. Often there is no real qualitative analysis that can be done on content generation algorithms because they generate aesthetics. So you'd just have to pick ones that seem to give pleasing sample results and try it out.
Most algorithms are centered around visual content generation, including terrain, architecture, humanoids, plants etc. There is some research on audio content generation, Generative Music, etc. Your requirements don't perfectly match either of these.
I think algorithms for procedural "dance steps" (if such a thing exists - I only found animation techniques) or Generative Music would be the closest match, if driven by the rhythms you detect in the song.
If you want to go down the composition generation approach, be prepared for a lot of completely different algorithms that are usually just hinted about, but not explained in detail.
E.g.:
http://tones.wolfram.com/about/faqs/howitworks.html
http://research.microsoft.com/en-us/um/redmond/projects/songsmith/
I'm looking for a C# .NET library for digital filtering (lowpass, highpass, notch) to filter ECG waveforms in real-time. Any suggestions?
If this is non commercial use, I have heard good things about the Signal Lab library. It is free for non commercial use, $570 for commercial use. It it a bit overkill if you are just needing low pass, high pass, and band pass filters. but it does come with controls for visualizing the data if you do not have any yet.
If you just need the filters you may just want to write your own code for the 3 filters. You can check the wikipedia pages for psudocode examples of a Low-pass filter and High-pass filter, I did not quickly find a code example of a noch filter.
Here are some C examples of various filters, to help give you a clue on what you need to do.
If your data is arriving in discrete chunks, I would use Reactive Extensions. This allows the input to control what happens next (reacting to data) instead of using "pull" operations. You can then react to this data by passing it through filters, and then react to that data by displaying it or performing additional calculations.
If you only need notch, high, and low filters, these are trivial to write. As each chunk of data arrives, you can decide whether or not to pass it to the next step (or whether or not to modify the data first). I would imagine you could write this whole section of code in less than 20 lines (maybe less than 10) using Rx. It would result in some pretty elegant code for this use case.
As far as I know you can write your own, because I did.
This should be a good starter for you (coded in C++ but you can easily covert the syntax to C#) - http://www.codeproject.com/KB/cpp/ecg_dsp.aspx
Third party libraries wouldn't be very flexible on the filter equation parameters. As you only will know the characteristics of your signal (amplitudes, frequency band and sampling etc.)
I recommend using a waveshaping algorithm first to get a smooth signal on the C# side before you apply filters, if your ECG sampling rate is low.