示例#1
0
        public bool IsValidTranscript(TranscriptInputDto inputDto)
        {
            if (string.IsNullOrEmpty(inputDto.Input))
            {
                _logger.LogError("Input is empty");
                return(false);
            }

            string[] inputLines = inputDto.Input.Split('\n');
            return(inputLines[0].StartsWith("1") == true && inputLines[1].StartsWith("00:") == true);
        }
示例#2
0
        public ActionResult <TranscriptOutputDto> CleanTranscript(TranscriptInputDto inputDto)
        {
            if (_transcriptService.IsValidTranscript(inputDto) == false)
            {
                string invalidMsg = "Input is not in a valid format";
                _logger.LogError(invalidMsg);
                return(BadRequest(invalidMsg));
            }

            return(_transcriptService.CleanTranscript(inputDto));
        }
示例#3
0
        public TranscriptOutputDto CleanTranscript(TranscriptInputDto inputDto)
        {
            string[] inputLines  = inputDto.Input.Split('\n');
            int      counter     = 0;
            string   videoString = string.Empty;
            string   blogString  = string.Empty;

            foreach (var line in inputLines)
            {
                counter = counter >= 4 ? 1 : counter + 1;

                string cleanedLine = line
                                     .ToUpper()
                                     .Replace("UM", string.Empty)
                                     .Replace("UH", string.Empty)
                                     .Replace("[MUSIC] YOU", "[MUSIC]")
                                     .Replace("  ", " ")
                                     .Replace("ALL RIGHT", "ALRIGHT")
                                     .Trim();

                videoString += cleanedLine + Formatting.NewLine;

                if (counter == 3)
                {
                    blogString += cleanedLine + Formatting.NewLine;
                }
            }

            blogString = RemoveDupesFromBlogString(blogString);
            blogString = CleanBlogString(blogString);

            TranscriptOutputDto outputDto = new();

            outputDto.VideoTitle = inputDto.VideoTitle.Replace(FileExtension.Srt, string.Empty);
            outputDto.VideoText  = videoString;
            outputDto.BlogText   = blogString;
            outputDto.BlogWords  = blogString.Split(' ').Length;

            _logger.LogInformation("Transcript processed successfully");

            _textFileService.SaveFileContents(
                $"{Transcript.OutputDirectory}/{outputDto.VideoTitle}.srt",
                outputDto.VideoText);

            _textFileService.SaveFileContents(
                $"{Transcript.OutputDirectory}/{outputDto.VideoTitle}.md",
                outputDto.BlogText);

            return(outputDto);
        }