本文整理汇总了Python中librosa.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python librosa.__version__方法的具体用法?Python librosa.__version__怎么用?Python librosa.__version__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类librosa
的用法示例。
在下文中一共展示了librosa.__version__方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_fb
# 需要导入模块: import librosa [as 别名]
# 或者: from librosa import __version__ [as 别名]
def test_create_fb(self):
self._test_create_fb()
self._test_create_fb(n_mels=128, sample_rate=44100)
self._test_create_fb(n_mels=128, fmin=2000.0, fmax=5000.0)
self._test_create_fb(n_mels=56, fmin=100.0, fmax=9000.0)
self._test_create_fb(n_mels=56, fmin=800.0, fmax=900.0)
self._test_create_fb(n_mels=56, fmin=1900.0, fmax=900.0)
self._test_create_fb(n_mels=10, fmin=1900.0, fmax=900.0)
if StrictVersion(librosa.__version__) < StrictVersion("0.7.2"):
return
self._test_create_fb(n_mels=128, sample_rate=44100, norm="slaney")
self._test_create_fb(n_mels=128, fmin=2000.0, fmax=5000.0, norm="slaney")
self._test_create_fb(n_mels=56, fmin=100.0, fmax=9000.0, norm="slaney")
self._test_create_fb(n_mels=56, fmin=800.0, fmax=900.0, norm="slaney")
self._test_create_fb(n_mels=56, fmin=1900.0, fmax=900.0, norm="slaney")
self._test_create_fb(n_mels=10, fmin=1900.0, fmax=900.0, norm="slaney")
示例2: check_min_versions
# 需要导入模块: import librosa [as 别名]
# 或者: from librosa import __version__ [as 别名]
def check_min_versions():
ret = True
# pyaudio
vers_required = "0.2.7"
vers_current = pyaudio.__version__
if StrictVersion(vers_current) < StrictVersion(vers_required):
print("Error: minimum pyaudio vers: {}, current vers {}".format(vers_required, vers_current))
ret = False
# librosa
vers_required = "0.4.3"
vers_current = librosa.__version__
if StrictVersion(vers_current) < StrictVersion(vers_required):
print("Error: minimum librosa vers: {}, current vers {}".format(vers_required, vers_current))
ret = False
# numpy
vers_required = "1.9.0"
vers_current = np.__version__
if StrictVersion(vers_current) < StrictVersion(vers_required):
print("Error: minimum numpy vers: {}, current vers {}".format(vers_required, vers_current))
ret = False
return ret
示例3: test_metadata
# 需要导入模块: import librosa [as 别名]
# 或者: from librosa import __version__ [as 别名]
def test_metadata():
"""The metadata of the json file should be correct."""
# Note: The json file should have been created with previous tests
with open(file_struct.features_file) as f:
data = json.load(f)
assert("metadata" in data.keys())
metadata = data["metadata"]
assert("timestamp" in metadata.keys())
assert(metadata["versions"]["numpy"] == np.__version__)
assert(metadata["versions"]["msaf"] == msaf.__version__)
assert(metadata["versions"]["librosa"] == librosa.__version__)
示例4: write_features
# 需要导入模块: import librosa [as 别名]
# 或者: from librosa import __version__ [as 别名]
def write_features(self):
"""Saves features to file."""
out_json = collections.OrderedDict()
try:
# Only save the necessary information
self.read_features()
except (WrongFeaturesFormatError, FeaturesNotFound,
NoFeaturesFileError):
# We need to create the file or overwite it
# Metadata
out_json = collections.OrderedDict({"metadata": {
"versions": {"librosa": librosa.__version__,
"msaf": msaf.__version__,
"numpy": np.__version__},
"timestamp": datetime.datetime.today().strftime(
"%Y/%m/%d %H:%M:%S")}})
# Global parameters
out_json["globals"] = {
"dur": self.dur,
"sample_rate": self.sr,
"hop_length": self.hop_length,
"audio_file": self.file_struct.audio_file
}
# Beats
out_json["est_beats"] = self._est_beats_times.tolist()
out_json["est_beatsync_times"] = self._est_beatsync_times.tolist()
if self._ann_beats_times is not None:
out_json["ann_beats"] = self._ann_beats_times.tolist()
out_json["ann_beatsync_times"] = self._ann_beatsync_times.tolist()
except FeatureParamsError:
# We have other features in the file, simply add these ones
with open(self.file_struct.features_file) as f:
out_json = json.load(f)
finally:
# Specific parameters of the current features
out_json[self.get_id()] = {}
out_json[self.get_id()]["params"] = {}
for param_name in self.get_param_names():
value = getattr(self, param_name)
# Check for special case of functions
if hasattr(value, '__call__'):
value = value.__name__
else:
value = str(value)
out_json[self.get_id()]["params"][param_name] = value
# Actual features
out_json[self.get_id()]["framesync"] = \
self._framesync_features.tolist()
out_json[self.get_id()]["est_beatsync"] = \
self._est_beatsync_features.tolist()
if self._ann_beatsync_features is not None:
out_json[self.get_id()]["ann_beatsync"] = \
self._ann_beatsync_features.tolist()
# Save it
with open(self.file_struct.features_file, "w") as f:
json.dump(out_json, f, indent=2)
示例5: griffin_lim
# 需要导入模块: import librosa [as 别名]
# 或者: from librosa import __version__ [as 别名]
def griffin_lim(spc, n_fft, n_shift, win_length, window="hann", n_iters=100):
"""Convert linear spectrogram into waveform using Griffin-Lim.
Args:
spc (ndarray): Linear spectrogram (T, n_fft // 2 + 1).
n_fft (int): Number of FFT points.
n_shift (int): Shift size in points.
win_length (int): Window length in points.
window (str, optional): Window function type.
n_iters (int, optionl): Number of iterations of Griffin-Lim Algorithm.
Returns:
ndarray: Reconstructed waveform (N,).
"""
# assert the size of input linear spectrogram
assert spc.shape[1] == n_fft // 2 + 1
if LooseVersion(librosa.__version__) >= LooseVersion("0.7.0"):
# use librosa's fast Grriffin-Lim algorithm
spc = np.abs(spc.T)
y = librosa.griffinlim(
S=spc,
n_iter=n_iters,
hop_length=n_shift,
win_length=win_length,
window=window,
center=True if spc.shape[1] > 1 else False,
)
else:
# use slower version of Grriffin-Lim algorithm
logging.warning(
"librosa version is old. use slow version of Grriffin-Lim algorithm."
"if you want to use fast Griffin-Lim, please update librosa via "
"`source ./path.sh && pip install librosa==0.7.0`."
)
cspc = np.abs(spc).astype(np.complex).T
angles = np.exp(2j * np.pi * np.random.rand(*cspc.shape))
y = librosa.istft(cspc * angles, n_shift, win_length, window=window)
for i in range(n_iters):
angles = np.exp(
1j
* np.angle(librosa.stft(y, n_fft, n_shift, win_length, window=window))
)
y = librosa.istft(cspc * angles, n_shift, win_length, window=window)
return y
示例6: griffin_lim
# 需要导入模块: import librosa [as 别名]
# 或者: from librosa import __version__ [as 别名]
def griffin_lim(
spc: np.ndarray,
n_fft: int,
n_shift: int,
win_length: int = None,
window: Optional[str] = "hann",
n_iter: Optional[int] = 32,
) -> np.ndarray:
"""Convert linear spectrogram into waveform using Griffin-Lim.
Args:
spc: Linear spectrogram (T, n_fft // 2 + 1).
n_fft: The number of FFT points.
n_shift: Shift size in points.
win_length: Window length in points.
window: Window function type.
n_iter: The number of iterations.
Returns:
Reconstructed waveform (N,).
"""
# assert the size of input linear spectrogram
assert spc.shape[1] == n_fft // 2 + 1
if LooseVersion(librosa.__version__) >= LooseVersion("0.7.0"):
# use librosa's fast Grriffin-Lim algorithm
spc = np.abs(spc.T)
y = librosa.griffinlim(
S=spc,
n_iter=n_iter,
hop_length=n_shift,
win_length=win_length,
window=window,
center=True if spc.shape[1] > 1 else False,
)
else:
# use slower version of Grriffin-Lim algorithm
logging.warning(
"librosa version is old. use slow version of Grriffin-Lim algorithm."
"if you want to use fast Griffin-Lim, please update librosa via "
"`source ./path.sh && pip install librosa==0.7.0`."
)
cspc = np.abs(spc).astype(np.complex).T
angles = np.exp(2j * np.pi * np.random.rand(*cspc.shape))
y = librosa.istft(cspc * angles, n_shift, win_length, window=window)
for i in range(n_iter):
angles = np.exp(
1j
* np.angle(librosa.stft(y, n_fft, n_shift, win_length, window=window))
)
y = librosa.istft(cspc * angles, n_shift, win_length, window=window)
return y
# TODO(kan-bayashi): write as torch.nn.Module
示例7: jam_pack
# 需要导入模块: import librosa [as 别名]
# 或者: from librosa import __version__ [as 别名]
def jam_pack(jam, **kwargs):
"""Pack data into a jams sandbox.
If not already present, this creates a `muda` field within `jam.sandbox`,
along with `history`, `state`, and version arrays which are populated by
deformation objects.
Any additional fields can be added to the `muda` sandbox by supplying
keyword arguments.
Parameters
----------
jam : jams.JAMS
A JAMS object
Returns
-------
jam : jams.JAMS
The updated JAMS object
Examples
--------
>>> jam = jams.JAMS()
>>> muda.jam_pack(jam, my_data=dict(foo=5, bar=None))
>>> jam.sandbox
<Sandbox: muda>
>>> jam.sandbox.muda
<Sandbox: state, version, my_data, history>
>>> jam.sandbox.muda.my_data
{'foo': 5, 'bar': None}
"""
if not hasattr(jam.sandbox, "muda"):
# If there's no mudabox, create one
jam.sandbox.muda = jams.Sandbox(
history=[],
state=[],
version=dict(
muda=version,
librosa=librosa.__version__,
jams=jams.__version__,
pysoundfile=psf.__version__,
),
)
elif not isinstance(jam.sandbox.muda, jams.Sandbox):
# If there is a muda entry, but it's not a sandbox, coerce it
jam.sandbox.muda = jams.Sandbox(**jam.sandbox.muda)
jam.sandbox.muda.update(**kwargs)
return jam