Example #1
0
        public static List <Transcription> GetTranscriptions(String videoId)
        {
            String subtitleLink = GetTranscriptionLink(videoId);

            XmlDocument doc = new XmlDocument();

            doc.Load(subtitleLink);
            XmlNode root = doc.ChildNodes[1];

            List <Transcription> transcriptions = new List <Transcription>();

            if (root.HasChildNodes)
            {
                for (int i = 0; i < root.ChildNodes.Count; i++)
                {
                    String phrase = root.ChildNodes[i].InnerText;
                    phrase = HttpUtility.HtmlDecode(phrase);
                    Transcription transcription = new Transcription
                    {
                        StartTime = (int)Convert.ToDouble(root.ChildNodes[i].Attributes["start"].Value),
                        Phrase    = phrase
                    };
                    transcription.Add(transcription);
                }
            }
            return(transcriptions);
        }
Example #2
0
 public static bool Import(Stream input, Transcription storage)
 {
     if (input is FileStream)
     {
         storage.Add(new TranscriptionParagraph());
         storage.MediaURI = ((FileStream)input).Name;
         return true;
     }
     return false;
 }
Example #3
0
        private void CNewSection(object sender, ExecutedRoutedEventArgs e)
        {
            TranscriptionSection   s = new TranscriptionSection(Properties.Strings.DefaultSectionText);
            TranscriptionParagraph p = new TranscriptionParagraph();

            p.Add(new TranscriptionPhrase());
            Transcription.Add(s);
            s.Add(p);
            VirtualizingListBox.ActiveTransctiption = s;
        }
Example #4
0
 public static bool Import(Stream input, Transcription storage)
 {
     if (input is FileStream)
     {
         storage.Add(new TranscriptionParagraph());
         storage.MediaURI = ((FileStream)input).Name;
         return(true);
     }
     return(false);
 }
Example #5
0
        public static bool Import(Stream input, Transcription storage)
        {
            var groups = ReadLines(input).SplitLines(x => x == "");

            //group[0] .. line index
            //group[1] .. time --> time SomeCustomStuff...
            //group[2...] .. string

            //group[lenght-1] .. empty line ignored


            var paragraphs = groups.Where(g => g.Length > 0).Select(g =>
            {
                TranscriptionPhrase p = new TranscriptionPhrase();
                var time = g[1].Split(' ');
                p.Begin  = TimeSpan.Parse(time[0], FRculture);
                // -->
                p.End = TimeSpan.Parse(time[2], FRculture);

                if (time.Length > 3)     //some position data
                {
                    p.Phonetics = string.Join(" ", time.Skip(3));
                }

                p.Text = string.Join("\r\n", g.Skip(2));

                return(new TranscriptionParagraph(p));
            });

            foreach (var p in paragraphs)
            {
                storage.Add(p);
            }

            return(true);
        }
Example #6
0
        public static bool Import(Stream input, Transcription storage)
        {
            XDocument doc  = XDocument.Load(input);
            var       root = doc.Element("NanovoidSegmentation");

            var mediums = root.Elements("Medium").ToArray();

            XElement medium = null;

            if (mediums.Length > 1)
            {
                SelectFile sf = new SelectFile(mediums.Select(m => m.Attribute("url") != null ? Path.GetFileName(m.Attribute("url").Value) : "name not specified").ToList());
                sf.Title = "Select Medium";
                if (sf.ShowDialog() == true)
                {
                    medium = mediums[sf.SelectedIndex];
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                medium = mediums.First();
            }

            var segmentations = medium.Elements("Segmentation").ToArray();

            XElement segmentation = null;

            if (segmentations.Length > 1)
            {
                var        lst = segmentations.Select(s => string.Join(" ", s.Attributes().Select(a => a.Name + ":" + a.Value))).ToList();
                SelectFile sf  = new SelectFile(lst);
                sf.Title = "Select segmentation";
                if (sf.ShowDialog() == true)
                {
                    segmentation = segmentations[sf.SelectedIndex];
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                segmentation = segmentations.First();
            }

            TimeSpan unitlen = new TimeSpan((long)(TimeSpan.FromSeconds(1).Ticks *XmlConvert.ToDouble(segmentation.Attribute("tres").Value)));
            //segmentations.Elements("Segment");

            Transcription        tr = storage;
            TranscriptionChapter ch = new TranscriptionChapter();

            ch.Text = segmentation.Attribute("type").Value;

            TranscriptionSection sec = new TranscriptionSection();

            sec.Text = segmentation.Attribute("label").Value;

            tr.MediaURI = medium.Attribute("url") != null?medium.Attribute("url").Value : "";

            var idss = segmentation.Element("Identities");

            if (idss != null)
            {
                var ids = idss.Elements("Id");
                if (ids != null && ids.Count() > 0)
                {
                    var speakers = ids.Select(i => new Speaker()
                    {
                        ID = XmlConvert.ToInt32(i.Attribute("id").Value), Surname = i.Attribute("label").Value
                    });
                    tr.Speakers = new SpeakerCollection(speakers);
                }
            }

            var segments = segmentation.Element("Segments").Elements("Segment");

            var paragraphs = MakeParagraphs(segments, unitlen);

            foreach (var p in paragraphs)
            {
                sec.Add(p);
            }

            ch.Add(sec);
            tr.Add(ch);


            tr.AssingSpeakersByID(); //added in newer version



            return(true);
        }