Example #1
0
        static void engine_RecognizeCompleted(object sender, System.Speech.Recognition.RecognizeCompletedEventArgs e)
        {
            DMDocument  doc       = new DMDocument();
            DMParagraph paragraph = new DMParagraph();


            DictationSyncEngine engine = sender as DictationSyncEngine;

            if (engine != null)
            {
                for (int i = 0; i < engine.Result.Count; i++)
                {
                    var        sentence   = engine.Result[i];
                    DMSentence dmSentence = BuildSentence(i, sentence);
                    paragraph.Inlines.Add(dmSentence);
                }

                doc.Blocks.Add(paragraph);
            }

            doc.Save(Path.Combine(Environment.CurrentDirectory, "data.xml"));

            Console.WriteLine("Recognize Completed!");

            Console.WriteLine("Press any key to exists!");
        }
 public void NotifySyncDocument(string documentstring)
 {
     this.ParentWindow.Dispatcher.Invoke(() =>
     {
         this.Document = DMDocument.Load(documentstring);
     });
 }
Example #3
0
 private void SaveDocument(DMDocument doc, string filepath)
 {
     if (doc != null)
     {
         doc.Save(filepath);
     }
 }
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="context">WF context</param>
        /// <returns></returns>
        protected override void Execute(NativeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            SplitedDocument sDoc         = context.GetValue(this.SplitedDocument);
            var             localEpisode = context.GetValue(this.LocalEpisode);

            // TODO : Code this activity
            DMDocument doc = new DMDocument();

            int index = 0;

            foreach (var para in sDoc.Paragraphs)
            {
                DMParagraph paragraph = new DMParagraph();

                for (int i = 0; i < para.Sentences.Count; i++)
                {
                    var text = para.Sentences[i];

                    var sentence = new DMSentence()
                    {
                        Index = index
                    };
                    sentence.Initialize(text);
                    paragraph.Inlines.Add(sentence);
                    paragraph.Inlines.Add(new Run(" "));

                    index += 1;
                }
                doc.Blocks.Add(paragraph);
            }

            doc.Save(localEpisode.SyncDocumentFilePath);
            localEpisode.ReloadSyncDocument();
        }
Example #5
0
        public void TestFetchTrustees()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password   = TestHelperSecure.MyPassword;
            string dst = DMLogin.Dst;

            // we know the trustees of this existing document
            int docNumber = 123456;

            TrusteeInfo[] expected = new TrusteeInfo[] {
                new TrusteeInfo("DOCS_USERS", TrusteeType.Group, AccessRights.ReadOnly),
                new TrusteeInfo("HR_USERS", TrusteeType.Group, AccessRights.NormalAccess),
                new TrusteeInfo("JDOE", TrusteeType.Person, AccessRights.View),
                new TrusteeInfo("NKHORIN", TrusteeType.Person, AccessRights.FullAccess),
            };

            DMDocument doc = new DMDocument()
            {
                Dst = dst, Library = DMLogin.Library
            };
            var actual = doc.FetchTrustees(docNumber);

            Assert.AreEqual(expected.Length, actual.Length);
            foreach (var exp in expected)
            {
                Assert.IsTrue(actual.Contains(exp), "Not found " + exp.Trustee);
            }
        }
        private void InitControl(DMDocument doc, ObservableCollection <LyricsPhrase> phraseCollection)
        {
            this.setDocByLrcUserControl.Document        = doc;
            this.setDocByLrcUserControl.SentencePhrases = phraseCollection;

            this.setDocByLrcUserControl.OnLyricsChanged += SetDocByLrcUserControl_OnLyricsChanged;
        }
Example #7
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="context">WF context</param>
        protected override void Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            var episode = context.GetValue(this.Episode);

            // TODO : Code this activity
            episode.SyncDocument = DMDocument.Load(episode.SyncDocumentFilePath);
        }
