Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
2a8ffa53
Commit
2a8ffa53
authored
6 years ago
by
Mirko Wächter
Browse files
Options
Downloads
Patches
Plain Diff
SpeechObserver observers now also all recognized text
parent
0829a7ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/RobotAPI/components/units/SpeechObserver.cpp
+34
-4
34 additions, 4 deletions
source/RobotAPI/components/units/SpeechObserver.cpp
source/RobotAPI/components/units/SpeechObserver.h
+17
-3
17 additions, 3 deletions
source/RobotAPI/components/units/SpeechObserver.h
with
51 additions
and
7 deletions
source/RobotAPI/components/units/SpeechObserver.cpp
+
34
−
4
View file @
2a8ffa53
/*
* This file is part of ArmarX.
*
*
* Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
* Karlsruhe Institute of Technology (KIT), all rights reserved.
*
...
...
@@ -23,6 +23,8 @@
#include
"SpeechObserver.h"
#include
<ArmarXCore/util/json/JSONObject.h>
using
namespace
armarx
;
SpeechObserver
::
SpeechObserver
()
...
...
@@ -33,6 +35,9 @@ void SpeechObserver::onInitObserver()
{
usingTopic
(
getProperty
<
std
::
string
>
(
"TextToSpeechTopicName"
).
getValue
());
usingTopic
(
getProperty
<
std
::
string
>
(
"TextToSpeechStateTopicName"
).
getValue
());
auto
proxy
=
getObjectAdapter
()
->
addWithUUID
(
new
SpeechListenerImpl
(
this
));
getIceManager
()
->
subscribeTopic
(
proxy
,
"Speech_Commands"
);
}
void
SpeechObserver
::
onConnectObserver
()
...
...
@@ -42,12 +47,16 @@ void SpeechObserver::onConnectObserver()
offerDataFieldWithDefault
(
"TextToSpeech"
,
"TextChangeCounter"
,
Variant
(
reportTextCounter
),
"Counter for text updates"
);
offerDataFieldWithDefault
(
"TextToSpeech"
,
"State"
,
Variant
(
""
),
"Current TTS state"
);
offerDataFieldWithDefault
(
"TextToSpeech"
,
"StateChangeCounter"
,
Variant
(
reportStateCounter
),
"Counter for text updates"
);
offerDataFieldWithDefault
(
"TextToSpeech"
,
"StateChangeCounter"
,
Variant
(
reportStateCounter
),
"Counter for state updates"
);
offerChannel
(
"SpeechToText"
,
"SpeechToText channel"
);
offerDataFieldWithDefault
(
"TextToSpeech"
,
"RecognizedText"
,
Variant
(
std
::
string
()),
"Text recognized by the SpeechRecogntion"
);
}
std
::
string
SpeechObserver
::
SpeechStateToString
(
TextToSpeechStateType
state
)
{
switch
(
state
)
switch
(
state
)
{
case
eIdle
:
return
"Idle"
;
...
...
@@ -70,7 +79,7 @@ void SpeechObserver::reportState(TextToSpeechStateType state, const Ice::Current
updateChannel
(
"TextToSpeech"
);
}
void
SpeechObserver
::
reportText
(
const
std
::
string
&
text
,
const
Ice
::
Current
&
)
void
SpeechObserver
::
reportText
(
const
std
::
string
&
text
,
const
Ice
::
Current
&
c
)
{
ScopedLock
lock
(
dataMutex
);
reportTextCounter
++
;
...
...
@@ -84,3 +93,24 @@ void SpeechObserver::reportTextWithParams(const std::string& text, const Ice::St
ScopedLock
lock
(
dataMutex
);
ARMARX_WARNING
<<
"reportTextWithParams is not implemented"
;
}
SpeechListenerImpl
::
SpeechListenerImpl
(
SpeechObserver
*
obs
)
:
obs
(
obs
)
{
}
void
armarx
::
SpeechListenerImpl
::
reportText
(
const
std
::
string
&
text
,
const
Ice
::
Current
&
)
{
ScopedLock
lock
(
dataMutex
);
JSONObject
json
;
json
.
fromString
(
text
);
obs
->
setDataField
(
"SpeechToText"
,
"RecognizedText"
,
Variant
(
json
.
getString
(
"text"
)));
}
void
armarx
::
SpeechListenerImpl
::
reportTextWithParams
(
const
std
::
string
&
,
const
Ice
::
StringSeq
&
,
const
Ice
::
Current
&
)
{
ScopedLock
lock
(
dataMutex
);
ARMARX_WARNING
<<
deactivateSpam
(
100
)
<<
"reportTextWithParams is not implemented"
;
}
This diff is collapsed.
Click to expand it.
source/RobotAPI/components/units/SpeechObserver.h
+
17
−
3
View file @
2a8ffa53
/*
* This file is part of ArmarX.
*
*
* Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
* Karlsruhe Institute of Technology (KIT), all rights reserved.
*
...
...
@@ -39,11 +39,25 @@ namespace armarx
defineOptionalProperty
<
std
::
string
>
(
"TextToSpeechStateTopicName"
,
"TextToSpeechState"
,
"Name of the TextToSpeechStateTopic"
);
}
};
class
SpeechObserver
;
class
SpeechListenerImpl
:
public
TextListenerInterface
{
public:
SpeechListenerImpl
(
SpeechObserver
*
obs
);
protected:
SpeechObserver
*
obs
;
Mutex
dataMutex
;
// TextListenerInterface interface
public:
void
reportText
(
const
std
::
string
&
,
const
Ice
::
Current
&
)
override
;
void
reportTextWithParams
(
const
std
::
string
&
,
const
Ice
::
StringSeq
&
,
const
Ice
::
Current
&
)
override
;
};
class
SpeechObserver
:
virtual
public
Observer
,
virtual
public
SpeechObserverInterface
virtual
public
Observer
,
virtual
public
SpeechObserverInterface
{
friend
class
SpeechListenerImpl
;
public:
SpeechObserver
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment