utils#

diffsptk.get_alpha(sr, mode='hts', n_freq=10, n_alpha=100)[source]#

Compute frequency warping factor under given sample rate.

Parameters:
srint >= 1 [scalar]

Sample rate in Hz.

mode[‘hts’, ‘auto’]

‘hts’ returns traditional alpha used in HTS. ‘auto’ computes appropriate alpha in L2 sense.

n_freqint >= 2 [scalar]

Number of sample points in the frequency domain.

n_alphaint >= 1 [scalar]

Number of sample points to search alpha.

Returns:
alphafloat [0 <= alpha < 1]

Frequency warping factor, \(\alpha\).

Examples

>>> _, sr = diffsptk.read("assets/data.wav")
>>> alpha = diffsptk.get_alpha(sr)
>>> alpha
0.42
diffsptk.read(filename, double=False, **kwargs)[source]#

Read waveform from file.

Parameters:
filenamestr [scalar]

Path of wav file.

doublebool [scalar]

If True, return double-type tensor.

kwargsadditional keyword arguments

Additional arguments passed to soundfile.read.

Returns:
xTensor

Waveform.

Examples

>>> x, sr = diffsptk.read("assets/data.wav")
>>> x
tensor([ 0.0002,  0.0004,  0.0006,  ...,  0.0006, -0.0006, -0.0007])
>>> sr
16000
diffsptk.write(filename, x, sr, **kwargs)[source]#

Write waveform to file.

Parameters:
filenamestr [scalar]

Path of wav file.

xTensor

Waveform.

srint [scalar]

Sample rate in Hz.

kwargsadditional keyword arguments

Additional arguments passed to soundfile.write.

Examples

>>> x, sr = diffsptk.read("assets/data.wav")
>>> diffsptk.write("out.wav", x, sr)