Skip to content

- avoid the case len(sil_tags) == 1 that it will return empty output #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nguyenlamvu123
Copy link

No description provided.

@yqzhishen
Copy link
Member

If len(sil_tags) == 1, the audio should be sliced. In which case do you think the slicer does not work properly?

@nguyenlamvu123
Copy link
Author

nguyenlamvu123 commented Jun 10, 2024

audio-slicer/slicer2.py:

        if silence_start is not None and total_frames - silence_start >= self.min_interval:
            silence_end = min(total_frames, silence_start + self.max_sil_kept)
            pos = rms_list[silence_start: silence_end + 1].argmin() + silence_start
            sil_tags.append((pos, total_frames + 1))
        # Apply and return slices.
        if len(sil_tags) == 0:
            return [waveform]
        else:  -------------------------------> if len(sil_tags) == 1, it will run into this
            chunks = []
            if sil_tags[0][0] > 0:
                chunks.append(self._apply_slice(waveform, 0, sil_tags[0][0]))  -------------------------------> sil_tags[0][0] < 0 and chunks is still an empty list
            for i in range(len(sil_tags) - 1):  -------------------------------> if len(sil_tags) == 1, it will be `for i in range(0):` and chunks is still an empty list
                chunks.append(self._apply_slice(waveform, sil_tags[i][1], sil_tags[i + 1][0]))
            if sil_tags[-1][1] < total_frames:
                chunks.append(self._apply_slice(waveform, sil_tags[-1][1], total_frames))  -------------------------------> if sil_tags[-1][1] >= total_frames, chunks is still an empty list
            return chunks

it is a strange story, with the same input and with if len(sil_tags) == 0:, it well runs in local (with pycharm) but is bad in remote server; well runs in remote server with if len(sil_tags) <= 1:
so I can`t take a screenshoot of debug of pycharm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants