private void openToolStripMenuItem_Click(object sender, EventArgs e) { labelStatus.Text = "Status: Opening audio file..."; OpenFileDialog open = new OpenFileDialog(); if (open.ShowDialog() == DialogResult.OK) { isRecorded = false; path = open.FileName; //Open the selected audio file signal = AudioOperations.OpenAudioFile(path); Sequence seq = AudioOperations.ExtractFeatures(signal); updateButtons(); /// Enabling buttons Add and Identify /// The buttons btnIdentify and btnAdd are enabled ONLY after opening /// audio file /// } /// <summary> /// Updating status label /// </summary> /// labelStatus.Text = "Status: Ready"; }
public AudioSignalNode(NodeDescription description, IResourceHandle <GlobalEngine> engineHandle, NodeContext nodeContext) : base(nodeContext) { this.description = description; FSignalInstance = (AudioSignal)Activator.CreateInstance(description.Signal); FEngineHandle = engineHandle; foreach (var input in description.Inputs) { FInputsMap.Add(input.Name, new MyPin() { Name = input.Name, Type = input.Type, Value = input.DefaultValue }); } Inputs = FInputsMap.Values.ToArray(); foreach (var output in description.Outputs) { FOutputsMap.Add(output.Name, new MyPin() { Name = output.Name, Type = output.Type, Value = output.DefaultValue }); } Outputs = FOutputsMap.Values.ToArray(); }
//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ public RCFilter() { cut = 0.5f; rez = 0.7f; state = 0f; input = new AudioSignal(); // TODO should we have a global signal for not connected connector ? output = new AudioSignal(); }
/// <summary> /// Remove the silent segment from the given audio signal /// </summary> /// <param name="signal">original signal</param> /// <returns>signal after removing the silent segment(s) from it</returns> public static AudioSignal RemoveSilence(AudioSignal signal) { AudioSignal filteredSignal = new AudioSignal(); filteredSignal.sampleRate = signal.sampleRate; filteredSignal.signalLengthInMilliSec = signal.signalLengthInMilliSec; filteredSignal.data = MFCC.MFCC.RemoveSilence(signal.data, signal.sampleRate, signal.signalLengthInMilliSec, 20); return(filteredSignal); }
private void WriteDataToFile(double[] data) { if (signal is AudioSignal) { AudioSignal filteredSignal = new AudioSignal(((AudioSignal)signal).AudioProperties, data); SignalsWriter signalsWriter = new SignalsWriter(); signalsWriter.WriteAudioSignalToFile(filteredSignal, filePathTextBox.Text); } }
//========================================================================================================================================// private void saveToolStripMenuItem_Click(object sender, EventArgs e) { saveFileDialog1.ShowDialog(this); string name = saveFileDialog1.FileName; signal = AudioOperations.OpenAudioFile(name); // Rsignal = AudioOperations.RemoveSilence(signal); Sequence sequ = AudioOperations.ExtractFeatures(signal); }
//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ public Sampler(AudioClip sample) { output = new AudioSignal(); pos = 0; // get samples data len = sample.samples; data = new float[len]; sample.GetData(data, 0); }
static private AudioSignal openNISTWav(string filename) { int sample_rate = 0, sample_count = 0, sample_n_bytes = 0; StreamReader reader = new StreamReader(filename); while (true) { string line = reader.ReadLine(); var splittedLine = line.Split(' '); if (splittedLine[0] == "sample_count") { sample_count = int.Parse(splittedLine[2]); } else if (splittedLine[0] == "sample_rate") { sample_rate = int.Parse(splittedLine[2]); } else if (splittedLine[0] == "sample_n_bytes") { sample_n_bytes = int.Parse(splittedLine[2]); } else if (splittedLine[0] == "end_head") { break; } } reader.Close(); byte[] wav = File.ReadAllBytes(filename); //header offset. int pos = 1024; int samples = (wav.Length - pos) / sample_n_bytes; // 2 bytes per sample (16 bit sound mono) int altsamples = sample_count / sample_n_bytes; double[] data = new double[sample_count]; // Write to double array: int i = 0; while (pos < wav.Length) { data[i] = bytesToDouble(wav[pos], wav[pos + 1]); pos += 2; i++; } AudioSignal signal = new AudioSignal(); signal.sampleRate = sample_rate; signal.data = data; signal.signalLengthInMilliSec = (double)1000.0 * sample_count / sample_rate; return(signal); }
public AudioSignal ReadAudioSignalFromFile(string filePath) { AudioSignal signal; AudioSignalProperties audioProperties = ReadAudioSignalProperties(filePath); double[] data = ReadAudioDataFromFile(filePath, audioProperties.CalculateHeaderSize(), audioProperties.BitsPerSample); signal = new AudioSignal(audioProperties, data); return(signal); }
//========================================================================================================================================// private void btnAdd_Click(object sender, EventArgs e) { saveFileDialog1.ShowDialog(this); string name = saveFileDialog1.FileName; signal = AudioOperations.OpenAudioFile(name); // Rsignal = AudioOperations.RemoveSilence(signal); Sequence sequ = AudioOperations.ExtractFeatures(signal); RWFile wr = new RWFile(); wr.WriteTestFile(sequ); }
/// <summary> /// Open the given audio file and return an "AudioSignal" with the following info: /// 1. data[]: array of audio samples /// 2. sample rate /// 3. signal length in milli sec /// </summary> /// <param name="filePath">audio file path</param> /// <returns>AudioSignal containing its data, sample rate and length in ms</returns> public static AudioSignal OpenAudioFile(string filePath) { WaveDecoder waveDecoder = new WaveDecoder(filePath); AudioSignal signal = new AudioSignal(); signal.sampleRate = waveDecoder.SampleRate; signal.signalLengthInMilliSec = waveDecoder.Duration; Signal tempSignal = waveDecoder.Decode(waveDecoder.Frames); signal.data = new double[waveDecoder.Frames]; tempSignal.CopyTo(signal.data); return(signal); }
//========================================================================================================================================// private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); if (open.ShowDialog() == DialogResult.OK) { isRecorded = false; path = open.FileName; //Open the selected audio file signal = AudioOperations.OpenAudioFile(path); Sequence seq = AudioOperations.ExtractFeatures(signal); updateButtons(); } }
public Oscillator(float frequency, float amplitude, float sampleRate) { freq = frequency; newFreq = freq; amp = amplitude; newAmp = amp; srate = sampleRate; step = 0; stepSize = freq / (sampleRate); port = false; portStep = 0.01f; pan = 0; newPan = 0; leftScale = rightScale = 1; listener = null; ampMod = null; freqMod = null; }
private void TestAudio_Click(object sender, EventArgs e) { saveFileDialog1.ShowDialog(); string FilePath = saveFileDialog1.FileName; signal = AudioOperations.OpenAudioFile(FilePath); Sequence TestSequence = AudioOperations.ExtractFeatures(signal); Sequence VoiceSequence; FileStream FS = new FileStream("test2.txt", FileMode.Open, FileAccess.Read); StreamReader SR = new StreamReader(FS); int NoOfVoices = (int)FS.ReadByte(); ReadVoices = new RWFile(NoOfVoices); DTW.VoiceDifferences = new double[NoOfVoices]; for (int i = 0; i < NoOfVoices; i++) { VoiceSequence = new Sequence(); VoiceSequence = ReadVoices.ReadFromFile(FS, SR, i); K = Math.Abs(TestSequence.NoOfFrames - VoiceSequence.NoOfFrames); DTW.VoiceDifferences[i] = DTW.Compare(TestSequence, VoiceSequence, 2); } FS.Close(); SR.Close(); string SpeakerName = DTW.GetSpeakerName(ReadVoices.UserNames, NoOfVoices); MessageBox.Show("Identified Speaker is " + SpeakerName); // MessageBox.Show(SpeakerName); this.Hide(); StartUpForm.Show(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); if (open.ShowDialog() == DialogResult.OK) { isRecorded = false; path = open.FileName; //Open the selected audio file signal = AudioOperations.OpenAudioFile(path); // remove sielnce AudioOperations.RemoveSilence(signal); Sequence seq = AudioOperations.ExtractFeatures(signal); seq_input = seq; /////*** seq_input initialize by open audio///////// sz_input = seq_input.Frames.Length; textBox2.Text = ""; textBox3.Text = ""; updateButtons(); } }
//===========================================================================================================================================// private void SaveAudio_Click(object sender, EventArgs e) { //Save the signal in a wave file saveFileDialog1.ShowDialog(this); string name = saveFileDialog1.FileName; //Extract the Features for saving signal = AudioOperations.OpenAudioFile(name); Sequence S = AudioOperations.ExtractFeatures(signal); //Write the Sequence in file RWFile Write = new RWFile(); Write.WriteInFile(S, UserName); MessageBox.Show("Voice Recorded Successfully"); //Re-direct the user to the start up form StartUpForm.Show(); //hide the current form this.Hide(); }
public static void IdentifySignalEvent(AudioSignal __instance) => new IdentifySignalMessage(__instance._name).Send();
public static void IdentifyFrequencyEvent(AudioSignal __instance) => new IdentifyFrequencyMessage(__instance._frequency).Send();
//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ public OscRamp() { pos = 0f; Freq = 440f; output = new AudioSignal(); }
public override void OnReceiveRemote(bool server, EnumMessage <SignalFrequency> message) { PlayerData.LearnFrequency(message.EnumValue); var displayMsg = $"{UITextLibrary.GetString(UITextType.NotificationNewFreq)} <color=orange>{AudioSignal.FrequencyToString(message.EnumValue, false)}</color>"; var data = new NotificationData(NotificationTarget.All, displayMsg, 10f, true); NotificationManager.SharedInstance.PostNotification(data, false); }
public void WriteAudioSignalToFile(AudioSignal signal, string filePath) { WriteAudioSignalPropertiesToFile(signal.AudioProperties, signal.Count, filePath); WriteAudioDataToFile(signal.Data, signal.AudioProperties.CalculateHeaderSize(), filePath, signal.AudioProperties.BitsPerSample); }
/// <summary> /// Extract MFCC coefficients of the sequence of frames for the given AudioSignal. /// Each frame (feature) consists of 13 coefficients /// </summary> /// <param name="signal">Audio signal to extract its features</param> /// <returns>Sequence of features (13 x NumOfFrames)</returns> public static Sequence ExtractFeatures(AudioSignal signal) { return(MFCC.MFCC.ExtractFeatures(signal.data, signal.sampleRate)); }
public static bool Moon_ChangeQuantumState( QuantumMoon __instance, ref bool __result, bool skipInstantVisibilityCheck, bool ____isPlayerInside, bool ____hasSunCollapsed, float ____playerWarpTime, ref int ____stateIndex, ref int ____collapseToIndex, QuantumOrbit[] ____orbits, float ____sphereCheckRadius, VisibilityTracker ____visibilityTracker, OWRigidbody ____moonBody, ConstantForceDetector ____constantForceDetector, ref bool ____useInitialMotion, ref int ____lastStateIndex, ref int[] ____stateSkipCounts, AudioSignal ____quantumSignal, ReferenceFrameVolume ____referenceFrameVolume, GameObject[] ____deactivateAtEye ) { if (QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, skipInstantVisibilityCheck) && !QuantumManager.Instance.Shrine.IsPlayerInDarkness()) { if (!skipInstantVisibilityCheck) { var method = new StackTrace().GetFrame(3).GetMethod(); DebugLog.ToConsole($"Warning - Tried to change moon state while still observed. Called by {method.DeclaringType}.{method.Name}", MessageType.Warning); } __result = false; return(false); } var flag = false; if (____isPlayerInside && ____hasSunCollapsed) { __result = false; return(false); } if (Time.time - ____playerWarpTime < 1f) { __result = false; return(false); } if (____stateIndex == 5 && ____isPlayerInside && !__instance.IsPlayerEntangled()) { __result = false; return(false); } for (var i = 0; i < 10; i++) { var stateIndex = (____collapseToIndex == -1) ? (int)__instance.GetType().GetMethod("GetRandomStateIndex", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, null) : ____collapseToIndex; var orbitIndex = -1; for (var j = 0; j < ____orbits.Length; j++) { if (____orbits[j].GetStateIndex() == stateIndex) { orbitIndex = j; break; } } if (orbitIndex == -1) { DebugLog.ToConsole($"Error - QM failed to find orbit for state {stateIndex}", MessageType.Error); } var orbitRadius = (orbitIndex == -1) ? 10000f : ____orbits[orbitIndex].GetOrbitRadius(); var owRigidbody = (orbitIndex == -1) ? Locator.GetAstroObject(AstroObject.Name.Sun).GetOWRigidbody() : ____orbits[orbitIndex].GetAttachedOWRigidbody(); var onUnitSphere = UnityEngine.Random.onUnitSphere; if (stateIndex == 5) { onUnitSphere.y = 0f; onUnitSphere.Normalize(); } var position = (onUnitSphere * orbitRadius) + owRigidbody.GetWorldCenterOfMass(); if (!Physics.CheckSphere(position, ____sphereCheckRadius, OWLayerMask.physicalMask) || ____collapseToIndex != -1) { ____visibilityTracker.transform.position = position; if (!Physics.autoSyncTransforms) { Physics.SyncTransforms(); } if (__instance.IsPlayerEntangled() || !QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, skipInstantVisibilityCheck)) { ____moonBody.transform.position = position; if (!Physics.autoSyncTransforms) { Physics.SyncTransforms(); } ____visibilityTracker.transform.localPosition = Vector3.zero; ____constantForceDetector.AddConstantVolume(owRigidbody.GetAttachedGravityVolume(), true, true); var velocity = owRigidbody.GetVelocity(); if (____useInitialMotion) { var initialMotion = owRigidbody.GetComponent <InitialMotion>(); velocity = (initialMotion == null) ? Vector3.zero : initialMotion.GetInitVelocity(); ____useInitialMotion = false; } var orbitAngle = UnityEngine.Random.Range(0, 360); ____moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(owRigidbody, ____moonBody, orbitAngle) + velocity); ____lastStateIndex = ____stateIndex; ____stateIndex = stateIndex; ____collapseToIndex = -1; flag = true; for (var k = 0; k < ____stateSkipCounts.Length; k++) { ____stateSkipCounts[k] = (k != ____stateIndex) ? (____stateSkipCounts[k] + 1) : 0; } QSBEventManager.FireEvent(EventNames.QSBMoonStateChange, stateIndex, onUnitSphere, orbitAngle); break; } ____visibilityTracker.transform.localPosition = Vector3.zero; } else { DebugLog.ToConsole("Warning - Quantum moon orbit position occupied! Aborting collapse.", MessageType.Warning); } } if (flag) { if (____isPlayerInside) { __instance.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { ____stateIndex }); } else { __instance.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { -1 }); ____quantumSignal.SetSignalActivation(____stateIndex != 5, 2f); } ____referenceFrameVolume.gameObject.SetActive(____stateIndex != 5); ____moonBody.SetIsTargetable(____stateIndex != 5); for (var l = 0; l < ____deactivateAtEye.Length; l++) { ____deactivateAtEye[l].SetActive(____stateIndex != 5); } GlobalMessenger <OWRigidbody> .FireEvent("QuantumMoonChangeState", ____moonBody); __result = true; return(false); } __result = false; return(false); }
private void btnIdentify_Click(object sender, EventArgs e) { /// <summary> /// updating status label /// </summary> /// metroLabel1.Visible = true; pruningToggle1.Visible = true; labelStatus.Text = "Status: Identifying speaker and running DTW algorithm..."; List <User> test = new List <User>(); string cnt = "";// To choose a testcase if (Testcase1_radioButton.Checked == true) { test = TestcaseLoader.LoadTestcase1Testing(@"C:\SpeakerID\Test Cases\Complete SpeakerID Dataset\TestingList.txt"); cnt = "1"; } else if (Testcase2_radioButton.Checked == true) { test = TestcaseLoader.LoadTestcase2Testing(@"C:\SpeakerID\Test Cases\Complete SpeakerID Dataset\TestingList.txt"); cnt = "2"; } else if (Testcase3_radioButton.Checked == true) { test = TestcaseLoader.LoadTestcase3Testing(@"C:\SpeakerID\Test Cases\Complete SpeakerID Dataset\TestingList.txt"); cnt = "3"; } else if (caseMilestone1.Checked) //First testcase { AudioSignal signalTemp = AudioOperations.OpenAudioFile("C:\\SpeakerID\\Test Cases\\Sample Test\\Input sample\\ItIsPlausible_Rich_US_English.wav"); signalTemp = AudioOperations.RemoveSilence(signalTemp); //don't analyze (template function) User userTemp = new User(); userTemp.UserTemplates = new List <AudioSignal>(); userTemp.UserName = ("Rich"); userTemp.UserTemplates.Add(signalTemp); test.Add(userTemp); cnt = "4"; } else if (caseMilestone2.Checked) { AudioSignal signalTemp = AudioOperations.OpenAudioFile("C:\\SpeakerID\\Test Cases\\Pruning Test\\1 min\\[Input] Why Study Algorithms - (1 min).wav"); signalTemp = AudioOperations.RemoveSilence(signalTemp); User userTemp = new User(); userTemp.UserTemplates = new List <AudioSignal>(); userTemp.UserName = ("BigOh (1 min)"); userTemp.UserTemplates.Add(signalTemp); test.Add(userTemp); cnt = "5"; } else if (caseMilestone3.Checked) { AudioSignal signalTemp = AudioOperations.OpenAudioFile("C:\\SpeakerID\\Test Cases\\Pruning Test\\4 min\\[Input] Why Study Algorithms - (4 min).wav"); signalTemp = AudioOperations.RemoveSilence(signalTemp); User userTemp = new User(); userTemp.UserTemplates = new List <AudioSignal>(); userTemp.UserName = ("BigOh (4 min)"); userTemp.UserTemplates.Add(signalTemp); test.Add(userTemp); cnt = "6"; } for (int y = 0; y < test.Count; ++y) { Random rnd = new Random(); //Generate random number to choose an audio sample to test it against the database AudioSignal sig = new AudioSignal(); sig = test[y].UserTemplates[0]; //rnd.Next(0, test[y].UserTemplates.Count)]; Sequence compareSequence_input = new Sequence(); compareSequence_input = AudioOperations.ExtractFeatures(sig); FileStream FS = new FileStream("C:/SpeakerID/case" + cnt + "/Relations.txt", FileMode.Open); StreamReader SR = new StreamReader(FS); string relations = SR.ReadLine(); SR.Close(); /// <summary> /// Split the string relations into an array of strings /// Delimiter: # /// Then split each string into name and path /// Delimiter: % /// Filling an array of "relationItem"s with the names and sequence paths of all sequences in the database, and leaving the /// distance attribute in all the array items as they are "NULL", until calculated using the DTW algorithm /// </summary> /// string[] relationsStrArr = relations.Split('#'); relationItem[] relationsStructArr = new relationItem[relationsStrArr.Length - 1]; matchedPerson person = new matchedPerson(); person.distance = -1; for (int i = 0; i < relationsStructArr.Length; i++) { string[] stringArrTemp = relationsStrArr[i].Split('%'); relationsStructArr[i].nameStr = stringArrTemp[0]; relationsStructArr[i].sequencePath = stringArrTemp[1]; } Stopwatch sw; TimeSpan TS = TimeSpan.Zero; for (int i = 0; i < relationsStructArr.Length; i++) //Loops on all sequences in DB { /// Reset the "compareSequence_output" variable and prepare SR for reading the sequence Sequence compareSequence_output = new Sequence(); FS = new FileStream(relationsStructArr[i].sequencePath, FileMode.Open); SR = new StreamReader(FS); /// Resetting the "file" variable string file = ""; file += SR.ReadLine(); string[] strTempFrames = file.Split('#'); //strTemp now contains all Frames in a sequence compareSequence_output.Frames = new MFCCFrame[strTempFrames.Length]; //Setting number of frames in output sequence for (int j = 0; j < strTempFrames.Length; j++) //Loops on all frames in a sequence { string[] strTempFeatures = strTempFrames[j].Split('%'); MFCCFrame frame = new MFCCFrame(); for (int k = 0; k < 13; k++) { frame.Features[k] = double.Parse(strTempFeatures[k]); //Loops on all 13 features in a frame and converts string to double } compareSequence_output.Frames[j] = new MFCCFrame(); for (int k = 0; k < 13; k++) { compareSequence_output.Frames[j].Features[k] = frame.Features[k]; } } /// Save the difference between compareSequence_output and compareSequence_input in relationsStructArr[i].distance if (pruningToggle1.Checked == true) { sw = Stopwatch.StartNew(); relationsStructArr[i].distance = Pruning_DTW(compareSequence_input, compareSequence_output); sw.Stop(); TS += sw.Elapsed; } else { sw = Stopwatch.StartNew(); relationsStructArr[i].distance = DTW_improved(compareSequence_input, compareSequence_output); sw.Stop(); TS += sw.Elapsed; } // update person object if (relationsStructArr[i].distance < person.distance || person.distance == -1) { person.distance = relationsStructArr[i].distance; person.name = relationsStructArr[i].nameStr; } /// Close the SR SR.Close(); Console.WriteLine(relationsStructArr[i].nameStr); } /// <summary> /// Updating status label and showing search results /// </summary> /// labelStatus.Text = "Status: Searching done."; Console.WriteLine(test[y].UserName); MessageBox.Show("Search completed\nThe closest match to this speaker is: " + person.name + "\nTime Elapsed for DTW only: " + TS.Hours + ':' + TS.Minutes + ':' + TS.Seconds + ':' + TS.Milliseconds + "\nTotal cost: " + person.distance, "Search Results"); labelStatus.Text = "Status: Ready"; } }
public override void OnReceiveRemote(bool server, EnumMessage <SignalName> message) { PlayerData.LearnSignal(message.EnumValue); QSBEventManager.FireEvent("IdentifySignal"); var displayMsg = $"{UITextLibrary.GetString(UITextType.NotificationSignalIdentified)} <color=orange>{AudioSignal.SignalNameToString(message.EnumValue)}</color>"; var data = new NotificationData(NotificationTarget.All, displayMsg, 10f, true); NotificationManager.SharedInstance.PostNotification(data, false); }
void SetAmplitudeModulator(AudioSignal s) { ampMod = s; }
private void btnAdd_Click(object sender, EventArgs e) { if (TestCase1.Checked) { string name = ""; List <User> t = TestcaseLoader.LoadTestcase1Training(@"C:\test\Complete SpeakerID Dataset\TrainingList.txt"); FileStream F = new FileStream("Projectsequences1.txt", FileMode.Append); StreamWriter sa = new StreamWriter(F); for (int i = 0; i < t.Count; i++) { name = t[i].UserName; for (int j = 0; j < t[i].UserTemplates.Count; j++) { AudioSignal sig = new AudioSignal(); seq = AudioOperations.ExtractFeatures(t[i].UserTemplates[j]); record = ""; for (int k = 0; k < seq.Frames.Length; k++) { for (int l = 0; l < 13; l++) { record += seq.Frames[k].Features[l]; if (l != 12) { record += "@"; } } if (k != seq.Frames.Length - 1) { record += "#"; } } sa.WriteLine(name); sa.WriteLine(record); } } sa.Close(); } if (TestCase2.Checked) { string name = ""; List <User> t = TestcaseLoader.LoadTestcase2Training(@"C:\test\Complete SpeakerID Dataset\TrainingList.txt"); FileStream F = new FileStream("Projectsequences2.txt", FileMode.Append); StreamWriter sa = new StreamWriter(F); for (int i = 0; i < t.Count; i++) { name = t[i].UserName; for (int j = 0; j < t[i].UserTemplates.Count; j++) { AudioSignal sig = new AudioSignal(); seq = AudioOperations.ExtractFeatures(t[i].UserTemplates[j]); record = ""; for (int k = 0; k < seq.Frames.Length; k++) { for (int l = 0; l < 13; l++) { record += seq.Frames[k].Features[l]; if (l != 12) { record += "@"; } } if (k != seq.Frames.Length - 1) { record += "#"; } } sa.WriteLine(name); sa.WriteLine(record); } } sa.Close(); } if (TestCase3.Checked) { string name = ""; List <User> t = TestcaseLoader.LoadTestcase3Training(@"C:\test\Complete SpeakerID Dataset\TrainingList.txt"); FileStream F = new FileStream("Projectsequences3.txt", FileMode.Append); StreamWriter sa = new StreamWriter(F); for (int i = 0; i < t.Count; i++) { name = t[i].UserName; for (int j = 0; j < t[i].UserTemplates.Count; j++) { AudioSignal sig = new AudioSignal(); seq = AudioOperations.ExtractFeatures(t[i].UserTemplates[j]); record = ""; for (int k = 0; k < seq.Frames.Length; k++) { for (int l = 0; l < 13; l++) { record += seq.Frames[k].Features[l]; if (l != 12) { record += "@"; } } if (k != seq.Frames.Length - 1) { record += "#"; } } sa.WriteLine(name); sa.WriteLine(record); } } sa.Close(); } if (Normal.Checked) { FileStream F = new FileStream("Projectsequences.txt", FileMode.Append); StreamWriter sa = new StreamWriter(F); Console.WriteLine("enter your name : "); string name = Console.ReadLine(); record = ""; for (int k = 0; k < seq.Frames.Length; k++) { for (int l = 0; l < 13; l++) { record += seq.Frames[k].Features[l]; if (l != 12) { record += "@"; } } if (k != seq.Frames.Length - 1) { record += "#"; } } sa.WriteLine(name); sa.WriteLine(record); sa.Close(); } }
//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ public Envelope() { output = new AudioSignal(); Time = 0.5f; }
void SetFrequencyModulator(AudioSignal s) { freqMod = s; }