Exemple #1
0
        public static void TranscriptTranslation()
        {
            //Console.WriteLine("Hello World!");
            var pathToVideo = @"C:\Users\v-isbojo\Pictures\OtherLangVideo\aa.mp4";

            var video = Video.ImportVideo(pathToVideo);

            var audio          = ffmpeg.ExtractAudio(video);
            var secretProvider = new SecretProvider(translationkeySecretIdentifier, subscriptionKeySecretIdentifier, applicationId);

            Transcript transcript = new Transcript(secretProvider, audio, Transcript.Language.EnglishUS);

            Translation translate = new Translation(secretProvider, transcript);

            Console.WriteLine("Press any key to continue.");
            Console.ReadKey();
        }
Exemple #2
0
        public Translation(SecretProvider secretProvider, Transcript transcript, Language[] languages = default(Language[]))
        {
            if (languages == default(Language[]))
            {
                listOfLanguages = new Language[] { Language.German, Language.Italian, Language.SerbianLatin };
            }
            else
            {
                listOfLanguages = languages;
            }

            textToBeTranslated = transcript.TranscriptBulkText.Value;

            try
            {
                TranslateTextRequest(secretProvider, listOfLanguages).Wait();
            }
            catch (Exception ex)
            {
                _ = ex;
            }
        }
Exemple #3
0
        public static void TestingTranscript()
        {
            var secretProvider = new SecretProvider(translationkeySecretIdentifier, subscriptionKeySecretIdentifier, applicationId);

            //write value
            // Write the string array to a new file named "WriteLines.txt".
            using (StreamWriter outputFile = new StreamWriter(Path.Combine("E:\\diplomskiTesting", "HeyHeyHeyIspravljeno.txt")))
            {
                string[] foldersInDirectory = Directory.GetDirectories("E:\\diplomskiTesting");
                float    wordErrorRateSum   = 0;
                int      testCount          = 0;
                foreach (var folder in foldersInDirectory)
                {
                    string[] subfoldersInDirectory = Directory.GetDirectories(folder);
                    string   testFile = "";
                    foreach (var subFolder in subfoldersInDirectory)
                    {
                        var allFiles = Directory.GetFiles(subFolder);

                        Parallel.ForEach(allFiles, (file) =>
                        {
                            if (file.EndsWith(".mp4"))
                            {
                                try
                                {
                                    var video = Video.ImportVideo(file);

                                    var audio = ffmpeg.ExtractAudio(video);

                                    Transcript transcript = new Transcript(secretProvider, audio, Path.GetFileName(folder));

                                    testFile          = allFiles.Where((f) => f.Contains(Path.GetFileNameWithoutExtension(file))).Where(x => x.EndsWith(".vtt")).FirstOrDefault();
                                    var wer           = WordErrorRate(testFile, transcript.TranscriptBulkText.Value);
                                    wordErrorRateSum += wer;
                                    outputFile.WriteLine("WER for file " + file + " " + wer);
                                    testCount++;
                                    Console.WriteLine("Press any key to continue.");
                                    //Console.ReadKey();
                                }
                                catch (Exception ex)
                                {
                                    outputFile.WriteLine("Skipping " + file);
                                    Console.WriteLine("Skipping " + file);
                                }
                            }
                        });
                        //foreach (var file in allFiles)
                        //{
                        //}
                    }

                    outputFile.WriteLine(Path.GetFileName(folder));
                    outputFile.WriteLine(wordErrorRateSum);
                    outputFile.WriteLine(testCount);
                    outputFile.WriteLine(wordErrorRateSum / testCount);
                }
                outputFile.WriteLine("KRAJ");
                outputFile.WriteLine(wordErrorRateSum);
                outputFile.WriteLine(testCount);
                outputFile.WriteLine(wordErrorRateSum / testCount);
            }
        }