Example #8
0
        public void TestUpdateTrustees_RemoveAndAddBack()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password   = TestHelperSecure.MyPassword;
            string dst = DMLogin.Dst;


            // we know the trustees of this existing document
            int                docNumber        = 123457;
            TrusteeInfo        docsUsersInitial = new TrusteeInfo("DOCS_USERS", TrusteeType.Group, AccessRights.ReadOnly);
            TrusteeInfo        docsUsersToSet   = new TrusteeInfo("DOCS_USERS", TrusteeType.Group, AccessRights.NoAccess);
            List <TrusteeInfo> expected         = new List <TrusteeInfo>()
            {
                docsUsersInitial,
                new TrusteeInfo("HR_USERS", TrusteeType.Group, AccessRights.NormalAccess),
                new TrusteeInfo("JDOE", TrusteeType.Person, AccessRights.View),
                new TrusteeInfo("NKHORIN", TrusteeType.Person, AccessRights.FullAccess),
            };

            DMDocument doc = new DMDocument()
            {
                Dst = dst, Library = DMLogin.Library
            };
            var actual = doc.FetchTrustees(docNumber);

            Assert.AreEqual(expected.Count, actual.Length);
            foreach (var exp in expected)
            {
                Assert.IsTrue(actual.Contains(exp), "Not found " + exp.Trustee);
            }

            // Remove DOCS_USERS. We use NoAccess to remove a truestee.
            // This is the way we implemented DMDocument.UpdateTrustees
            doc.UpdateTrustees(docNumber, new TrusteeInfo[] { docsUsersToSet });

            // check
            expected.Remove(docsUsersInitial);
            actual = doc.FetchTrustees(docNumber);
            Assert.AreEqual(expected.Count, actual.Length);
            foreach (var exp in expected)
            {
                Assert.IsTrue(actual.Contains(exp), "Not found " + exp.Trustee);
            }

            // Add DOCS_USERS back
            doc.UpdateTrustees(docNumber, new TrusteeInfo[] { docsUsersInitial });

            // check
            expected.Add(docsUsersInitial);
            actual = doc.FetchTrustees(docNumber);
            Assert.AreEqual(expected.Count, actual.Length);
            foreach (var exp in expected)
            {
                Assert.IsTrue(actual.Contains(exp), "Not found " + exp.Trustee);
            }
        }
Example #9
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="context">WF context</param>
        /// <returns></returns>
        protected override void Execute(NativeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            var lrc      = context.GetValue(this.Lyrics);
            var filePath = context.GetValue(this.DocumentFilePath);
            var doc      = context.GetValue(this.Document);
            var needSave = context.GetValue(this.NeedSaveDocument);
            var needload = context.GetValue(this.NeedLoadDocument);

            // TODO : Code this activity
            if (needload)
            {
                doc = DMDocument.Load(filePath);
            }

            var result = false;

            if (doc == null)
            {
                if (File.Exists(filePath))
                {
                    doc = DMDocument.Load(filePath);

                    if (doc.Sentences.Count() != lrc.Phrases.Count)
                    {
                        result = false;
                    }
                    else
                    {
                        var index = 0;
                        foreach (var sentence in doc.Sentences)
                        {
                            var phrase = lrc.Phrases[index];

                            sentence.BeginTime = phrase.BeginTime;
                            sentence.EndTime   = phrase.EndTime;
                            index += 1;
                        }
                        result = true;
                    }
                }
                else
                {
                    doc = BuildDocument(lrc);
                }
                result = true;
            }
            {
                if (result && needSave)
                {
                    doc.Save(filePath);
                }
            }
            // Return value
            this.Result.Set(context, result);
        }
Example #10
0
 public void NotifyDictation(string dictationFilePath)
 {
     this.ParentWindow.Dispatcher.Invoke(() =>
     {
         if (File.Exists(dictationFilePath) == true)
         {
             this.Dictation = DMDocument.Load(dictationFilePath);
         }
     });
 }
