def analyze(video_id):
    print "Beginning audio analysis...\n"
    file_name = audio_scraper.get_wav_from_vid(video_id)
    decision_tree = tree.generate()
    audio_file = AudioFile.open(file_name)
    frames = audio_file.frames(16384)
    save_spectrum_image(audio_file)

    analysis = []
    i = 0

    for frame in frames:
        #print "Processing [audio frame {}]...".format(i)
        frequencies, levels = get_power_spectrum(frame)
        data = training_data.generate(frequencies, levels, file_name)

        try:
            analysis.append(decision_tree.predict(data))
        except ValueError as e:
            print "Encountered error: {0}".format(e)

        i += 1

    print "Audio analysis complete.\n"

    return analysis, frames
Exemplo n.º 2
0
def import_data(video_id):
    file_name = audio_scraper.download_song(video_id)
    audio_file = AudioFile.open(file_name)
    frames = audio_file.frames(16384)

    for frame in frames:
        import_frame(frame)
def analyze(video_id):
    print "Beginning audio analysis...\n"
    file_name = audio_scraper.get_wav_from_vid(video_id)
    decision_tree = tree.generate()
    audio_file = AudioFile.open(file_name)
    frames = audio_file.frames(16384)
    save_spectrum_image(audio_file)

    analysis = []
    i = 0

    for frame in frames:
        # print "Processing [audio frame {}]...".format(i)
        frequencies, levels = get_power_spectrum(frame)
        data = training_data.generate(frequencies, levels, file_name)

        try:
            analysis.append(decision_tree.predict(data))
        except ValueError as e:
            print "Encountered error: {0}".format(e)

        i += 1

    print "Audio analysis complete.\n"

    return analysis, frames
Exemplo n.º 4
0
def import_data(video_id):
    file_name = audio_scraper.download_song(video_id)
    audio_file = AudioFile.open(file_name)
    frames = audio_file.frames(16384)

    for frame in frames:
        import_frame(frame)