Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
d01d7fed
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看板
提交
d01d7fed
编写于
3月 01, 2022
作者:
Q
qingen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[wip][vec] add clustering of vectors #1304
上级
c962eec5
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
8 addition
and
23 deletion
+8
-23
examples/ami/sd0/local/ami_prepare.py
examples/ami/sd0/local/ami_prepare.py
+1
-4
examples/ami/sd0/local/ami_splits.py
examples/ami/sd0/local/ami_splits.py
+0
-4
examples/ami/sd0/local/dataio.py
examples/ami/sd0/local/dataio.py
+0
-4
examples/ami/sd0/local/diarization.py
examples/ami/sd0/local/diarization.py
+7
-11
未找到文件。
examples/ami/sd0/local/ami_prepare.py
浏览文件 @
d01d7fed
...
@@ -17,11 +17,8 @@ Data preparation.
...
@@ -17,11 +17,8 @@ Data preparation.
Download: http://groups.inf.ed.ac.uk/ami/download/
Download: http://groups.inf.ed.ac.uk/ami/download/
Prepares metadata files (JSON) from manual annotations "segments/" using RTTM format (Oracle VAD).
Prepares metadata files (JSON) from manual annotations "segments/" using RTTM format (Oracle VAD).
Authors
* qingenz123@126.com (Qingen ZHAO) 2022
"""
"""
import
argparse
import
argparse
import
glob
import
glob
import
json
import
json
...
...
examples/ami/sd0/local/ami_splits.py
浏览文件 @
d01d7fed
...
@@ -15,10 +15,6 @@
...
@@ -15,10 +15,6 @@
AMI corpus contained 100 hours of meeting recording.
AMI corpus contained 100 hours of meeting recording.
This script returns the standard train, dev and eval split for AMI corpus.
This script returns the standard train, dev and eval split for AMI corpus.
For more information on dataset please refer to http://groups.inf.ed.ac.uk/ami/corpus/datasets.shtml
For more information on dataset please refer to http://groups.inf.ed.ac.uk/ami/corpus/datasets.shtml
Authors
* qingenz123@126.com (Qingen ZHAO) 2022
"""
"""
ALLOWED_OPTIONS
=
[
"scenario_only"
,
"full_corpus"
,
"full_corpus_asr"
]
ALLOWED_OPTIONS
=
[
"scenario_only"
,
"full_corpus"
,
"full_corpus_asr"
]
...
...
examples/ami/sd0/local/dataio.py
浏览文件 @
d01d7fed
...
@@ -13,10 +13,6 @@
...
@@ -13,10 +13,6 @@
# limitations under the License.
# limitations under the License.
"""
"""
Data reading and writing.
Data reading and writing.
Authors
* qingenz123@126.com (Qingen ZHAO) 2022
"""
"""
import
os
import
os
import
pickle
import
pickle
...
...
examples/ami/sd0/local/diarization.py
浏览文件 @
d01d7fed
...
@@ -15,10 +15,6 @@
...
@@ -15,10 +15,6 @@
This script contains basic functions used for speaker diarization.
This script contains basic functions used for speaker diarization.
This script has an optional dependency on open source sklearn library.
This script has an optional dependency on open source sklearn library.
A few sklearn functions are modified in this script as per requirement.
A few sklearn functions are modified in this script as per requirement.
Authors
* qingenz123@126.com (Qingen ZHAO) 2022
"""
"""
import
argparse
import
argparse
...
@@ -377,7 +373,7 @@ class EmbeddingMeta:
...
@@ -377,7 +373,7 @@ class EmbeddingMeta:
self
.
stats
=
(
self
.
stats
.
transpose
()
/
vect_norm
).
transpose
()
self
.
stats
=
(
self
.
stats
.
transpose
()
/
vect_norm
).
transpose
()
class
Spec
_Clust_u
norm
:
class
Spec
ClustU
norm
:
"""
"""
This class implements the spectral clustering with unnormalized affinity matrix.
This class implements the spectral clustering with unnormalized affinity matrix.
Useful when affinity matrix is based on cosine similarities.
Useful when affinity matrix is based on cosine similarities.
...
@@ -390,7 +386,7 @@ class Spec_Clust_unorm:
...
@@ -390,7 +386,7 @@ class Spec_Clust_unorm:
Example
Example
-------
-------
>>> import diarization as diar
>>> import diarization as diar
>>> clust = diar.Spec
_Clust_u
norm(min_num_spkrs=2, max_num_spkrs=10)
>>> clust = diar.Spec
ClustU
norm(min_num_spkrs=2, max_num_spkrs=10)
>>> emb = [[ 2.1, 3.1, 4.1, 4.2, 3.1],
>>> emb = [[ 2.1, 3.1, 4.1, 4.2, 3.1],
... [ 2.2, 3.1, 4.2, 4.2, 3.2],
... [ 2.2, 3.1, 4.2, 4.2, 3.2],
... [ 2.0, 3.0, 4.0, 4.1, 3.0],
... [ 2.0, 3.0, 4.0, 4.1, 3.0],
...
@@ -586,7 +582,7 @@ class Spec_Clust_unorm:
...
@@ -586,7 +582,7 @@ class Spec_Clust_unorm:
if
k_oracle
is
not
None
:
if
k_oracle
is
not
None
:
num_of_spk
=
k_oracle
num_of_spk
=
k_oracle
else
:
else
:
lambda_gap_list
=
self
.
get
EigenG
aps
(
lambdas
[
1
:
self
.
max_num_spkrs
])
lambda_gap_list
=
self
.
get
_eigen_g
aps
(
lambdas
[
1
:
self
.
max_num_spkrs
])
num_of_spk
=
(
np
.
argmax
(
num_of_spk
=
(
np
.
argmax
(
lambda_gap_list
[:
min
(
self
.
max_num_spkrs
,
len
(
lambda_gap_list
))])
lambda_gap_list
[:
min
(
self
.
max_num_spkrs
,
len
(
lambda_gap_list
))])
...
@@ -617,7 +613,7 @@ class Spec_Clust_unorm:
...
@@ -617,7 +613,7 @@ class Spec_Clust_unorm:
"""
"""
_
,
self
.
labels_
,
_
=
k_means
(
emb
,
k
)
_
,
self
.
labels_
,
_
=
k_means
(
emb
,
k
)
def
get
EigenG
aps
(
self
,
eig_vals
):
def
get
_eigen_g
aps
(
self
,
eig_vals
):
"""
"""
Returns the difference (gaps) between the Eigen values.
Returns the difference (gaps) between the Eigen values.
...
@@ -641,7 +637,7 @@ class Spec_Clust_unorm:
...
@@ -641,7 +637,7 @@ class Spec_Clust_unorm:
return
eig_vals_gap_list
return
eig_vals_gap_list
class
Spec
_
Cluster
(
SpectralClustering
):
class
SpecCluster
(
SpectralClustering
):
def
perform_sc
(
self
,
X
,
n_neighbors
=
10
):
def
perform_sc
(
self
,
X
,
n_neighbors
=
10
):
"""
"""
Performs spectral clustering using sklearn on embeddings.
Performs spectral clustering using sklearn on embeddings.
...
@@ -969,12 +965,12 @@ def do_spec_clustering(diary_obj, out_rttm_file, rec_id, k, pval, affinity_type,
...
@@ -969,12 +965,12 @@ def do_spec_clustering(diary_obj, out_rttm_file, rec_id, k, pval, affinity_type,
"""
"""
if
affinity_type
==
"cos"
:
if
affinity_type
==
"cos"
:
clust_obj
=
Spec
_Clust_u
norm
(
min_num_spkrs
=
2
,
max_num_spkrs
=
10
)
clust_obj
=
Spec
ClustU
norm
(
min_num_spkrs
=
2
,
max_num_spkrs
=
10
)
k_oracle
=
k
# use it only when oracle num of speakers
k_oracle
=
k
# use it only when oracle num of speakers
clust_obj
.
do_spec_clust
(
diary_obj
.
stats
,
k_oracle
,
pval
)
clust_obj
.
do_spec_clust
(
diary_obj
.
stats
,
k_oracle
,
pval
)
labels
=
clust_obj
.
labels_
labels
=
clust_obj
.
labels_
else
:
else
:
clust_obj
=
Spec
_
Cluster
(
clust_obj
=
SpecCluster
(
n_clusters
=
k
,
n_clusters
=
k
,
assign_labels
=
"kmeans"
,
assign_labels
=
"kmeans"
,
random_state
=
1234
,
random_state
=
1234
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录