public CMUSphinx_GrammarDict CreateGrammarDoc_FSG() { if (currentCMUSphinxDoc != null) return currentCMUSphinxDoc; CMUSphinx_GrammarDict ret = new CMUSphinx_GrammarDict(); ret.GrammarName = GetName(); CMUSphinx_FSGState root = ret.FSGCreate(ret.GrammarName); CMUSphinx_FSGState s;// = ret.FSGTransitionToNewState(root, "Holly i'm awake"); //ret.FSGGroupStates(s, ret.FSGGetEndState()); s = ret.FSGTransitionToNewState(root, "Holly i am awake"); ret.FSGGroupStates(s, ret.FSGGetEndState()); s = ret.FSGTransitionToNewState(root, "Holly turn off the alarm please"); ret.FSGGroupStates(s, ret.FSGGetEndState()); ret.BuildFSGGrammarAndDict(); currentCMUSphinxDoc = ret; return ret; }
public CMUSphinx_GrammarDict CreateGrammarDoc_FSG() { if (currentCMUDoc != null) return currentCMUDoc; caps_rules_fsg = new Dictionary<EDeviceCapabilities,Tuple<CMUSphinx_FSGState,CMUSphinx_FSGState>>(); CMUSphinx_GrammarDict ret = new CMUSphinx_GrammarDict(); ret.GrammarName = GetName(); CMUSphinx_FSGState root = ret.FSGCreate(GetName()); CMUSphinx_FSGState holly = ret.FSGTransitionToNewState(root, "Holly"); // HOLLY <ACTION> (<DEVICECLASS> [(<ROOM> | HERE)] | <DEVICENAME> ) PLEASE //only add to this list if the action only has a single output, "Please" CMUSphinx_FSGState preSinglePlease = ret.FSGCreateOrphanState(); CMUSphinx_FSGState postSinglePlease = ret.FSGCreateOrphanState(); ret.FSGLinkStates(preSinglePlease, postSinglePlease, "please"); foreach (Room rm in ListRooms()) { if (rm.Name == "") continue; CMUSphinx_FSGState actionDevicePreRoom = null; foreach (Device d in rm.ListDevices()) { CMUSphinx_FSGState startAction = null, endAction = null; bool caps_valid = FSGActionsFromCapabilities(d.Capabilities, ret, ref startAction, ref endAction); if (!caps_valid) continue; ret.FSGGroupStates(holly, startAction); //Action immediately follows Holly string cl = SoundsLike.Get(d.Class, false); if (cl != "") { if(actionDevicePreRoom == null) actionDevicePreRoom = ret.FSGCreateOrphanState(); ret.FSGLinkStates(startAction, actionDevicePreRoom, cl); } if (d.FriendlyName != "") { ret.FSGLinkStates(endAction, preSinglePlease, d.FriendlyName); } } if (actionDevicePreRoom == null) continue; //no device classes in room if (rm != CurrentLocation) { ret.FSGLinkStates(actionDevicePreRoom, preSinglePlease, "in the "+rm.Name); } else { ret.FSGLinkStates(actionDevicePreRoom, preSinglePlease, "in the " + rm.Name); ret.FSGLinkStates(actionDevicePreRoom, preSinglePlease, "here"); } ret.FSGLinkStates(actionDevicePreRoom, postSinglePlease, "please"); } ret.FSGGroupStates(ret.FSGGetEndState(), postSinglePlease); ret.BuildFSGGrammarAndDict(); currentCMUDoc = ret; return ret; }
public CMUSphinx_GrammarDict CreateGrammarDoc_FSG() { if (currentJSGFDoc != null) return currentJSGFDoc; CMUSphinx_GrammarDict ret = new CMUSphinx_GrammarDict(); ret.GrammarName = GetName(); CMUSphinx_FSGState root = ret.FSGCreate(ret.GrammarName); CMUSphinx_FSGState end = ret.FSGGetEndState(); //numbers CMUSphinx_FSGState epNumsStart = ret.FSGCreateOrphanState(); CMUSphinx_FSGState epNumsEnd = CreateNumberFSG(epNumsStart, ret); CMUSphinx_FSGState seasonNumsStart = ret.FSGCreateOrphanState(); CMUSphinx_FSGState seasonNumsEnd = CreateNumberFSG(seasonNumsStart, ret); //TV Shows if (mTVShows == null) { mTVShows = ListTVShows(); } if (mTVShows == null) return null; List<string> tvShowNames = new List<string>(); foreach (XBMCProto.TVShow s in mTVShows) { string temps = CleanString(s.label); temps = temps.Trim(); if (temps == "" || s.tvshowid < 1) continue; tvShowNames.Add(temps); } CMUSphinx_FSGState play = ret.FSGTransitionToNewState(root, "Holly play show"); CMUSphinx_FSGState temp1 = ret.FSGTransitionToNewState(root, "Holly resume show"); ret.FSGGroupStates(play, temp1); temp1 = ret.FSGCreateOrphanState(); CMUSphinx_FSGState temp2; foreach (string s in tvShowNames) { temp2 = ret.FSGTransitionToNewState(play, s); ret.FSGGroupStates(temp1, temp2); } temp1 = ret.FSGTransitionToNewState(temp1, "season"); temp1 = CreateNumberFSG(temp1, ret); temp1 = ret.FSGTransitionToNewState(temp1, "episode"); temp1 = CreateNumberFSG(temp1, ret); temp1 = ret.FSGTransitionToNewState(temp1, "please"); ret.FSGGroupStates(end, temp1); //Movies if (mMovies == null) { mMovies = ListMovies(); } if (mMovies == null) return null; List<string> movieNames = new List<string>(); foreach (XBMCProto.Movie m in mMovies) { string temps = CleanString(m.label); temps = temps.Trim(); if (temps == "" || m.movieid < 1) continue; movieNames.Add(temps); } play = ret.FSGTransitionToNewState(root, "Holly play movie"); temp1 = ret.FSGTransitionToNewState(root, "Holly resume movie"); ret.FSGGroupStates(play, temp1); temp1 = ret.FSGCreateOrphanState(); foreach (string s in movieNames) { temp2 = ret.FSGTransitionToNewState(play, s); ret.FSGGroupStates(temp1, temp2); } temp1 = ret.FSGTransitionToNewState(temp1, "please"); ret.FSGGroupStates(end, temp1); //Music Genres SrgsOneOf audioGenres = new SrgsOneOf(); if (mGenres == null) { mGenres = ListAudioGenres(); } if (mGenres == null) return null; List<string> genreNames = new List<string>(); foreach (XBMCProto.Genre m in mGenres) { string temps = CleanString(m.label); temps = temps.Trim(); if (temps == "" || m.genreid < 1) continue; genreNames.Add(temps); } play = ret.FSGTransitionToNewState(root, "Holly play me some"); temp1 = ret.FSGCreateOrphanState(); foreach (string s in movieNames) { temp2 = ret.FSGTransitionToNewState(play, s); ret.FSGGroupStates(temp1, temp2); } temp1 = ret.FSGTransitionToNewState(temp1, "music please"); ret.FSGGroupStates(end, temp1); //Other play = ret.FSGTransitionToNewState(root, "Holly stop media please"); ret.FSGGroupStates(end, play); play = ret.FSGTransitionToNewState(root, "Holly pause media please"); ret.FSGGroupStates(end, play); play = ret.FSGTransitionToNewState(root, "Holly resume media please"); ret.FSGGroupStates(end, play); ret.BuildFSGGrammarAndDict(); currentJSGFDoc = ret; return ret; }