Skip to content
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

Silence part #14

Open
SunHaoRanCN opened this issue Jun 20, 2023 · 3 comments
Open

Silence part #14

SunHaoRanCN opened this issue Jun 20, 2023 · 3 comments

Comments

@SunHaoRanCN
Copy link

Hi, I implemented audio segmentation with your code and it works great. In the mean time, I also want to generate a list of chunks of silence part which is rejected here. Is there any way I can achieve this?

@yqzhishen
Copy link
Member

https://github.com/openvpi/audio-slicer/blob/main/slicer2.py#L76

The list sil_tags represents start frame and end frame indices of all silence parts. You can use the similar method as I get the sound chunks to get the silence chunks.

@EmreOzkose
Copy link

To obtain silence parts in seconds, I think below code is enough ?

  1. Return sil_tags: (return chunks -> return chunks, sil_tags)
  2. Calculate in seconds:
audio, sr = soundfile.read(audio_path)
slicer = Slicer(
    sr=sr,
    threshold=-40,
    min_length=5000,
    min_interval=300,
    hop_size=10,
    max_sil_kept=500
)
chunks, sil_tags = slicer.slice(audio)
for sil_tag in sil_tags:
    start = sil_tag[0] * slicer.hop_size / sr
    end = sil_tag[1] * slicer.hop_size / sr
    print(start, end)

or basically

for sil_tag in sil_tags:
    start = sil_tag[0] / 100
    end = sil_tag[1] / 100
    print(start, end)

@yqzhishen
Copy link
Member

@EmreOzkose numbers in sil_tags are frame indices, simply dividing by 100 may not generalize for all hop_size. By the way, there are already some forked version of audio slicer that produces both timestamps and chuncks, like this one: https://github.com/openvpi/SOME/blob/main/utils/slicer2.py

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

No branches or pull requests

3 participants