/* Split the video, audio and JSON data for this meeting into smaller * segments. This allows multiple people to work on the fixes to * the text at the same time. */ public void Split(string meetingFolder, string videofile, string fixasrFile, int segmentSize, int segmentOverlap) { string splitFolder = meetingFolder + "\\" + "FixText"; // The processed recording will next go through the following workflow: // 1. Users will fix errors in the text generated by auto voice recognition. // 2. Users will add metadata tags to the transcript. // To facilitate this, we will split the video, audio and transcript files into smaller segments. // This has the advantages that: // 1. More than one volunteer can work on the recording at the same time. // 2. Less video or audio data needs to be downloaded to the user at one time. string stringValue = File.ReadAllText(fixasrFile); FixasrView fixasr = JsonConvert.DeserializeObject <FixasrView>(stringValue); // Split the recording into parts and put them each in subfolders of subfolder "parts". SplitRecording splitRecording = new SplitRecording(); int parts = splitRecording.Split(videofile, splitFolder, segmentSize, segmentOverlap); // Also extract the audio from each of these segments. // Some user may prefer to work with the audio for fixing the transcript. // We will put the audio files in the same folder as the video. ExtractAudio extract = new ExtractAudio(); extract.ExtractAll(splitFolder); // Split the full transcript into segments that match the audio and video segments in size. SplitTranscript splitTranscript = new SplitTranscript(); splitTranscript.split(fixasr, splitFolder, segmentSize, segmentOverlap, parts); }
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); }