public void TestMoveToCloudAndTranscribe(string language)
        {
            string baseName     = "USA_ME_LincolnCounty_BoothbayHarbor_Selectmen_EN_2017-02-15";
            string videoFile    = _config.TestfilesPath + "\\" + baseName + ".mp4";
            string outputFolder = _config.TestfilesPath + "\\" + "TestMoveToCloudAndTranscribe";

            FileDataRepositories.GMFileAccess.DeleteAndCreateDirectory(outputFolder);

            string outputBasePath = outputFolder + "\\" + baseName;
            string shortFile      = outputBasePath + ".mp4";
            string audioFile      = outputBasePath + ".flac";
            string jsonFile       = outputBasePath + ".json";


            // Extract short version
            SplitRecording splitRecording = new SplitRecording();

            splitRecording.ExtractPart(videoFile, shortFile, 60, 4 * 60);

            // Extract audio.
            ExtractAudio extract = new ExtractAudio();

            extract.Extract(shortFile, audioFile);

            // Transcribe
            //TranscribeAudio ta = new TranscribeAudio(_config);
            TranscribeResponse response = transcribe.MoveToCloudAndTranscribe(audioFile, baseName + ".flac", language);

            string stringValue = JsonConvert.SerializeObject(response, Formatting.Indented);

            File.WriteAllText(outputBasePath + "-rsp.json", stringValue);

            // Modify Transcript json format
            ModifyTranscriptJson mt     = new ModifyTranscriptJson();
            FixasrView           fixasr = mt.Modify(response);

            // Create JSON file
            stringValue = JsonConvert.SerializeObject(fixasr, Formatting.Indented);
            File.WriteAllText(jsonFile, stringValue);
        }
Esempio n. 2
0
        public void Process(string videoFile, string meetingFolder, string language)
        {
            /////// Copy video to meeting folder  /////////

            FileInfo infile        = new FileInfo(videoFile);
            string   videofileCopy = meetingFolder + "\\" + "01-Video.mp4";

            if (!config.IsDevelopment)
            {
                File.Copy(videoFile, videofileCopy);
            }
            else
            {
                // #### FOR DEVELOPMENT: WE SHORTEN THE RECORDING FILE. ####
                SplitRecording splitRecording = new SplitRecording();
                splitRecording.ExtractPart(videoFile, videofileCopy, 0, config.RecordingSizeForDevelopment);
            }

            /////// Extract the audio. ////////////////////////

            ExtractAudio extract   = new ExtractAudio();
            string       audioFile = meetingFolder + "\\" + "02-Audio.flac";

            extract.Extract(videofileCopy, audioFile);

            /////// Transcribe the audio file. /////////////

            // We want the object name in the cloud to be the original video file name with ".flac" extension.
            string objectName = Path.GetFileNameWithoutExtension(videoFile) + ".flac";

            TranscribeResponse transcript;

            //if (!config.UseAudioFileAlreadyInCloud)
            //{

            // Move audio file to cloud and transcribe
            transcript = transcribeAudio.MoveToCloudAndTranscribe(audioFile, objectName, language);

            //} else
            //{
            //    // For development and it's already in cloud
            //    // TODO - check if it is already in cloud
            //    transcript = transcribeAudio.TranscribeInCloud(objectName, language);
            //}

            string stringValue    = JsonConvert.SerializeObject(transcript, Formatting.Indented);
            string outputJsonFile = meetingFolder + "\\" + "03-Transcribed.json";

            File.WriteAllText(outputJsonFile, stringValue);

            /////// Reformat the JSON transcript to match what the fixasr routine will use.

            ModifyTranscriptJson convert = new ModifyTranscriptJson();

            outputJsonFile = meetingFolder + "\\" + "04-ToFix.json";
            FixasrView fixasr = convert.Modify(transcript);

            stringValue = JsonConvert.SerializeObject(fixasr, Formatting.Indented);
            File.WriteAllText(outputJsonFile, stringValue);

            /////// Split the video, audio and transcript into multiple work segments

            //SplitIntoWorkSegments split = new SplitIntoWorkSegments();
            //split.Split(meetingFolder, videofileCopy, outputJsonFile, config.FixasrSegmentSize,
            //    config.FixasrSegmentOverlap);
        }