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
2023-10-21 14:43:11 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2023-10-21 14:43:11 +0800
Commit
b582f6c1151a4c0059f6d88b83ee3772b9c2ca0e
b582f6c1
1 parent
19377177
support specifying output filename (#380)
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
18 行增加
和
9 行删除
mfc-examples/NonStreamingTextToSpeech/NonStreamingTextToSpeech.rc
mfc-examples/NonStreamingTextToSpeech/NonStreamingTextToSpeechDlg.cpp
mfc-examples/NonStreamingTextToSpeech/NonStreamingTextToSpeechDlg.h
mfc-examples/NonStreamingTextToSpeech/Resource.h
mfc-examples/NonStreamingTextToSpeech/NonStreamingTextToSpeech.rc
查看文件 @
b582f6c
B
// Microsoft Visual C++ generated resource script.
...
...
mfc-examples/NonStreamingTextToSpeech/NonStreamingTextToSpeechDlg.cpp
查看文件 @
b582f6c
...
...
@@ -146,6 +146,7 @@ void CNonStreamingTextToSpeechDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control
(
pDX
,
IDC_SPEED
,
speed_
);
DDX_Control
(
pDX
,
IDOK
,
generate_btn_
);
DDX_Control
(
pDX
,
IDC_TEXT
,
my_text_
);
DDX_Control
(
pDX
,
IDC_OUTPUT_FILENAME
,
output_filename_
);
}
BEGIN_MESSAGE_MAP
(
CNonStreamingTextToSpeechDlg
,
CDialogEx
)
...
...
@@ -251,6 +252,7 @@ void CNonStreamingTextToSpeechDlg::Init() {
InitHint
();
speaker_id_
.
SetWindowText
(
Utf8ToUtf16
(
"0"
).
c_str
());
speed_
.
SetWindowText
(
Utf8ToUtf16
(
"1.0"
).
c_str
());
output_filename_
.
SetWindowText
(
Utf8ToUtf16
(
"./generated.wav"
).
c_str
());
bool
ok
=
true
;
std
::
string
error_message
=
"--------------------"
;
...
...
@@ -313,6 +315,10 @@ void CNonStreamingTextToSpeechDlg::Init() {
}
static
std
::
string
ToString
(
const
CString
&
s
)
{
CT2CA
pszConvertedAnsiString
(
s
);
return
std
::
string
(
pszConvertedAnsiString
);
}
void
CNonStreamingTextToSpeechDlg
::
OnBnClickedOk
()
{
// TODO: Add your control notification handler code here
...
...
@@ -325,32 +331,32 @@ void CNonStreamingTextToSpeechDlg::OnBnClickedOk() {
}
speed_
.
GetWindowText
(
s
);
float
speed
=
_ttof
(
s
);
float
speed
=
static_cast
<
float
>
(
_ttof
(
s
)
);
if
(
speed
<
0
)
{
AfxMessageBox
(
Utf8ToUtf16
(
"Please input a valid speed"
).
c_str
(),
MB_OK
);
return
;
}
my_text_
.
GetWindowText
(
s
);
CT2CA
pszConvertedAnsiString
(
s
);
std
::
string
ss
(
pszConvertedAnsiString
);
std
::
string
ss
=
ToString
(
s
);
if
(
ss
.
empty
())
{
AfxMessageBox
(
Utf8ToUtf16
(
"Please input your text"
).
c_str
(),
MB_OK
);
return
;
}
const
SherpaOnnxGeneratedAudio
*
audio
=
const
SherpaOnnxGeneratedAudio
*
audio
=
SherpaOnnxOfflineTtsGenerate
(
tts_
,
ss
.
c_str
(),
speaker_id
,
speed
);
std
::
string
filename
=
"./generated.wav"
;
int
ok
=
SherpaOnnxWriteWave
(
audio
->
samples
,
audio
->
n
,
audio
->
sample_rate
,
output_filename_
.
GetWindowText
(
s
);
std
::
string
filename
=
ToString
(
s
);
int
ok
=
SherpaOnnxWriteWave
(
audio
->
samples
,
audio
->
n
,
audio
->
sample_rate
,
filename
.
c_str
());
SherpaOnnxDestroyOfflineTtsGeneratedAudio
(
audio
);
if
(
ok
)
{
AfxMessageBox
(
Utf8ToUtf16
(
"Saved to ./generated.wav
successfully"
).
c_str
(),
MB_OK
);
AfxMessageBox
(
Utf8ToUtf16
(
std
::
string
(
"Saved to "
)
+
filename
+
"
successfully"
).
c_str
(),
MB_OK
);
}
else
{
AfxMessageBox
(
Utf8ToUtf16
(
"Failed to save to ./generated.wav"
).
c_str
(),
MB_OK
);
AfxMessageBox
(
Utf8ToUtf16
(
std
::
string
(
"Failed to save to "
)
+
filename
).
c_str
(),
MB_OK
);
}
//CDialogEx::OnOK();
...
...
mfc-examples/NonStreamingTextToSpeech/NonStreamingTextToSpeechDlg.h
查看文件 @
b582f6c
...
...
@@ -45,4 +45,5 @@ protected:
SherpaOnnxOfflineTts
*
tts_
;
CEdit
my_text_
;
CEdit
output_filename_
;
};
...
...
mfc-examples/NonStreamingTextToSpeech/Resource.h
查看文件 @
b582f6c
...
...
@@ -11,6 +11,8 @@
#define IDC_SPEED 1003
#define IDC_TEXT 1004
#define IDC_HINT 1005
#define IDC_EDIT1 1006
#define IDC_OUTPUT_FILENAME 1006
// Next default values for new objects
//
...
...
@@ -18,7 +20,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 100
6
#define _APS_NEXT_CONTROL_VALUE 100
7
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
...
...
请
注册
或
登录
后发表评论