public void Process(string videoFile, string meetingFolder, string language) { /////// Copy video to meeting folder ///////// AudioProcessing audioProcessing = new AudioProcessing(); string videofileCopy = Path.Combine(meetingFolder, "video.mp4"); // #### If MaxRecordingSize is not zero, we shorted the recording. #### if (config.MaxRecordingSize == 0) { File.Copy(videoFile, videofileCopy); } else { audioProcessing.ExtractPart(videoFile, videofileCopy, 0, config.MaxRecordingSize); } /////// Extract the audio. //////////////////////// ExtractAudio extract = new ExtractAudio(); string audioFile = Path.Combine(meetingFolder, "audio.flac"); audioProcessing.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"; TranscribeParameters transParams = new TranscribeParameters { audiofilePath = audioFile, objectName = objectName, GoogleCloudBucketName = config.GoogleCloudBucketName, useAudioFileAlreadyInCloud = config.UseAudioFileAlreadyInCloud, language = language, MinSpeakerCount = 2, MaxSpeakerCount = 6 // TODO Add "phrases" field: names of officers }; Transcribed_Dto transcript = transcribeAudio.TranscribeAudioFile(transParams); string stringValue = JsonConvert.SerializeObject(transcript, Formatting.Indented); string outputJsonFile = Path.Combine(meetingFolder, "transcribed.json"); File.WriteAllText(outputJsonFile, stringValue); }
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); }