Example #11
0
        static void Main(string[] args)
        {
            string currentFilePath = "";

            args = new string[1] {
                Path.Combine(Environment.CurrentDirectory, "SGTV.wav")
            };
            if (args != null && args.Length > 0)
            {
                var str = args[0];
                Console.WriteLine("Args : " + str);

                var waveFile = str + ".wav";// str.ToLower().Replace(".mp3", ".wav");
                var lrcFile  = str + ".lrc";
                currentFilePath = str + ".xml";
                if (File.Exists(currentFilePath) == true)
                {
                    Console.WriteLine("xml file is E");
                    DMDocument doc = DMDocument.Load(currentFilePath);
                    Lyrics     lrc = new Lyrics();

                    foreach (var sentence in doc.Sentences)
                    {
                        LyricsPhrase phrase = new LyricsPhrase()
                        {
                            BeginTime = sentence.BeginTime,
                            EndTime   = sentence.EndTime,
                            Text      = sentence.Text
                        };
                        lrc.Phrases.Add(phrase);
                    }
                    lrc.Save(lrcFile);
                }
                else
                {
                    WaveDecoder wd = new WaveDecoder();
                    wd.ProcessForRecognize(str, waveFile);

                    DictationSyncEngine engine = new DictationSyncEngine("en-US");

                    engine.SentenceRecognized += engine_SentenceRecognized;
                    engine.RecognizeCompleted += engine_RecognizeCompleted;
                    engine.Process(waveFile);
                }
            }
            else
            {
                Console.WriteLine("Args is null!");
            }
            Console.ReadLine();
        }
Example #12
0
        public void LoadSyncDocument(string filePath)
        {
            this.ParentWindow.Dispatcher.Invoke(() =>
            {
                this.Document = DMDocument.Load(filePath);
                this.DocumentChangedAction(this.Document);

                using (CompositionContainer container = new CompositionContainer())
                {
                    var karaokeService = new KaraokeHighlightService();

                    container.ComposeParts(this.AudioPlayer, this.Document, karaokeService);
                }
            });
        }
Example #13
0
        public void NotifySyncDocument(string documentFilePath)
        {
            this.ParentWindow.Dispatcher.Invoke(() =>
            {
                if (File.Exists(documentFilePath) == true)
                {
                    this.Document = DMDocument.Load(documentFilePath);

                    if (this.DocumentChangedAction != null)
                    {
                        this.DocumentChangedAction(this.Document);
                    }
                }
            });
        }
Example #14
0
        public void TestCreateFolder_LinkToFolder_DeleteFolder()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password   = TestHelperSecure.MyPassword;
            string newDocName = Guid.NewGuid().ToString();
            string dst        = DMLogin.Dst;

            ProfileInfo profile = new ProfileInfo()
            {
                FormName = "STANDARD_P"
            };

            profile.Properties = new Dictionary <string, string>()
            {
                { "DOCNAME", newDocName },
                { "APP_ID", "FOLDER" },
                { "AUTHOR_ID", "JDOE" },
                { "TYPIST_ID", "NKHORIN" }
            };

            DMDocument doc = new DMDocument()
            {
                Dst = dst, Library = DMLogin.Library
            };

            // create
            var docInfo = doc.CreateProfile(profile);

            Assert.IsNotNull(docInfo);
            Assert.IsTrue(docInfo.DocNumber > 0);
            Assert.IsTrue(docInfo.VersionID > 0);

            try {
                // no need to unlock a folder

                // link to an existing folder (we looked up its DOCNUMBER and VERSIONID)
                var parent = new DocumentInfo {
                    DocNumber = 12070617, VersionID = 12681993
                };
                doc.AddLink(docInfo.DocNumber, parent);
            }
            finally {
                // clear links and delete
                doc.DeleteProfile(docInfo.DocNumber, true);
            }
        }
