Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
169040b4
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
169040b4
编写于
3月 08, 2022
作者:
K
KP
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
-
上级
1f08095f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
185 addition
and
0 deletion
+185
-0
paddleaudio/tests/features/test_istft.py
paddleaudio/tests/features/test_istft.py
+49
-0
paddleaudio/tests/features/test_log_melspectrogram.py
paddleaudio/tests/features/test_log_melspectrogram.py
+50
-0
paddleaudio/tests/features/test_spectrogram.py
paddleaudio/tests/features/test_spectrogram.py
+42
-0
paddleaudio/tests/features/test_stft.py
paddleaudio/tests/features/test_stft.py
+44
-0
未找到文件。
paddleaudio/tests/features/test_istft.py
0 → 100644
浏览文件 @
169040b4
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
unittest
import
numpy
as
np
import
paddle
from
.base
import
FeatTest
from
paddleaudio.functional.window
import
get_window
from
paddlespeech.s2t.transform.spectrogram
import
IStft
from
paddlespeech.s2t.transform.spectrogram
import
Stft
class
TestIstft
(
FeatTest
):
def
initParmas
(
self
):
self
.
n_fft
=
512
self
.
hop_length
=
128
self
.
window_str
=
'hann'
def
test_istft
(
self
):
ps_stft
=
Stft
(
self
.
n_fft
,
self
.
hop_length
)
ps_res
=
ps_stft
(
self
.
waveform
.
T
).
squeeze
(
1
).
T
# (n_fft//2 + 1, n_frmaes)
x
=
paddle
.
to_tensor
(
ps_res
)
ps_istft
=
IStft
(
self
.
hop_length
)
ps_res
=
ps_istft
(
ps_res
.
T
)
window
=
get_window
(
self
.
window_str
,
self
.
n_fft
,
dtype
=
self
.
waveform
.
dtype
)
pd_res
=
paddle
.
signal
.
istft
(
x
,
self
.
n_fft
,
self
.
hop_length
,
window
=
window
)
np
.
testing
.
assert_array_almost_equal
(
ps_res
,
pd_res
,
decimal
=
5
)
if
__name__
==
'__main__'
:
unittest
.
main
()
paddleaudio/tests/features/test_log_melspectrogram.py
0 → 100644
浏览文件 @
169040b4
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
unittest
import
numpy
as
np
import
paddle
import
paddleaudio
from
.base
import
FeatTest
from
paddlespeech.s2t.transform.spectrogram
import
LogMelSpectrogram
class
TestLogMelSpectrogram
(
FeatTest
):
def
initParmas
(
self
):
self
.
n_fft
=
512
self
.
hop_length
=
128
self
.
n_mels
=
40
def
test_log_melspect
(
self
):
ps_melspect
=
LogMelSpectrogram
(
self
.
sr
,
self
.
n_mels
,
self
.
n_fft
,
self
.
hop_length
)
ps_res
=
ps_melspect
(
self
.
waveform
.
T
).
squeeze
(
1
).
T
x
=
paddle
.
to_tensor
(
self
.
waveform
)
# paddlespeech.s2t的特征存在幅度谱和功率谱滥用的情况
ps_melspect
=
paddleaudio
.
features
.
LogMelSpectrogram
(
self
.
sr
,
self
.
n_fft
,
self
.
hop_length
,
power
=
1.0
,
n_mels
=
self
.
n_mels
,
f_min
=
0.0
)
pa_res
=
(
ps_melspect
(
x
)
/
10.0
).
squeeze
(
0
).
numpy
()
np
.
testing
.
assert_array_almost_equal
(
ps_res
,
pa_res
,
decimal
=
5
)
if
__name__
==
'__main__'
:
unittest
.
main
()
paddleaudio/tests/features/test_spectrogram.py
0 → 100644
浏览文件 @
169040b4
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
unittest
import
numpy
as
np
import
paddle
import
paddleaudio
from
.base
import
FeatTest
from
paddlespeech.s2t.transform.spectrogram
import
Spectrogram
class
TestSpectrogram
(
FeatTest
):
def
initParmas
(
self
):
self
.
n_fft
=
512
self
.
hop_length
=
128
def
test_spectrogram
(
self
):
ps_spect
=
Spectrogram
(
self
.
n_fft
,
self
.
hop_length
)
ps_res
=
ps_spect
(
self
.
waveform
.
T
).
squeeze
(
1
).
T
# Magnitude
x
=
paddle
.
to_tensor
(
self
.
waveform
)
pa_spect
=
paddleaudio
.
features
.
Spectrogram
(
self
.
n_fft
,
self
.
hop_length
,
power
=
1.0
)
pa_res
=
pa_spect
(
x
).
squeeze
(
0
).
numpy
()
np
.
testing
.
assert_array_almost_equal
(
ps_res
,
pa_res
,
decimal
=
5
)
if
__name__
==
'__main__'
:
unittest
.
main
()
paddleaudio/tests/features/test_stft.py
0 → 100644
浏览文件 @
169040b4
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
unittest
import
numpy
as
np
import
paddle
from
.base
import
FeatTest
from
paddleaudio.functional.window
import
get_window
from
paddlespeech.s2t.transform.spectrogram
import
Stft
class
TestStft
(
FeatTest
):
def
initParmas
(
self
):
self
.
n_fft
=
512
self
.
hop_length
=
128
self
.
window_str
=
'hann'
def
test_stft
(
self
):
ps_stft
=
Stft
(
self
.
n_fft
,
self
.
hop_length
)
ps_res
=
ps_stft
(
self
.
waveform
.
T
).
squeeze
(
1
).
T
# (n_fft//2 + 1, n_frmaes)
x
=
paddle
.
to_tensor
(
self
.
waveform
)
window
=
get_window
(
self
.
window_str
,
self
.
n_fft
,
dtype
=
x
.
dtype
)
pd_res
=
paddle
.
signal
.
stft
(
x
,
self
.
n_fft
,
self
.
hop_length
,
window
=
window
).
squeeze
(
0
).
numpy
()
np
.
testing
.
assert_array_almost_equal
(
ps_res
,
pd_res
,
decimal
=
5
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录