Skip to content

Commit 435effb

Browse files
committed
use librosa
1 parent 2af50b4 commit 435effb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

demo.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
matplotlib.use('Agg') # Remove this line if you don't need them
1111
import matplotlib.pyplot as plt
1212

13-
import soundfile as sf
13+
# import soundfile as sf
14+
import librosa
1415
import pyworld as pw
1516

1617

@@ -55,7 +56,8 @@ def main(args):
5556
rmtree('test')
5657
os.mkdir('test')
5758

58-
x, fs = sf.read('utterance/vaiueo2d.wav')
59+
# x, fs = sf.read('utterance/vaiueo2d.wav')
60+
x, fs = librosa.load('utterance/vaiueo2d.wav')
5961

6062
# 1. A convient way
6163
f0, sp, ap, pyDioOpt = pw.wav2world(x, fs) # use default options
@@ -74,14 +76,14 @@ def main(args):
7476
_sp = pw.cheaptrick(x, _f0, t, fs)
7577
_ap = pw.d4c(x, _f0, t, fs)
7678
_y = pw.synthesize(_f0, _sp, _ap, fs, pyDioOpt.option['frame_period'])
77-
sf.write('test/y_without_f0_refinement.wav', _y, fs)
79+
librosa.output.write_wav('test/y_without_f0_refinement.wav', _y, fs)
7880

7981
# 2-2 With F0 refinement (using stonemask)
8082
f0 = pw.stonemask(x, _f0, t, fs)
8183
sp = pw.cheaptrick(x, f0, t, fs)
8284
ap = pw.d4c(x, f0, t, fs)
8385
y = pw.synthesize(f0, sp, ap, fs, pyDioOpt.option['frame_period'])
84-
sf.write('test/y_with_f0_refinement.wav', y, fs)
86+
librosa.output.write_wav('test/y_with_f0_refinement.wav', y, fs)
8587

8688
# Comparison
8789
savefig('test/wavform.png', [x, _y, y])

0 commit comments

Comments
 (0)