示例#1
0
文件: dp.py 项目: karlbishnu/NotZam
def load_backgrounds(data):
    backgrounds = []

    background_paths = data['backgroundSlices']
    logger.info("input: %s", background_paths)
    for background_path in background_paths:
        backgrounds.append(open_audio(background_path))

    return backgrounds
示例#2
0
文件: dp.py 项目: karlbishnu/NotZam
def load_all_waves(root):
    audios = []
    for path, dirs, filenames in os.walk(root):
        for filename in filenames:
            if filename.endswith("mp3"):
                full_path = path + "/" + filename
                audio = open_audio(full_path)
                audios.append((full_path, audio))

    return audios
示例#3
0
def slice_sound(path, duration_sec=MIN_BACK_DURATION_SEC):
    res = []
    try:
        sound = open_audio(path).split_to_mono()[0]
        total_duration = len(sound)
        duration_millis = duration_sec * 1000

        for i in range(0, total_duration, duration_millis):
            target = "1-" + str(i) + ".wav"
            end = i+duration_millis-1 if i+duration_millis-1 < total_duration else total_duration
            buf = sound[i:end]
            buf.export(out_f=target, format="wav").close()
            res.append(target)

    except FileNotFoundError as e:
        logger.error("file:{path} not found".format(path=path))
    except Exception as e:
        logger.error("exception occurs : {e}".format(e=e))
    return res
示例#4
0
 def setUp(self):
     self.background: AudioSegment = open_audio(
         'test-asset/raw-data/backgrounds/1.mp3')
     self.activate: AudioSegment = open_audio(
         'test-asset/raw-data/activates/1_2.wav')
示例#5
0
def process(data):
    segment = open_audio(data['filePath'])
    x = fit_audio(segment)
    predictions = predict(x)
    return make_output(segment, predictions)