Exemplo n.º 1
0
def upload_wavs_from_shell(project_name, segment_length):
    project_name = project_name.lower()
    media_path = "media/uploaded_wavs/" + project_name + '/'
    p = Project.objects.get(name=project_name)
    file_list = os.listdir(media_path)
    if file_list == []:
        raise ValueError("Upload files to %s" % media_path)
    for file_name in file_list:
        f = File(open(media_path + file_name), 'r')
        subprocess.call(['rm', media_path + file_name])
        f.name = file_name
        w = Wav(project=p, file=f, name=file_name, upload_date=timezone.now())
        w.save()
        duration = get_wav_duration(w)
        create_segments(wav=w, duration=duration, segments_length=segment_length)
Exemplo n.º 2
0
def create_wav(project, file, name, upload_date):
    w = Wav(project=project, file=file, name=name, upload_date=upload_date)
    w.save()

    return w