Is it possible to replicate vegasaur's silence detection script ?

andy-0 wrote on 9/29/2023, 6:12 PM

Hello everyone! I have a question regarding Vegas Pro 17, particularly regarding an extension called Vegasaur. My question is as follows: Is there a way to access the scripts and programs used by Vegasaur independently, without needing to install the extension, and most importantly, without having to spend the $100 it costs? In my local currency, this amount is quite high, so I'm looking for alternatives to access Vegasaur's features for free, such as silence detection, marker placement, and segment deletion, similar to what the extension offers. Does anyone know how this can be achieved?

Comments

Robert Johnston wrote on 9/29/2023, 10:41 PM

@jetdv @andy-0 JetDV may have a script for removing silent parts of audio.

Intel Core i7 10700K CPU @ 3.80GHz (to 4.65GHz), NVIDIA GeForce RTX 2060 SUPER 8GBytes. Memory 32 GBytes DDR4. Also Intel UHD Graphics 630. Mainboard: Dell Inc. PCI-Express 3.0 (8.0 GT/s) Comet Lake. Bench CPU Multi Thread: 5500.5 per CPU-Z.

Vegas Pro 21.0 (Build 108) with Mocha Vegas

Windows 11 not pro

Robert Johnston wrote on 9/29/2023, 10:52 PM

@andy-0 And here it is: https://www.jetdv.com/2023/02/06/remove-silent-areas-from-an-audio-track-in-vegas-part-6/

 

Intel Core i7 10700K CPU @ 3.80GHz (to 4.65GHz), NVIDIA GeForce RTX 2060 SUPER 8GBytes. Memory 32 GBytes DDR4. Also Intel UHD Graphics 630. Mainboard: Dell Inc. PCI-Express 3.0 (8.0 GT/s) Comet Lake. Bench CPU Multi Thread: 5500.5 per CPU-Z.

Vegas Pro 21.0 (Build 108) with Mocha Vegas

Windows 11 not pro

Former user wrote on 9/29/2023, 11:15 PM

That works reasonably well, problem I am noticing is that it cuts before a person has finished speaking like on the last syllable . Maybe that value can be adjusted within the script to increase the delay

Robert Johnston wrote on 9/30/2023, 5:02 AM

@Former user @andy-0 There are some parameters near the beginning of the script you can adjust, I noticed. You'll have to experiment with the variables or watch the tutorials to know what they do.


        double QuietLimit = -40.0;
        Timecode logOffset = Timecode.FromFrames(10);
        Timecode minLength = Timecode.FromSeconds(1.500);

       

Intel Core i7 10700K CPU @ 3.80GHz (to 4.65GHz), NVIDIA GeForce RTX 2060 SUPER 8GBytes. Memory 32 GBytes DDR4. Also Intel UHD Graphics 630. Mainboard: Dell Inc. PCI-Express 3.0 (8.0 GT/s) Comet Lake. Bench CPU Multi Thread: 5500.5 per CPU-Z.

Vegas Pro 21.0 (Build 108) with Mocha Vegas

Windows 11 not pro

jetdv wrote on 10/2/2023, 8:40 AM

@Phil_P I got a notification about a message from you in this post but I don't see the question.

Phil_P wrote on 10/2/2023, 9:16 AM

@Phil_P I got a notification about a message from you in this post but I don't see the question.

