desh2608 / gss

A simple package for Guided source separation (GSS)
MIT License
105 stars 13 forks source link

Suggestion to robustify filenames #34

Closed boeddeker closed 1 year ago

boeddeker commented 1 year ago

In the source code you use

f"{recording_id}-{speaker}-{int(100*cut.start):06d}_{int(100*cut.end):06d}.flac"

to create the filenames. This can sometimes be confusing, because the filename and the actual start and end could be differnt, e.g. when start = 0.58, the file name would contain 000057 (In CHiME5 and 6 this was painful, when the names changed). A simple fix would be to use round instead of int. That would also allow reading the timestamps from the file, convert to float and reuse to create the filename.

Here, an example, that you could use to find numbers that causes issues:

for i in range(1000):

    # Read time from file
    f = float(f'{i//1000}.{i%1000:03d}')

    # Write as part of filename
    a = f'{int(f * 100):06d}'  # Quantisation and sometimes wrong flooring

    # Read time from filename
    b = int(a) / 100

    # Write as part of filename
    c = f'{int(b * 100):06d}'  # Sometimes wrong flooring

    if a != c:
        print(i, f, a, b, c)

# Output: 
# 291 0.291 000029 0.29 000028
# 292 0.292 000029 0.29 000028
# 293 0.293 000029 0.29 000028
# 294 0.294 000029 0.29 000028
# 295 0.295 000029 0.29 000028
# 296 0.296 000029 0.29 000028
# 297 0.297 000029 0.29 000028
# 298 0.298 000029 0.29 000028
# 299 0.299 000029 0.29 000028
# 571 0.571 000057 0.57 000056
# 572 0.572 000057 0.57 000056
# 573 0.573 000057 0.57 000056
# 574 0.574 000057 0.57 000056
# 575 0.575 000057 0.57 000056
# 576 0.576 000057 0.57 000056
# 577 0.577 000057 0.57 000056
# 578 0.578 000057 0.57 000056
# 579 0.579 000057 0.57 000056
# 580 0.58 000057 0.57 000056
# 581 0.581 000058 0.58 000057
# 582 0.582 000058 0.58 000057
# 583 0.583 000058 0.58 000057
# 584 0.584 000058 0.58 000057
# 585 0.585 000058 0.58 000057
# 586 0.586 000058 0.58 000057
# 587 0.587 000058 0.58 000057
# 588 0.588 000058 0.58 000057
# 589 0.589 000058 0.58 000057
desh2608 commented 1 year ago

Hi Christoph! Your suggestion makes sense. I'll make this change when I have some time next week.