Example #15
0
        public void TestCreateAndDeleteEmptyCustomProfile()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password   = TestHelperSecure.MyPassword;
            string newDocName = Guid.NewGuid().ToString();
            string dst        = DMLogin.Dst;

            ProfileInfo profile = new ProfileInfo()
            {
                FormName = "CUSTOM_PROFILE_FORM"
            };

            profile.Properties = new Dictionary <string, string>()
            {
                { "DOCNAME", newDocName },
                { "APP_ID", "MS WORD" },
                { "AUTHOR_ID", "JDOE" },
                { "TYPIST_ID", "JDOE" },
                { "TYPE_ID", "REPORT" },
                { "CUSTOM_PROP", "NEW VAL" }
            };

            DMDocument doc = new DMDocument()
            {
                Dst = dst, Library = DMLogin.Library
            };

            // create
            var docInfo = doc.CreateProfile(profile);

            Assert.IsNotNull(docInfo);
            Assert.IsTrue(docInfo.DocNumber > 0);
            Assert.IsTrue(docInfo.VersionID > 0);

            // unlock (check-in). We are okay with creating a profile without a document file
            try {
                doc.UnlockDocument(docInfo);
            }
            catch (DMApiEmptyDocumentFileException) {
            }

            // delete
            doc.DeleteProfile(docInfo.DocNumber);
        }
Example #16
0
        public void TestFindLinks()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password   = TestHelperSecure.MyPassword;
            string dst = DMLogin.Dst;

            // we know an existing document-folder link in our library
            int        docNumber    = 12071903;
            string     expectedLink = "799470242";
            DMDocument doc          = new DMDocument()
            {
                Dst = dst, Library = DMLogin.Library
            };
            var res = doc.FindLinks(docNumber);

            Assert.IsNotNull(res);
            Assert.AreEqual(1, res.RowCount);
            Assert.AreEqual(expectedLink, res.Rows[0].Values[0]);
        }
Example #17
0
        private static void AudioFilePath_Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var mw = sender as MainWindow;

            mw.IsEdited = false;
            mw.AudioPlayer.Load(mw.AudioFilePath);

            DMDocument doc = DMDocument.Load(mw.DocumentFilePath);

            mw.Document = doc;
            mw.documentScrollViewer_dictation.Document = doc;

            XContent            content = null;
            TextSentencesLoader loader  = new TextSentencesLoader(mw.TxtFilePath);

            if (File.Exists(mw.SubtitleFilePath) == false)
            {
                content = new XContent();
                foreach (var kvp in loader.Sentences)
                {
                    content.Root.Add(new XSentence(kvp.Key, kvp.Value));
                }
            }
            else
            {
                content = new XContent(mw.SubtitleFilePath);

                //int i = 0;
                //foreach (var sentence in content.Sentences)
                //{
                //    var kv = loader.Sentences[i];

                //    sentence.Translation = kv.Value;

                //    i += 1;
                //}

                //content.Save(mw.SubtitleFilePath);
            }
            mw.ContentDocument = content;
        }
Example #18
0
        public void TestCreateAndDeleteFolder()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password   = TestHelperSecure.MyPassword;
            string newDocName = Guid.NewGuid().ToString();
            string dst        = DMLogin.Dst;

            ProfileInfo profile = new ProfileInfo()
            {
                FormName = "STANDARD_P"
            };

            profile.Properties = new Dictionary <string, string>()
            {
                { "DOCNAME", newDocName },
                { "APP_ID", "FOLDER" },
                { "AUTHOR_ID", "JDOE" },
                { "TYPIST_ID", "JDOE" }
            };
            profile.Trustees = new List <TrusteeInfo>()
            {
                new TrusteeInfo("DOCS_USERS", TrusteeType.Group, AccessRights.ReadOnly)
            };

            DMDocument doc = new DMDocument()
            {
                Dst = dst, Library = DMLogin.Library
            };

            // create
            var docInfo = doc.CreateProfile(profile);

            Assert.IsNotNull(docInfo);
            Assert.IsTrue(docInfo.DocNumber > 0);
            Assert.IsTrue(docInfo.VersionID > 0);

            // no need to unlock a folder

            // delete
            doc.DeleteProfile(docInfo.DocNumber);
        }