Hi there, I removed it as it was not relevant. I looked in detail at the tutorial to see why mp3 was being used, as I initially mistakenly thought that the files were being rendered as mp3, (I didn't realise that this was just to get the loudness info).

Now that you are here, please allow me to say thank you, great script, and very ingenious.

jetdv wrote on 10/2/2023, 11:49 AM

Yes, it was just to get the text file. Then the script deleted the mp3 file. Any format could have been used.

andy-0 wrote on 6/11/2024, 3:09 PM

That works reasonably well, problem I am noticing is that it cuts before a person has finished speaking like on the last syllable . Maybe that value can be adjusted within the script to increase the delay

Does the script work correctly for you? I've tried to adjust the dbs level several times but it always deletes the entire event

RedRob-CandlelightProdctns wrote on 6/13/2024, 9:07 PM

Whether it's $59 or $99 -- it is 1000% worth it.

I just was telling my beloved that I would happily send them $$ as a Holiday gift just to say THANK YOU over and over. Their toolset saves me hours of time on some projects, over and over -- and are so darned flexible and powerful! JetDB's Excaliber was similarly a lifesaver for our multi-cam work in earlier versions of Vegas... great stuff!

Vegas 21.300

My PC (for finishing):

Cyperpower PC Intel Core i7-7700K CPU @ 4.2GHz, 64GB mem @ 2133MHz RAM, AMD Radeon RX470 (4GB dedicated) with driver recommended by Vegas Updater (reports as 30.0.15021.11005 dated 4/28/22), and Intel HD Graphics 630 driver version 31.0.101.2112 dated 7/21/22 w/16GB shared memory. Windows 10 Pro 64bit version 10.0.19045 Build 19045.

My main editing laptop:

Dell G15 Special Edition 5521, Bios 1.12 9/13/22, Windows 11 22H2 (10.0.22621)

12th Gen Intel Core i7-12700H (14 cores, 20 logical processors), 32 GB DDR5 4800MHz RAM, Intel Iris Xe Graphics, NVIDIA GeForce RTX 3070 Ti Laptop GPU w/8GB GDDR6 RAM, Realtek Audio

 

 

Robert Johnston wrote on 6/13/2024, 10:48 PM

@andy-0 The script works correctly for me. The script reads the Momentary Loudness column in the log file. What are you entering for decibels? Hopefully it has a minus sign in front of it, like -23, otherwise it will most likely wipe out the entire event if it is positive or zero. Also, what do you have the track volume set to? That affects momentary loudness.

Intel Core i7 10700K CPU @ 3.80GHz (to 4.65GHz), NVIDIA GeForce RTX 2060 SUPER 8GBytes. Memory 32 GBytes DDR4. Also Intel UHD Graphics 630. Mainboard: Dell Inc. PCI-Express 3.0 (8.0 GT/s) Comet Lake. Bench CPU Multi Thread: 5500.5 per CPU-Z.

Vegas Pro 21.0 (Build 108) with Mocha Vegas

Windows 11 not pro

andy-0 wrote on 6/13/2024, 11:49 PM

@andy-0 The script works correctly for me. The script reads the Momentary Loudness column in the log file. What are you entering for decibels? Hopefully it has a minus sign in front of it, like -23, otherwise it will most likely wipe out the entire event if it is positive or zero. Also, what do you have the track volume set to? That affects momentary loudness.

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;
        Renderer myRenderer = null;
        RenderTemplate rndrTemplate = null;
        double QuietLimit = -35.0;
        Timecode logOffset = Timecode.FromFrames(10);
        Timecode minLength = Timecode.FromSeconds(1.5);
        bool[,] trackStatus = new bool[1000, 2];

        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            FindRenderers();

            string tempFile = myVegas.TemporaryFilesPath + Path.DirectorySeparatorChar + "temp.mp3";
            string tempLog = myVegas.TemporaryFilesPath + Path.DirectorySeparatorChar + "temp_loud.txt";

            SaveTrackStatus();

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsAudio() && myTrack.Selected)
                {
                    myTrack.Mute = false;

                    RenderTempFile(tempFile);
                    ProcessLog(tempLog, myTrack);

                    File.Delete(tempFile);
                    File.Delete(tempLog);

                    myTrack.Mute = true;
                }
            }


            RecallTrackStatus();
        }

        public void FindRenderers()
        {
            try
            {
                foreach (Renderer renderer in myVegas.Renderers)
                {
                    //MP3
                    if ("adfa6a4b-a99b-42e3-ae1f-081123ada04b" == renderer.ClassID.ToString())
                    {
                        myRenderer = renderer;

                        try
                        {
                            foreach (RenderTemplate renderTemplate in renderer.Templates)
                            {
                                if (renderTemplate.IsValid())
                                {
                                    //192 Kbps, CD Transparent Audio
                                    if ("8ab64a16-81f5-46e6-8155-1611d592088c" == renderTemplate.TemplateGuid.ToString())
                                    {
                                        rndrTemplate = renderTemplate;
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            {
            }
        }

        public void SaveTrackStatus()
        {
            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsAudio())
                {
                    int myIndex = myTrack.Index;
                    trackStatus[myIndex, 0] = myTrack.Mute;
                    trackStatus[myIndex, 1] = myTrack.Solo;

                    myTrack.Mute = true;
                    myTrack.Solo = false;
                }
            }
        }

        public void RecallTrackStatus()
        {
            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsAudio())
                {
                    int myIndex = myTrack.Index;
                    myTrack.Mute = trackStatus[myIndex, 0];
                    myTrack.Solo = trackStatus[myIndex, 1];
                }
            }
        }

        public void RenderTempFile(string tempFile)
        {
            RenderArgs args = new RenderArgs();
            args.OutputFile = tempFile;
            args.RenderTemplate = rndrTemplate;
            args.Start = Timecode.FromFrames(0);
            args.Length = myVegas.Project.Length;
            args.IncludeMarkers = false;
            args.StretchToFill = false;
            args.GenerateLoudnessLog = true;

            RenderStatus status = myVegas.Render(args);
        }

        public void ProcessLog(string path, Track myTrack)
        {
            var lines = File.ReadLines(path);

            bool foundfirst = false;
            bool FoundQuiet = false;
            Timecode QuietStart = Timecode.FromFrames(0);
            Timecode QuietEnd = Timecode.FromFrames(0);
            Timecode PreviousTC = Timecode.FromFrames(0);

            foreach (string line in lines)
            {
                if (line.StartsWith("------------"))
                {
                    if (FoundQuiet)
                    {
                        QuietEnd = PreviousTC;
                        ProcessSegment(QuietStart, myVegas.Project.Length + logOffset, myTrack);
                    }
                    break;
                }
                if (line.StartsWith("              Pos."))
                {
                    foundfirst = true;
                }
                else
                {
                    if (foundfirst)
                    {
                        if (line.Length > 5)
                        {
                            string[] pieces = line.Split('\t');
                            Timecode trackTime = Timecode.FromString(pieces[1]);
                            double trackVolume = 0;
                            if (pieces[2].Contains("Inf"))
                            {
                                trackVolume = -100;
                            }
                            else
                            {
                                trackVolume = Convert.ToDouble(pieces[2]);
                            }

                            if (trackVolume < QuietLimit)
                            {
                                if (!FoundQuiet)
                                {
                                    FoundQuiet = true;
                                    QuietStart = trackTime;
                                }
                            }
                            else
                            {
                                if (FoundQuiet)
                                {
                                    FoundQuiet = false;
                                    QuietEnd = PreviousTC;

                                    ProcessSegment(QuietStart, QuietEnd, myTrack);
                                }
                            }
                            PreviousTC = trackTime;
                        }
                    }
                }
            }
        }

        private void ProcessSegment(Timecode QuietStart, Timecode QuietEnd, Track myTrack)
        {
            Timecode startTC = QuietStart - logOffset;
            if (startTC < Timecode.FromFrames(0))
            {
                startTC = Timecode.FromFrames(0);
            }

            Timecode endTC = QuietEnd - logOffset;
            Timecode regionLen = endTC - startTC;

            if (regionLen > minLength)
            {
                foreach (TrackEvent evnt in myTrack.Events)
                {
                    if (evnt.Start < startTC && evnt.End > startTC)
                    {
                        evnt.Split(startTC - evnt.Start);
                    }
                    if (evnt.Start < endTC && evnt.End > endTC)
                    {
                        evnt.Split(endTC - evnt.Start);
                    }
                }
                for (int i = myTrack.Events.Count - 1; i >= 0; i--)
                {
                    TrackEvent evnt = myTrack.Events[i];
                    if (evnt.Start >= startTC && evnt.End <= endTC)
                    {
                        myTrack.Events.Remove(evnt);
                    }
                }
            }
        }

    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    //public void FromVegas(Vegas vegas, String scriptFile, XmlDocument scriptSettings, ScriptArgs args)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}


@Robert Johnston I didn't change anything in the script (just the double QuietLimit = -35.0; which is the value I'm looking for), the track volume is at the normal Vegas standard and has no effect and even so the entire audio event is excluded even with levels higher than those indicated in the script

Robert Johnston wrote on 6/14/2024, 4:08 AM

@andy-0 That looks like the script I have. Take a look at the loudness log to see what is being recorded for loudness in the momentary loudness column. You can get the loudness log going to Tools > Generate Loudness Log. Just Solo the one audio track. After the log is generated, see if most of the entries are below -35 dB. You can also turn on the Loudness meter and watch the momentary loudness levels as your clip is playing back. View > Window > Loudness Meters ( CTRL-ALT-7).

I forgot to mention that besides the track volume, there is the event volume that is also taken into account. Check that the event volume level hasn't been accidently pulled down with the mouse. Also check the audio FX to make sure those are okay.

If you upload the audio file to Google Drive or One Drive, we can download it and test it out.

Last changed by Robert Johnston on 6/14/2024, 4:11 AM, changed a total of 1 times.

Intel Core i7 10700K CPU @ 3.80GHz (to 4.65GHz), NVIDIA GeForce RTX 2060 SUPER 8GBytes. Memory 32 GBytes DDR4. Also Intel UHD Graphics 630. Mainboard: Dell Inc. PCI-Express 3.0 (8.0 GT/s) Comet Lake. Bench CPU Multi Thread: 5500.5 per CPU-Z.

Vegas Pro 21.0 (Build 108) with Mocha Vegas

Windows 11 not pro

andy-0 wrote on 6/14/2024, 6:44 AM

@Robert Johnston When I get home I will upload the audio and the loudness log file generated by it but first I wanted to ask if you made any specific configuration in Vegas Pro so it can use the script correctly. I'm using version 17 of Vegas Pro but I don't think the script is showing this instability due to the version

 

 

andy-0 wrote on 6/14/2024, 11:23 AM

@Robert Johnston  (google drive link to the script) Here is the link to the Google Drive file. In it, I've placed a video that I was using as an example to test the script, the script for removing silent areas that I'm using, and the loudness log file generated by the script. I still haven't figured out what's causing the audio event to be completely deleted even though it has values greater than the threshold.