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
Fangjun Kuang
2024-03-09 18:15:03 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-03-09 18:15:03 +0800
Commit
3232dff2cf94a041a87c11c2be8b507a58c7ab43
3232dff2
1 parent
ac43c2d7
Support user provided data in tts callback. (#653)
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
36 行增加
和
2 行删除
sherpa-onnx/c-api/c-api.cc
sherpa-onnx/c-api/c-api.h
sherpa-onnx/python/csrc/faked-alsa.cc
sherpa-onnx/c-api/c-api.cc
查看文件 @
3232dff
...
...
@@ -636,6 +636,32 @@ const SherpaOnnxGeneratedAudio *SherpaOnnxOfflineTtsGenerateWithCallback(
return
ans
;
}
const
SherpaOnnxGeneratedAudio
*
SherpaOnnxOfflineTtsGenerateWithCallbackWithArg
(
const
SherpaOnnxOfflineTts
*
tts
,
const
char
*
text
,
int32_t
sid
,
float
speed
,
SherpaOnnxGeneratedAudioCallbackWithArg
callback
,
void
*
arg
)
{
auto
wrapper
=
[
callback
,
arg
](
const
float
*
samples
,
int32_t
n
)
{
callback
(
samples
,
n
,
arg
);
};
sherpa_onnx
::
GeneratedAudio
audio
=
tts
->
impl
->
Generate
(
text
,
sid
,
speed
,
wrapper
);
if
(
audio
.
samples
.
empty
())
{
return
nullptr
;
}
SherpaOnnxGeneratedAudio
*
ans
=
new
SherpaOnnxGeneratedAudio
;
float
*
samples
=
new
float
[
audio
.
samples
.
size
()];
std
::
copy
(
audio
.
samples
.
begin
(),
audio
.
samples
.
end
(),
samples
);
ans
->
samples
=
samples
;
ans
->
n
=
audio
.
samples
.
size
();
ans
->
sample_rate
=
audio
.
sample_rate
;
return
ans
;
}
void
SherpaOnnxDestroyOfflineTtsGeneratedAudio
(
const
SherpaOnnxGeneratedAudio
*
p
)
{
if
(
p
)
{
...
...
sherpa-onnx/c-api/c-api.h
查看文件 @
3232dff
...
...
@@ -644,6 +644,9 @@ SHERPA_ONNX_API typedef struct SherpaOnnxGeneratedAudio {
typedef
void
(
*
SherpaOnnxGeneratedAudioCallback
)(
const
float
*
samples
,
int32_t
n
);
typedef
void
(
*
SherpaOnnxGeneratedAudioCallbackWithArg
)(
const
float
*
samples
,
int32_t
n
,
void
*
arg
);
SHERPA_ONNX_API
typedef
struct
SherpaOnnxOfflineTts
SherpaOnnxOfflineTts
;
// Create an instance of offline TTS. The user has to use DestroyOfflineTts()
...
...
@@ -678,6 +681,13 @@ SherpaOnnxOfflineTtsGenerateWithCallback(
const
SherpaOnnxOfflineTts
*
tts
,
const
char
*
text
,
int32_t
sid
,
float
speed
,
SherpaOnnxGeneratedAudioCallback
callback
);
// Same as SherpaOnnxGeneratedAudioCallback but you can pass an additional
// `void* arg` to the callback.
SHERPA_ONNX_API
const
SherpaOnnxGeneratedAudio
*
SherpaOnnxOfflineTtsGenerateWithCallbackWithArg
(
const
SherpaOnnxOfflineTts
*
tts
,
const
char
*
text
,
int32_t
sid
,
float
speed
,
SherpaOnnxGeneratedAudioCallbackWithArg
callback
,
void
*
arg
);
SHERPA_ONNX_API
void
SherpaOnnxDestroyOfflineTtsGeneratedAudio
(
const
SherpaOnnxGeneratedAudio
*
p
);
...
...
sherpa-onnx/python/csrc/faked-alsa.cc
查看文件 @
3232dff
...
...
@@ -43,5 +43,3 @@ void PybindAlsa(py::module *m) {
}
}
// namespace sherpa_onnx
#endif // SHERPA_ONNX_PYTHON_CSRC_FAKED_ALSA_H_
...
...
请
注册
或
登录
后发表评论