# What could an algorithm look like that iterates through all combinations of two variables to aim at a certain number of entries? [closed]

For background information, see "Some background" further down.

I have a list that looks like this:

Start-Time-In-Seconds;End-Time-In-Seconds
1;2
4;6
12;15
...


This works together with a wave file by acting as a cutlist. So the desired parts are 1->2, 4->6, 12->15, ...

If the distance between End-Time-In-Seconds of the previous element and Start-Time-In-Seconds of the current element is below a threshold of seconds(I call it Pausendauer) I merge those two, ie if the threshold is 3 seconds then the list will be

Start-Time-In-Seconds;End-Time-In-Seconds
1;6
12;15
...


If the distance between Start-Time-In-Seconds and End-Time-In-Seconds is below a threshold of seconds(I call it Minimallänge) I discard this sample, ie if the threshold is 4 seconds then the list will be

Start-Time-In-Seconds;End-Time-In-Seconds
1;6
...


What could an algorithm look like that iterates (intelligently) through all combinations of Minimallänge and Pausendauer to aim at a certain number of entries? Example:

The number of entries should be 3. Given the number 3 the algorithm should iterate (intelligently) through all combinations of Minimallänge and Pausendauer to output something like this:

Start-Time-In-Seconds;End-Time-In-Seconds
1;12
18;20
50;100


And that should be all. You notice I did not add "..." to it as the final list is to only consist of three entries.

Some background: The wave file contains several interviews being recorded continuously with pauses in between. A VAD gave me areas where it presumes voice to be. As I know the number of total conversations(f.i. 3, usually more which is why this makes sense) my goal is to determine them automatically. The cutlist is the raw output of my VAD which I want to turn into a usable cutlist for ffmpeg.

PS: If you can, share an algorithm in c#.

• This is off-topic for dsp.SE. I vote to close. – Dilip Sarwate Mar 7 '13 at 12:17
• Recommend a better place then. – Zurechtweiser Mar 7 '13 at 12:29
• This is a general algorithm question, Stack Overflow might be a better place. But I warn you that your problem is ill defined in its current form - you can reduce the number of entries by increasing either of the two variables. This will lead to different solutions, and you will have to find another criteria to weigh them. It looks like you problem would be better defined if you had an extra constraint, for example, "total length of the resulting sequence is N seconds" or "maximize the % of original material that is preserved". – pichenettes Mar 7 '13 at 12:52
• I hereby add: Minimallänge must be greater than 10 seconds. – Zurechtweiser Mar 7 '13 at 12:58
• If the conversations are between different pairs of speakers, use speaker diarization techniques (unsupervised speaker recognition). Otherwise, maybe you could just detect the 2 largest silences/gaps and assume that these are the boundaries between the conversations. – pichenettes Mar 7 '13 at 15:54