Skip to content

Instantly share code, notes, and snippets.

View ngbala6's full-sized avatar
🏠
Data Scientist

Bala Murugan N G ngbala6

🏠
Data Scientist
View GitHub Profile
@ngbala6
ngbala6 / silenceremove.py
Last active October 21, 2022 00:40
Silence Removal using Python
import collections
import contextlib
import sys
import wave
import webrtcvad
def read_wave(path):
"""Reads a .wav file.
Takes the path, and returns (PCM audio data, sample rate).
import os
from pydub import AudioSegment
import glob
# if "audio" folder not exists, it will create
if not os.path.isdir("audio"):
os.mkdir("audio")
# Grab the Audio files in "audio" folder
wavfiles = glob.glob("./audio/*.wav")
from vad import VoiceActivityDetector
# import json
# Input file
audiofile = "abc.wav"
plotaudiosignal = VoiceActivityDetector(audiofile)
# Plotting the Audio signals, so that we can identify when it is having silence in audio
# Import packages
from pydub import AudioSegment
from pydub.playback import play
# Play audio
playaudio = AudioSegment.from_file("bala.wav", format="wav")
play(playaudio)