|
|
@ -13,13 +13,14 @@
|
|
|
|
# limitations under the License.
|
|
|
|
# limitations under the License.
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
import urllib.request
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
import numpy as np
|
|
|
|
import paddle
|
|
|
|
import paddle
|
|
|
|
|
|
|
|
|
|
|
|
from paddleaudio import load
|
|
|
|
from paddleaudio import load
|
|
|
|
|
|
|
|
|
|
|
|
file_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
wav_url = 'https://paddlespeech.bj.bcebos.com/PaddleAudio/zh.wav'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FeatTest(unittest.TestCase):
|
|
|
|
class FeatTest(unittest.TestCase):
|
|
|
@ -31,9 +32,10 @@ class FeatTest(unittest.TestCase):
|
|
|
|
def setUpDevice(self, device='cpu'):
|
|
|
|
def setUpDevice(self, device='cpu'):
|
|
|
|
paddle.set_device(device)
|
|
|
|
paddle.set_device(device)
|
|
|
|
|
|
|
|
|
|
|
|
def initWavInput(self):
|
|
|
|
def initWavInput(self, url=wav_url):
|
|
|
|
self.waveform, self.sr = load(
|
|
|
|
if not os.path.isfile(os.path.basename(url)):
|
|
|
|
os.path.abspath(os.path.join(file_dir, '../wav/zh.wav')))
|
|
|
|
urllib.request.urlretrieve(url, os.path.basename(url))
|
|
|
|
|
|
|
|
self.waveform, self.sr = load(os.path.abspath(os.path.basename(url)))
|
|
|
|
self.waveform = self.waveform.astype(
|
|
|
|
self.waveform = self.waveform.astype(
|
|
|
|
np.float32
|
|
|
|
np.float32
|
|
|
|
) # paddlespeech.s2t.transform.spectrogram only supports float32
|
|
|
|
) # paddlespeech.s2t.transform.spectrogram only supports float32
|
|
|
|