Esempio n. 1
0
        static void TranscribeVideo(
            SampleVideo sample,              // sample video to use
            string fixedTags,                // file in which to save the fixed transcription
            string audio,                    // file in which to save the extracted audio
            bool useSmallSample,             // if true, use a small sample of the video/audio
            bool useAudioFileAlreadyInCloud, // if true, use prior audio in cloud if it exists
            string rawTranscription)         // file in which to save the raw transcription
        {
            string videofilePath                   = sample.filepath;
            string objectName                      = sample.objectname;
            RepeatedField <string> phrases         = sample.phrases;
            AudioProcessing        audioProcessing = new AudioProcessing();

            string googleCloudBucketName = "govmeeting-transcribe";

            TranscribeParameters transParams = new TranscribeParameters
            {
                audiofilePath              = audio,
                objectName                 = objectName,
                GoogleCloudBucketName      = googleCloudBucketName,
                useAudioFileAlreadyInCloud = useAudioFileAlreadyInCloud,
                language        = "en",
                MinSpeakerCount = 2,
                MaxSpeakerCount = 6,
                phrases         = phrases
            };

            // Clean up from last run
            File.Delete(audio);
            File.Delete(fixedTags);

            if (useSmallSample)
            {
                string shortVideoFile = videofilePath.Replace(".mp4", "-3min.mp4");
                //SplitRecording splitRecording = new SplitRecording();
                audioProcessing.ExtractPart(videofilePath, shortVideoFile, 60, 3 * 60);
                videofilePath = shortVideoFile;
            }

            audioProcessing.Extract(videofilePath, audio);

            GMFileAccess.SetGoogleCredentialsEnvironmentVariable();

            // Transcribe the audio file
            TranscribeAudio transcribe     = new TranscribeAudio();
            Transcribed_Dto response       = transcribe.TranscribeAudioFile(transParams, rawTranscription);
            string          responseString = JsonConvert.SerializeObject(response, Formatting.Indented);

            File.WriteAllText(fixedTags, responseString);

            WriteCopyOfResponse(responseString, fixedTags);
        }
Esempio n. 2
0
        static void Main()
        {
            SampleVideos samples = new SampleVideos();

            string FlacAudio      = AddPath("1_Audio.flac");   // step 1 flac audio file
            string RawTrans       = AddPath("2_Trans.json");   // step 2 raw transcription
            string Simplified     = AddPath("3_Simpify.json"); // step 3 simplified transcription
            string FixedTags      = AddPath("4_Fix.json");     // step 4 SpeakerTags added
            string EditMeetingDto = AddPath("5_Dto.json");     // step 5 EditMeetingDto

            JobType     JOB_TO_DO        = JobType.Dto;
            SampleVideo SAMPLE_TO_USE    = samples.LittleFallsVideo;
            bool        USE_SMALL_SAMPLE = false; // if true, use a small sample of video - 3 minutes
            bool        USE_CLOUD_FILE   = true;  // if true, use prior audio file in cloud if it exists

            switch (JOB_TO_DO)
            {
            case JobType.TransSimpFixDto:
                // do steps 1, 2, 3, 4 & 5
                TranscribeVideo(SAMPLE_TO_USE, FixedTags, FlacAudio, USE_SMALL_SAMPLE, USE_CLOUD_FILE, RawTrans);
                CreateEditTranscriptView(FixedTags, EditMeetingDto);
                break;

            case JobType.TransSimpFix:
                // do steps 1, 2, 3 & 4
                TranscribeVideo(SAMPLE_TO_USE, FixedTags, FlacAudio, USE_SMALL_SAMPLE, USE_CLOUD_FILE, RawTrans);
                break;

            case JobType.Simp:
                // Simplify the raw transcription
                SimplifyRaw(RawTrans, Simplified);
                break;

            case JobType.Fix:
                // Fix the simplified file by adding the speaker tags
                FixSpeakerTags(Simplified, FixedTags);
                break;

            case JobType.Dto:
                // Convert Fixed to the MeetingEditDto
                CreateEditTranscriptView(FixedTags, EditMeetingDto);
                break;
            }
        }