Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
gtf35
2024-04-13 23:39:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-04-13 23:39:07 +0800
Commit
b0265b258dc9f868cdf02b8d74a6230d7b45788b
b0265b25
1 parent
983df28a
Replace torchaudio with soundfile in python-api-examples (#765)
显示空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
27 行增加
和
9 行删除
python-api-examples/speaker-identification-with-vad-non-streaming-asr.py
python-api-examples/speaker-identification-with-vad.py
python-api-examples/speaker-identification.py
python-api-examples/speaker-identification-with-vad-non-streaming-asr.py
查看文件 @
b0265b2
...
...
@@ -65,7 +65,7 @@ from typing import Dict, List, Tuple
import
numpy
as
np
import
sherpa_onnx
import
torchaudio
import
soundfile
as
sf
try
:
import
sounddevice
as
sd
...
...
@@ -357,8 +357,14 @@ def load_speaker_file(args) -> Dict[str, List[str]]:
def
load_audio
(
filename
:
str
)
->
Tuple
[
np
.
ndarray
,
int
]:
samples
,
sample_rate
=
torchaudio
.
load
(
filename
)
return
samples
[
0
]
.
contiguous
()
.
numpy
(),
sample_rate
data
,
sample_rate
=
sf
.
read
(
filename
,
always_2d
=
True
,
dtype
=
"float32"
,
)
data
=
data
[:,
0
]
# use only the first channel
samples
=
np
.
ascontiguousarray
(
data
)
return
samples
,
sample_rate
def
compute_speaker_embedding
(
...
...
python-api-examples/speaker-identification-with-vad.py
查看文件 @
b0265b2
...
...
@@ -60,7 +60,7 @@ from typing import Dict, List, Tuple
import
numpy
as
np
import
sherpa_onnx
import
torchaudio
import
soundfile
as
sf
try
:
import
sounddevice
as
sd
...
...
@@ -160,8 +160,14 @@ def load_speaker_file(args) -> Dict[str, List[str]]:
def
load_audio
(
filename
:
str
)
->
Tuple
[
np
.
ndarray
,
int
]:
samples
,
sample_rate
=
torchaudio
.
load
(
filename
)
return
samples
[
0
]
.
contiguous
()
.
numpy
(),
sample_rate
data
,
sample_rate
=
sf
.
read
(
filename
,
always_2d
=
True
,
dtype
=
"float32"
,
)
data
=
data
[:,
0
]
# use only the first channel
samples
=
np
.
ascontiguousarray
(
data
)
return
samples
,
sample_rate
def
compute_speaker_embedding
(
...
...
python-api-examples/speaker-identification.py
查看文件 @
b0265b2
...
...
@@ -52,7 +52,7 @@ from typing import Dict, List, Tuple
import
numpy
as
np
import
sherpa_onnx
import
torchaudio
import
soundfile
as
sf
try
:
import
sounddevice
as
sd
...
...
@@ -145,8 +145,14 @@ def load_speaker_file(args) -> Dict[str, List[str]]:
def
load_audio
(
filename
:
str
)
->
Tuple
[
np
.
ndarray
,
int
]:
samples
,
sample_rate
=
torchaudio
.
load
(
filename
)
return
samples
[
0
]
.
contiguous
()
.
numpy
(),
sample_rate
data
,
sample_rate
=
sf
.
read
(
filename
,
always_2d
=
True
,
dtype
=
"float32"
,
)
data
=
data
[:,
0
]
# use only the first channel
samples
=
np
.
ascontiguousarray
(
data
)
return
samples
,
sample_rate
def
compute_speaker_embedding
(
...
...
请
注册
或
登录
后发表评论