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
OpenDAS
Torchaudio
Commits
8202c798
Unverified
Commit
8202c798
authored
Nov 09, 2021
by
nateanl
Committed by
GitHub
Nov 09, 2021
Browse files
[fbsync] Enable CLANGFORMAT (#1999)
parent
e7ea820e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
16 deletions
+19
-16
examples/libtorchaudio/augmentation/main.cpp
examples/libtorchaudio/augmentation/main.cpp
+5
-4
examples/libtorchaudio/speech_recognition/transcribe.cpp
examples/libtorchaudio/speech_recognition/transcribe.cpp
+6
-5
examples/libtorchaudio/speech_recognition/transcribe_list.cpp
...ples/libtorchaudio/speech_recognition/transcribe_list.cpp
+8
-7
No files found.
examples/libtorchaudio/augmentation/main.cpp
View file @
8202c798
#include <torch/script.h>
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
4
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" <JIT_OBJECT> <INPUT_FILE> <OUTPUT_FILE>"
<<
std
::
endl
;
if
(
argc
!=
4
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" <JIT_OBJECT> <INPUT_FILE> <OUTPUT_FILE>"
<<
std
::
endl
;
return
-
1
;
}
...
...
@@ -10,12 +11,12 @@ int main(int argc, char* argv[]) {
std
::
cout
<<
"Loading module from: "
<<
argv
[
1
]
<<
std
::
endl
;
try
{
module
=
torch
::
jit
::
load
(
argv
[
1
]);
}
catch
(
const
c10
::
Error
&
error
)
{
}
catch
(
const
c10
::
Error
&
error
)
{
std
::
cerr
<<
"Failed to load the module:"
<<
error
.
what
()
<<
std
::
endl
;
return
-
1
;
}
std
::
cout
<<
"Performing the process ..."
<<
std
::
endl
;
module
.
forward
({
c10
::
IValue
(
argv
[
2
]),
c10
::
IValue
(
argv
[
3
])});
std
::
cout
<<
"Done."
<<
std
::
endl
;
std
::
cout
<<
"Done."
<<
std
::
endl
;
}
examples/libtorchaudio/speech_recognition/transcribe.cpp
View file @
8202c798
...
...
@@ -2,7 +2,8 @@
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
3
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" <JIT_OBJECT_DIR> <INPUT_AUDIO_FILE>"
<<
std
::
endl
;
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" <JIT_OBJECT_DIR> <INPUT_AUDIO_FILE>"
<<
std
::
endl
;
return
-
1
;
}
...
...
@@ -10,19 +11,19 @@ int main(int argc, char* argv[]) {
std
::
cout
<<
"Loading module from: "
<<
argv
[
1
]
<<
std
::
endl
;
try
{
loader
=
torch
::
jit
::
load
(
std
::
string
(
argv
[
1
])
+
"/loader.zip"
);
}
catch
(
const
c10
::
Error
&
error
)
{
}
catch
(
const
c10
::
Error
&
error
)
{
std
::
cerr
<<
"Failed to load the module:"
<<
error
.
what
()
<<
std
::
endl
;
return
-
1
;
}
try
{
encoder
=
torch
::
jit
::
load
(
std
::
string
(
argv
[
1
])
+
"/encoder.zip"
);
}
catch
(
const
c10
::
Error
&
error
)
{
}
catch
(
const
c10
::
Error
&
error
)
{
std
::
cerr
<<
"Failed to load the module:"
<<
error
.
what
()
<<
std
::
endl
;
return
-
1
;
}
try
{
decoder
=
torch
::
jit
::
load
(
std
::
string
(
argv
[
1
])
+
"/decoder.zip"
);
}
catch
(
const
c10
::
Error
&
error
)
{
}
catch
(
const
c10
::
Error
&
error
)
{
std
::
cerr
<<
"Failed to load the module:"
<<
error
.
what
()
<<
std
::
endl
;
return
-
1
;
}
...
...
@@ -34,5 +35,5 @@ int main(int argc, char* argv[]) {
std
::
cout
<<
"Generating the transcription"
<<
std
::
endl
;
auto
result
=
decoder
.
forward
({
emission
});
std
::
cout
<<
result
.
toString
()
->
string
()
<<
std
::
endl
;
std
::
cout
<<
"Done."
<<
std
::
endl
;
std
::
cout
<<
"Done."
<<
std
::
endl
;
}
examples/libtorchaudio/speech_recognition/transcribe_list.cpp
View file @
8202c798
#include <chrono>
#include <torch/script.h>
#include <chrono>
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
4
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
"<JIT_OBJECT_DIR> <FILE_LIST> <OUTPUT_DIR>
\n
"
<<
std
::
endl
;
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
"<JIT_OBJECT_DIR> <FILE_LIST> <OUTPUT_DIR>
\n
"
<<
std
::
endl
;
std
::
cerr
<<
"<FILE_LIST> is `<ID>
\t
<PATH>
\t
<TRANSCRIPTION>`"
<<
std
::
endl
;
return
-
1
;
}
...
...
@@ -13,19 +14,19 @@ int main(int argc, char* argv[]) {
std
::
cout
<<
"Loading module from: "
<<
argv
[
1
]
<<
std
::
endl
;
try
{
loader
=
torch
::
jit
::
load
(
std
::
string
(
argv
[
1
])
+
"/loader.zip"
);
}
catch
(
const
c10
::
Error
&
error
)
{
}
catch
(
const
c10
::
Error
&
error
)
{
std
::
cerr
<<
"Failed to load the module:"
<<
error
.
what
()
<<
std
::
endl
;
return
-
1
;
}
try
{
encoder
=
torch
::
jit
::
load
(
std
::
string
(
argv
[
1
])
+
"/encoder.zip"
);
}
catch
(
const
c10
::
Error
&
error
)
{
}
catch
(
const
c10
::
Error
&
error
)
{
std
::
cerr
<<
"Failed to load the module:"
<<
error
.
what
()
<<
std
::
endl
;
return
-
1
;
}
try
{
decoder
=
torch
::
jit
::
load
(
std
::
string
(
argv
[
1
])
+
"/decoder.zip"
);
}
catch
(
const
c10
::
Error
&
error
)
{
}
catch
(
const
c10
::
Error
&
error
)
{
std
::
cerr
<<
"Failed to load the module:"
<<
error
.
what
()
<<
std
::
endl
;
return
-
1
;
}
...
...
@@ -37,7 +38,7 @@ int main(int argc, char* argv[]) {
std
::
string
line
;
std
::
chrono
::
milliseconds
t_encode
(
0
);
std
::
chrono
::
milliseconds
t_decode
(
0
);
while
(
std
::
getline
(
input_file
,
line
))
{
while
(
std
::
getline
(
input_file
,
line
))
{
std
::
istringstream
iline
(
line
);
std
::
string
id
;
std
::
string
path
;
...
...
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