Spaces:
Runtime error
Runtime error
File size: 1,326 Bytes
322d295 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
from moviepy.editor import AudioFileClip
import os
from keras.models import load_model
from Sound2Img import sound_2_Img
from pydub import AudioSegment
from useClahe import applyClahe
class convertWav():
def __init__(self, video_path, save_path):
self.video_path = video_path
self.save_path = save_path
def convert(self, v_path, s_path, ext):
AudioFileClip(v_path).write_audiofile(f"{s_path}.{ext}")
self.convert2Mono(s_path, ext)
def convert2Mono(self, s_path, ext):
sound = AudioSegment.from_wav(s_path + '.' + ext)
sound = sound.set_channels(1)
sound.export(s_path + '.' + ext, format="wav")
def beginn(self):
for i in os.listdir(self.video_path):
path = self.video_path + i
save_path_ = save_path + i
Ext = "wav"
self.convert(path, save_path_, Ext)
path = "Videos/tr/"
save_path = "Sounds/tr/"
converter = convertWav(path, save_path)
converter.beginn()
# model = load_model("models/CLAHE/148epochCLAHEcallback.h5")
# sound_2_Img(save_path).save_spectrograms()
# print("Spektrogram oluşturuldu!")
#
# applyClahe(save_path + 'images/').apply()
# print("Clahe uygulandı!")
# for i in os.listdir(save_path + 'images/'):
# model.predict(i) |