Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
RapidASR
Commits
978a6781
Commit
978a6781
authored
Feb 26, 2023
by
mayong
Browse files
update files
parent
3aad0a8f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
19 deletions
+26
-19
cpp_onnx/include/Audio.h
cpp_onnx/include/Audio.h
+1
-1
cpp_onnx/src/lib/Audio.cpp
cpp_onnx/src/lib/Audio.cpp
+4
-1
cpp_onnx/src/lib/paraformer_onnx.cpp
cpp_onnx/src/lib/paraformer_onnx.cpp
+16
-16
cpp_onnx/tester/tester.cpp
cpp_onnx/tester/tester.cpp
+5
-1
No files found.
cpp_onnx/include/Audio.h
View file @
978a6781
...
...
@@ -43,7 +43,7 @@ class Audio {
Audio
(
int
data_type
,
int
size
);
~
Audio
();
void
disp
();
void
loadwav
(
const
char
*
filename
);
bool
loadwav
(
const
char
*
filename
);
int
fetch_chunck
(
float
*&
dout
,
int
len
);
int
fetch
(
float
*&
dout
,
int
&
len
,
int
&
flag
);
void
padding
();
...
...
cpp_onnx/src/lib/Audio.cpp
View file @
978a6781
...
...
@@ -112,7 +112,7 @@ void Audio::disp()
speech_len
);
}
void
Audio
::
loadwav
(
const
char
*
filename
)
bool
Audio
::
loadwav
(
const
char
*
filename
)
{
if
(
speech_buff
!=
NULL
)
{
...
...
@@ -124,6 +124,8 @@ void Audio::loadwav(const char *filename)
FILE
*
fp
;
fp
=
fopen
(
filename
,
"rb"
);
if
(
fp
==
nullptr
)
return
false
;
fseek
(
fp
,
0
,
SEEK_END
);
uint32_t
nFileLen
=
ftell
(
fp
);
fseek
(
fp
,
44
,
SEEK_SET
);
...
...
@@ -150,6 +152,7 @@ void Audio::loadwav(const char *filename)
AudioFrame
*
frame
=
new
AudioFrame
(
speech_len
);
frame_queue
.
push
(
frame
);
return
true
;
}
int
Audio
::
fetch_chunck
(
float
*&
dout
,
int
len
)
...
...
cpp_onnx/src/lib/paraformer_onnx.cpp
View file @
978a6781
...
...
@@ -162,28 +162,28 @@ string ModelImp::forward(float* din, int len, int flag)
input_onnx
.
emplace_back
(
std
::
move
(
onnx_feats
));
input_onnx
.
emplace_back
(
std
::
move
(
onnx_feats_len
));
//auto output = m_session_encoder->Run(run_option,
// m_strEncInputName.data(),
// input_onnx.data(),
// m_strEncInputName.size(),
// m_strEncOutputName.data(),
// m_strEncOutputName.size()
//);
string
result
;
try
{
auto
outputTensor
=
m_session
->
Run
(
run_option
,
m_szInputNames
.
data
(),
input_onnx
.
data
(),
m_szInputNames
.
size
(),
m_szOutputNames
.
data
(),
m_szOutputNames
.
size
());
//assert(outputTensor.size() == 1 && outputTensor[0].IsTensor());
std
::
vector
<
int64_t
>
outputShape
=
outputTensor
[
0
].
GetTensorTypeAndShapeInfo
().
GetShape
();
auto
outputTensor
=
m_session
->
Run
(
run_option
,
m_szInputNames
.
data
(),
input_onnx
.
data
(),
m_szInputNames
.
size
(),
m_szOutputNames
.
data
(),
m_szOutputNames
.
size
());
//assert(outputTensor.size() == 1 && outputTensor[0].IsTensor());
std
::
vector
<
int64_t
>
outputShape
=
outputTensor
[
0
].
GetTensorTypeAndShapeInfo
().
GetShape
();
int64_t
outputCount
=
std
::
accumulate
(
outputShape
.
begin
(),
outputShape
.
end
(),
1
,
std
::
multiplies
<
int64_t
>
());
float
*
floatData
=
outputTensor
[
0
].
GetTensorMutableData
<
float
>
();
auto
encoder_out_lens
=
outputTensor
[
1
].
GetTensorMutableData
<
int64_t
>
();
//float* floatSize = outputTensor[1].GetTensorMutableData<float>();
//std::vector<float> out_data(floatArray, floatArray + outputCount);
result
=
greedy_search
(
floatData
,
*
encoder_out_lens
);
}
catch
(...)
{
result
=
""
;
}
int64_t
outputCount
=
std
::
accumulate
(
outputShape
.
begin
(),
outputShape
.
end
(),
1
,
std
::
multiplies
<
int64_t
>
());
float
*
floatData
=
outputTensor
[
0
].
GetTensorMutableData
<
float
>
();
auto
encoder_out_lens
=
outputTensor
[
1
].
GetTensorMutableData
<
int64_t
>
();
//float* floatSize = outputTensor[1].GetTensorMutableData<float>();
//std::vector<float> out_data(floatArray, floatArray + outputCount);
string
result
=
greedy_search
(
floatData
,
*
encoder_out_lens
);
if
(
in
)
delete
in
;
...
...
cpp_onnx/tester/tester.cpp
View file @
978a6781
...
...
@@ -20,7 +20,11 @@ int main(int argc, char *argv[])
}
struct
timeval
start
,
end
;
Audio
audio
(
0
);
audio
.
loadwav
(
argv
[
2
]);
if
(
!
audio
.
loadwav
(
argv
[
2
]))
{
printf
(
"cannot load %s
\n
"
,
argv
[
2
]);
return
-
1
;
}
audio
.
disp
();
gettimeofday
(
&
start
,
NULL
);
Model
*
mm
=
create_model
(
argv
[
1
],
3
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment