public static void SaveSpeechDB(string filename, SpeechDB speechFile) { using (StreamWriter file = File.CreateText(filename)) { JsonSerializer serializer = new JsonSerializer(); serializer.Formatting = Formatting.Indented; serializer.Serialize(file, speechFile); } }
public static SpeechDB CreateExampleFile() { SpeechDB speechExample = new SpeechDB(); for (int i = 0; i < 3; i++) { SpeechAct sa = new SpeechAct(); sa.SpeechType = "SpeechType" + i; for(int j=0; j<3; j++) { sa.Speech.Add("Speech " + j + " for " + sa.SpeechType); } for(int j=0; j<3; j++) { SpeechTag st = new SpeechTag(); st.ParameterName = "SpeechTag" + j + sa.SpeechType; st.Tag = "ST" + i.ToString() + j.ToString(); sa.Tags.Add(st); } speechExample.SpeechActs.Add(sa); } return speechExample; }