From c0ed5acc33679b08815ae5a1118fa91858a51bc1 Mon Sep 17 00:00:00 2001 From: niksedk Date: Fri, 12 Apr 2024 08:46:29 +0200 Subject: [PATCH] Work on tts --- src/libse/TextToSpeech/PiperModels.cs | 3 +-- src/ui/Forms/Main.cs | 6 ++++++ src/ui/Forms/Tts/TextToSpeech.cs | 2 +- src/ui/Logic/VideoPreviewGenerator.cs | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libse/TextToSpeech/PiperModels.cs b/src/libse/TextToSpeech/PiperModels.cs index abbc16278..bb8b5786a 100644 --- a/src/libse/TextToSpeech/PiperModels.cs +++ b/src/libse/TextToSpeech/PiperModels.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace Nikse.SubtitleEdit.Core.TextToSpeech diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index 9b76f584f..f1f9d51ab 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -19032,6 +19032,12 @@ namespace Nikse.SubtitleEdit.Forms TaskDelayHelper.RunDelayed(TimeSpan.FromMilliseconds(25), () => { + if (string.IsNullOrEmpty(_videoFileName) || _videoInfo == null) + { + MessageBox.Show(LanguageSettings.Current.General.NoVideoLoaded); + return; + } + if (RequireFfmpegOk()) { using (var form = new TextToSpeech(_subtitle, GetCurrentSubtitleFormat(), _videoFileName, _videoInfo)) diff --git a/src/ui/Forms/Tts/TextToSpeech.cs b/src/ui/Forms/Tts/TextToSpeech.cs index ef5fb056c..df75cf272 100644 --- a/src/ui/Forms/Tts/TextToSpeech.cs +++ b/src/ui/Forms/Tts/TextToSpeech.cs @@ -182,7 +182,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts var next = _subtitle.GetParagraphOrDefault(index + 1); var pFileName = Path.Combine(_waveFolder, index + ".wav"); - //TODO: analyse audio and remove silence at start and end (ffmpeg -af silenceremove=1:0:-50dB:1:1:-50dB) + //TODO: analyse audio and remove silence at start and end (ffmpeg -af silenceremove=1:0:-5dB:1:1:-5dB) var outputFileName1 = Path.Combine(_waveFolder, index + "_u.wav"); var trimProcess = VideoPreviewGenerator.TrimSilenceStartAndEnd(pFileName, outputFileName1); trimProcess.Start(); diff --git a/src/ui/Logic/VideoPreviewGenerator.cs b/src/ui/Logic/VideoPreviewGenerator.cs index e37182503..369357014 100644 --- a/src/ui/Logic/VideoPreviewGenerator.cs +++ b/src/ui/Logic/VideoPreviewGenerator.cs @@ -612,7 +612,7 @@ namespace Nikse.SubtitleEdit.Logic StartInfo = { FileName = GetFfmpegLocation(), - Arguments = $"-i \"{inputFileName}\" -af silenceremove=start_periods=1:start_silence=0.01,areverse,silenceremove=start_periods=1:start_silence=0.01,areverse \"{outputFileName}\"", + Arguments = $"-i \"{inputFileName}\" -af \"areverse,atrim=start=0.2,silenceremove=start_periods=1:start_silence=0.1:start_threshold=0.01,areverse,atrim=start=0,silenceremove=start_periods=1:start_silence=0.1:start_threshold=0.01\" \"{outputFileName}\"", UseShellExecute = false, CreateNoWindow = true }