private void Identificare_Click(object sender, EventArgs e) { listBox2.Items.Clear(); string p = $"{Path.GetDirectoryName(Application.ExecutablePath)}\\TestSample\\ Identificare.wav"; VerificareForm form = new VerificareForm(p, DeviceNumber); List <NAudio.Wave.WaveInCapabilities> sourse = new List <NAudio.Wave.WaveInCapabilities>(); for (int i = 0; i < NAudio.Wave.WaveIn.DeviceCount; i++) { sourse.Add(NAudio.Wave.WaveIn.GetCapabilities(i)); } if (!(sourse.Count >= DeviceNumber - 1)) { DeviceNumber = sourse.Count() - 1; } form.ShowDialog(); if (!File.Exists(p)) { MessageBox.Show("Eroare, inregistrarea nu a fost efectuata cu succes"); return; } List <List <double> > aux = new List <List <double> >(DoMFCC(p)); re = new List <double>(); st = new List <string>(); foreach (string item in Directory.GetFiles("Users")) { FileInfo f = new FileInfo(item); rs = new ReteaNeuronala(12, 1, nrNeuroni, 1); if (!File.Exists($"{Path.GetDirectoryName(Application.ExecutablePath)}\\Weights\\{f.Name}.txt")) { rs.ExportXML(f.Name); } rs.ImportXML(f.Name); List <List <double> > Rezultate = new List <List <double> >(); for (int i = 0; i < aux.Count; i++) { List <double> target = new List <double>(); target.Add(1); List <double> Inputs = new List <double>(aux[i]); Rezultate.Add(rs.ForWordPropagation(Inputs, target)); } List <double> rez = new List <double>(); List <double> targ = new List <double>(); for (int i = 0; i < Rezultate.Count; i++) { List <double> au = new List <double>(Rezultate[i]); double value = au[0]; rez.Add(value); targ.Add(1); } double eroare = Eroarre(rez, targ); if (Verificare_Label.Text == "NaN%") { MessageBox.Show("Inregistrare esuata"); return; } else { re.Add(eroare); st.Add(f.Name); } } Sort(); for (int i = 0; i < st.Count; i++) { listBox2.Items.Add(st[i] + $"-> {re[i]}%"); } }
private void Verificare_Click(object sender, EventArgs e) { if (SelectedUser_Label.Text == "Nimeni") { MessageBox.Show("Selecteaza un utilizator"); return; } List <NAudio.Wave.WaveInCapabilities> sourse = new List <NAudio.Wave.WaveInCapabilities>(); for (int i = 0; i < NAudio.Wave.WaveIn.DeviceCount; i++) { sourse.Add(NAudio.Wave.WaveIn.GetCapabilities(i)); } if (!(sourse.Count >= DeviceNumber - 1)) { DeviceNumber = sourse.Count() - 1; } string p = $"{Path.GetDirectoryName(Application.ExecutablePath)}\\TestSample\\ {SelectedUser_Label.Text}.wav"; VerificareForm form = new VerificareForm(p, DeviceNumber); form.ShowDialog(); if (!File.Exists(p)) { MessageBox.Show("Eroare, inregistrarea nu a fost efectuata cu succes"); return; } List <List <double> > aux = new List <List <double> >(DoMFCC(p)); rs = new ReteaNeuronala(12, 1, nrNeuroni, 1); rs.ImportXML(SelectedUser_Label.Text); List <List <double> > Rezultate = new List <List <double> >(); for (int i = 0; i < aux.Count; i++) { List <double> target = new List <double>(); target.Add(1); List <double> Inputs = new List <double>(aux[i]); Rezultate.Add(rs.ForWordPropagation(Inputs, target)); } List <double> rez = new List <double>(); List <double> targ = new List <double>(); for (int i = 0; i < Rezultate.Count; i++) { List <double> au = new List <double>(Rezultate[i]); double value = au[0]; rez.Add(value); targ.Add(1); } double eroare = Eroarre(rez, targ); Verificare_Label.Text = eroare.ToString() + "%"; if (Verificare_Label.Text == "NaN%") { MessageBox.Show("Inregistrare esuata"); Verificare_Label.Text = "%"; } }