Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Q&A, Tips, Tricks and Howto

Reply
 
Thread Tools Display Modes
Old 04-15-2021, 11:34 AM   #1
Konzertheld
Human being with feelings
 
Join Date: Apr 2021
Posts: 2
Default Cut parts out based on known positions saved in a text file

Hello everyone,

I have a very specific case that can be generalized a lot. I want to cut silence from a video. Because I was not satisfied with the results of the different silence detection methods in Reaper, I used a speech recognition algorithm designed to create subtitles. Now I have a subtitles file that has very accurate markers of where speech is present. I want to use this file to feed Reaper to automatically cut out the silence.

- I have programming skills. I can easily convert the subtitles file to any format if needed.
- Manually or only half-automated cutting silence is not an option. I need to cut hundreds of positions per file and dozens of files.
- I do know of a way to remove empty space though, so if the method I should use left me with the silent parts actually removed and I only needed to move all the remaining parts, that would be ok.
- Ideally though, I would like to feed a list of from-to-positions to Reaper by just loading a file and have Reaper simply ripple cut those out (do not leave empty space where the silence was).

What options do I have?

Thanks in advance!

(I did not put this in the video section because I do not think this is video-specific, as I do not request using specifically a subtitles file and I can cut the video file just as any audio file. I hope that's fine.)
Konzertheld is offline   Reply With Quote
Old 04-15-2021, 11:31 PM   #2
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

One way I can think of is to convert your "subtitles file" to a suitable csv file and
use the action:
Markers/Regions: Import markers/regions from file (replace all existing)

(or Script: X-Raym_Import markers and regions from tab-delimited CSV file.lua)

Either way, that gets you a bunch of regions corresponding to your speech.

(EDIT or, maybe better - regions corresponding to the gaps?)


Then, perhaps...
Script: X-Raym_Split selected items at regions.lua

Which leaves you with the task of deleting (or muting) outside regions...
(EDIT or removing the region contents...)

If no-one has a suggestion for that job, I can knock up a little script later today.
__________________
it's meant to sound like that...

Last edited by jrk; 04-15-2021 at 11:45 PM.
jrk is offline   Reply With Quote
Old 04-16-2021, 01:18 PM   #3
Konzertheld
Human being with feelings
 
Join Date: Apr 2021
Posts: 2
Default

Thank you! That was very helpful already.

- I was able to import my markers as regions.
- I got the script to split my item using the regions.
- Now the simplest solution (to me) appears to be a loop of "select next item" twice, skipping every other one EDIT: Nope, just once, as one (the one the marker is at) is always skipped, and "ripple delete". I figured out I can just turn ripple on and then the normal remove action ("Remove items/tracks/envelope points") will ripple delete. So... how do I create that loop, and how do I get it to run until the end of the track and then stop?

EDIT: So... I figured out how to create such a loop (I found the SWS cycle editor). Turns out, just removing every other region is not such a bright idea, because not every pause between two subtitles means there is no spoken word*. So... I might be in luck and get my subtitle generator to not add unnecessary pauses, otherwise I'll need something to detect regions with unusually low volume, which is propably a lot harder than what I originally wanted to do and out of the scope of this thread, which can be considered solved.

Summary of what I did:
- convert subtitle file to Reaper-compatible CSV file
- "Markers/Regions: Import markers/regions from file (replace all existing)"
- "Script: X-Raym_Split selected items at regions.lua"
- Turn on ripple remove
- Use SWS cycle editor to create a loop of "Item navigation: Select and move to next item" and "Remove items/tracks/envelope points"

Thanks again for pointing me in the right direction.

* The reason is propably that subtitles can't be too long and when it splits a subtitle into two so it can be displayed, it adds a pause in between them for whatever reason. This pause seems to have a specific length so maybe I am in luck and can remove all pauses of that specific length, but as soon as I miss one or have a false positive, dozens of regions might be deleted errorneously so while what I wanted to achieve works perfectly, the subtitle file is not as much of a help as I thought.

Last edited by Konzertheld; 04-16-2021 at 02:09 PM. Reason: figured it out myself
Konzertheld is offline   Reply With Quote
Old 04-16-2021, 10:40 PM   #4
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

Ah. Well, glad to help a little.

Just in case you hadn't thought of it,
https://opensource.com/article/19/9/...earning-python
__________________
it's meant to sound like that...
jrk is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.