Commit b7ddc469 authored by IT18126884's avatar IT18126884

Add the Silence count

parent 900e3bca
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/2021-060.iml" filepath="$PROJECT_DIR$/.idea/2021-060.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/Updated.iml" filepath="$PROJECT_DIR$/.idea/Updated.iml" />
</modules>
</component>
</project>
\ No newline at end of file
import os
from pydub import AudioSegment
from pydub.silence import split_on_silence
sound = AudioSegment.from_wav("chunk7.wav")
chunks = split_on_silence(sound, min_silence_len=50, silence_thresh=sound.dBFS - 16, keep_silence=150)
chunk_folder_name = "splits_by_pauses"
# create folder to store chunks
if not os.path.isdir(chunk_folder_name):
os.mkdir(chunk_folder_name)
for i, audio_chunk in enumerate(chunks, start=1):
chunk_file = os.path.join(chunk_folder_name, f"chunk{i}.wav")
audio_chunk.export(chunk_file, format="wav", bitrate='192k')
print(str(len(chunks) - 1) + " : Pause/s found")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment