Best way to do voice authentication in C#

家住魔仙堡 提交于 2019-12-24 07:15:39

问题


I am building a voice authentication system and for that, I am using C# Speech recognition which lets me save the audio file which I convert and stores it as wav file.

I have another wav file in which I have stored my voice.

Then I am using FFT as mentioned here to compare 2 wav file and I use Cross Correlation code from here.

My openWav code is as below:

 public static void openWav(string filename, out double[] left, out double[] right)
        {
            var numArray = File.ReadAllBytes(filename);
            int num1 = numArray[22];
            int index1;
            int index2;
            int num2;
            for (index1 = 12;
                numArray[index1] != 100 || numArray[index1 + 1] != 97 ||
                (numArray[index1 + 2] != 116 || numArray[index1 + 3] != 97);
                index1 = index2 + (4 + num2))
            {
                index2 = index1 + 4;
                num2 = numArray[index2] + numArray[index2 + 1] * 256 + numArray[index2 + 2] * 65536 +
                       numArray[index2 + 3] * 16777216;
            }
            var index3 = index1 + 8;
            var length = (numArray.Length - index3) / 2;
            if (num1 == 2)
                length /= 2;
            left = new double[length];
            right = num1 != 2 ? null : new double[length];
            var index4 = 0;
            while (index3 < numArray.Length)
            {
                left[index4] = bytesToDouble(numArray[index3], numArray[index3 + 1]);
                index3 += 2;
                if (num1 == 2)
                {
                    right[index4] = bytesToDouble(numArray[index3], numArray[index3 + 1]);
                    index3 += 2;
                }
                ++index4;
            }
        }

It works without error but every time I get the answer in between 0.6 to 0.8 even though it is not my voice.

Can anyone suggest where I am doing wrong or if there is any other way to do it in C#?

来源:https://stackoverflow.com/questions/47125110/best-way-to-do-voice-authentication-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!