Changeset cd46892 for python/tests


Ignore:
Timestamp:
Dec 23, 2018, 5:48:12 AM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
Children:
51b5f9c
Parents:
966c650
Message:

[tests] add parse_file_samplerate to fetch samplerate from path

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/utils.py

    r966c650 rcd46892  
    22
    33import os
     4import re
    45import glob
    56import numpy as np
     
    7879                    total_files += 1
    7980    return total_files
     81
     82def parse_file_samplerate(soundfile):
     83    samplerate = None
     84    # parse samplerate
     85    re_sr = re.compile(r'/([0-9]{4,})Hz_.*')
     86    match_samplerate = re_sr.findall(soundfile)
     87    if match_samplerate:
     88        samplerate = int(match_samplerate[0])
     89    else:
     90        import warnings
     91        warnings.warn(UserWarning("could not parse samplerate for {:s}"
     92            .format(soundfile)))
     93    return samplerate
Note: See TracChangeset for help on using the changeset viewer.