Example #19
0
        public void TestCreateAndDeleteDocument()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password   = TestHelperSecure.MyPassword;
            string dst        = DMLogin.Dst;
            string newDocName = Guid.NewGuid().ToString();

            ProfileInfo profile = new ProfileInfo()
            {
                FormName = "STANDARD_P"
            };

            profile.Properties = new Dictionary <string, string>()
            {
                { "DOCNAME", newDocName },
                { "APP_ID", "NOTEPAD" },
                { "AUTHOR_ID", "JDOE" },
                { "TYPIST_ID", "JDOE" }
            };
            DMDocument doc = new DMDocument()
            {
                Dst = dst, Library = DMLogin.Library
            };

            string fileName = Path.GetTempFileName();

            File.WriteAllText(fileName, "hello world!\r\n");
            try {
                var docInfo = doc.CreateDocument(profile, fileName);
                Assert.IsNotNull(docInfo);
                Assert.IsTrue(docInfo.DocNumber > 0);
                Assert.IsTrue(docInfo.VersionID > 0);
                //TODO download content and check

                doc.DeleteProfile(docInfo.DocNumber);
            }
            finally {
                File.Delete(fileName);
            }
        }
Example #20
0
        private static DMDocument BuildDocument(Core.Lyrics lrc)
        {
            var doc   = new DMDocument();
            var para  = new DMParagraph();
            var index = 0;

            foreach (var phrase in lrc.Phrases)
            {
                var sentence = new DMSentence(index)
                {
                    BeginTime = phrase.BeginTime,
                    EndTime   = phrase.EndTime,
                };
                sentence.Initialize(lrc.Transcript);

                para.Inlines.Add(sentence);

                index += 1;
            }
            doc.Blocks.Add(para);
            return(doc);
        }
 private void btn_AutoFind_Click(object sender, RoutedEventArgs e)
 {
     if (this.TimeLineSelector.CanSelectByTranscript == true)
     {
         this.TimeLineSelector.SelectByTranscript(this.Sentence.ToString());
     }
     else
     {
         DMDocument doc = this.Sentence.Paragraph.Parent as DMDocument;
         var        tmp = 0;
         var        all = 0;
         foreach (var sentence in doc.Sentences)
         {
             var length = sentence.ToString().Length;
             if (sentence != this.Sentence)
             {
                 tmp += length;
             }
             all += length;
         }
         this.TimeLineSelector.SelectByCharIndex(tmp + 1, tmp + 1 + this.Sentence.ToString().Length, all);
     }
 }
Example #22
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="context">WF context</param>
        protected override void Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            var sentences    = context.GetValue(this.RefSentences);
            var localEpisode = context.GetValue(this.LocalEpisode);

            // TODO : Code this activity
            var dmDoc = DMDocument.Load(localEpisode.SyncDocumentFilePath);

            foreach (var refSentence in sentences)
            {
                var dmSentence = dmDoc.Sentences.Single((sentence) => {
                    return(sentence.Index == refSentence.Index ? true : false);
                });

                dmSentence.BeginTime = refSentence.Begin;
                dmSentence.EndTime   = refSentence.End;
            }

            dmDoc.Save(localEpisode.SyncDocumentFilePath);

            localEpisode.ReloadSyncDocument();
        }
Example #23
0
 public SetDocumentByLyricsUserControl(DMDocument doc, ObservableCollection <LyricsPhrase> phrases)
     : this()
 {
     this.Document        = doc;
     this.SentencePhrases = phrases;
 }
Example #24
0
 public void ReloadDictationDocument()
 {
     this._dictationDocument = null;
     var diction = this.DictationDocument;
 }
Example #25
0
 public void ReloadSyncDocument()
 {
     this._syncDocument = null;
     var syncDoc = this.SyncDocument;
 }
Example #26
0
 public void NotifyRecognizeProgress(DMDocument episodeDocument)
 {
 }