Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Hertz-Lab
Research
Intelligent Museum
Language Identifier
Commits
923492cd
Commit
923492cd
authored
Dec 14, 2021
by
Dan Wilcox
Browse files
pass script in via --execute command arg, remove script from repo
parent
2f8e4ee6
Changes
4
Hide whitespace changes
Inline
Side-by-side
bin/data/send_languages.sh
deleted
100755 → 0
View file @
2f8e4ee6
http
-v
-j
POST https://thingsboard.zkm.de/api/v1/rFKmcjtHSLgVvrT6NaCB/telemetry
$*
src/Commandline.cpp
View file @
923492cd
...
...
@@ -33,6 +33,7 @@ bool Commandline::parse(int argc, char **argv) {
bool
autostop
=
false
;
bool
verbose
=
false
;
bool
version
=
false
;
std
::
string
command
=
""
;
parser
.
add_option
(
"-s,--senders"
,
senders
,
"OSC sender addr:port host pairs, ex.
\"
192.168.0.100:5555
\"
"
...
...
@@ -50,6 +51,7 @@ bool Commandline::parse(int argc, char **argv) {
ofToString
(
ofApp
::
modelSampleRate
)
+
", default "
+
ofToString
(
app
->
sampleRate
));
parser
.
add_flag
(
"--nolisten"
,
nolisten
,
"do not listen on start"
);
parser
.
add_flag
(
"--autostop"
,
autostop
,
"stop listening automatically after detection"
);
parser
.
add_option
(
"-e,--execute"
,
command
,
"command to execute on detection with key=value pair args"
);
parser
.
add_flag
(
"-v,--verbose"
,
verbose
,
"verbose printing"
);
parser
.
add_flag
(
"--version"
,
version
,
"print version and exit"
);
...
...
@@ -199,6 +201,11 @@ bool Commandline::parse(int argc, char **argv) {
app
->
autostop
=
true
;
}
// command
if
(
command
!=
""
)
{
app
->
command
=
command
;
}
return
true
;
}
...
...
src/ofApp.cpp
View file @
923492cd
...
...
@@ -128,16 +128,6 @@ void ofApp::setup() {
ofLogVerbose
(
PACKAGE
)
<<
"============================"
;
}
std
::
string
resultTOString
(
Labels
labelsMap
,
std
::
vector
<
float
>
outputVector
){
std
::
string
result
;
for
(
size_t
i
=
0
;
i
<
outputVector
.
size
();
i
++
)
{
result
.
append
(
labelsMap
[
i
]
+
"="
+
std
::
to_string
(
outputVector
[
i
])
+
" "
);
}
return
result
;
}
//--------------------------------------------------------------
void
ofApp
::
update
()
{
...
...
@@ -169,19 +159,22 @@ void ofApp::update() {
bool
detected
=
false
;
if
(
prob
>=
minConfidence
)
{
displayLabel
=
labelsMap
[
argMax
];
bool
isGerman
=
(
displayLabel
.
compare
(
"german"
)
==
0
)
?
true
:
false
;
std
::
string
cmd_args
=
resultTOString
(
labelsMap
,
outputVector
);
cmd_args
.
append
(
"selected="
+
displayLabel
);
cmd_args
.
append
(
"isGerman="
+
std
::
to_string
(
isGerman
));
std
::
string
cmd
=
ofToDataPath
(
"send_languages.sh"
)
+
" "
+
cmd_args
;
ofLog
()
<<
cmd
;
ofSystem
(
cmd
);
// send osc
ofxOscMessage
message
;
message
.
setAddress
(
"/lang"
);
message
.
addIntArg
(
argMax
);
message
.
addStringArg
(
labelsMap
[
argMax
]
);
message
.
addStringArg
(
displayLabel
);
message
.
addFloatArg
(
prob
*
100
);
for
(
auto
sender
:
senders
)
{
sender
->
sendMessage
(
message
);}
// execute command?
if
(
command
!=
""
)
{
std
::
string
params
=
+
"selected="
+
displayLabel
+
" "
+
resultToString
(
outputVector
);
ofLogVerbose
(
PACKAGE
)
<<
command
<<
" "
<<
params
<<
" &"
;
ofSystem
(
command
+
" "
+
params
+
" &"
);
}
detected
=
true
;
}
else
{
...
...
@@ -481,3 +474,15 @@ void ofApp::oscReceived(const ofxOscMessage &message) {
}
}
}
//--------------------------------------------------------------
std
::
string
ofApp
::
resultToString
(
std
::
vector
<
float
>
outputVector
)
{
std
::
string
result
=
""
;
for
(
size_t
i
=
0
;
i
<
outputVector
.
size
();
i
++
)
{
result
+=
labelsMap
[
i
]
+
"="
+
std
::
to_string
(
outputVector
[
i
]);
if
(
i
<
outputVector
.
size
()
-
1
)
{
result
+=
" "
;
}
}
return
result
;
}
src/ofApp.h
View file @
923492cd
...
...
@@ -65,6 +65,9 @@ class ofApp : public ofBaseApp {
/// osc receiver callback
void
oscReceived
(
const
ofxOscMessage
&
message
);
/// convert model results into a key=value string seperated by spaces
std
::
string
resultToString
(
std
::
vector
<
float
>
outputVector
);
// audio
ofSoundStream
soundStream
;
int
inputDevice
=
-
1
;
// -1 means search for default device
...
...
@@ -126,4 +129,7 @@ class ofApp : public ofBaseApp {
ofxOscReceiver
receiver
;
int
port
=
9898
;
bool
recordingStarted
=
false
;
// optional command to run on detection
std
::
string
command
=
""
;
};
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