Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Speech
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
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
Skills
Speech
Commits
4589dde6
Commit
4589dde6
authored
6 months ago
by
Timo Birr
Browse files
Options
Downloads
Patches
Plain Diff
Fixed providers so they do not crash on memory restart
parent
251a3e2b
Branches
fix/better-failsafety
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/asr_base/asr_base/audio_memory_asr.py
+10
-2
10 additions, 2 deletions
python/asr_base/asr_base/audio_memory_asr.py
python/asr_base/asr_base/base.py
+11
-5
11 additions, 5 deletions
python/asr_base/asr_base/base.py
with
21 additions
and
7 deletions
python/asr_base/asr_base/audio_memory_asr.py
+
10
−
2
View file @
4589dde6
...
...
@@ -5,6 +5,7 @@ from abc import ABC
from
time
import
sleep
import
numpy
as
np
from
Ice
import
LocalException
from
armarx_audio.aron.audio
import
Audio
from
armarx_audio.audio_reader
import
AudioReader
,
AUDIO_CORE_SEGMENT_ID
...
...
@@ -34,8 +35,15 @@ class AudioMemoryASR(BaseASR, ABC):
while
not
hasattr
(
self
,
'
_audio_reader
'
):
sleep
(
1
)
# Wait for Audio Memory to connect. Unfortunately, recorder_thread might get started before.
print
(
'
Subscribing to updates from
'
,
self
.
_audio_input_entity
)
self
.
_audio_reader
.
poll_updates
(
entity_id
=
self
.
_audio_input_entity
,
callback
=
self
.
_receive_audio_from_memory
)
while
True
:
try
:
self
.
_audio_reader
.
poll_updates
(
entity_id
=
self
.
_audio_input_entity
,
callback
=
self
.
_receive_audio_from_memory
)
except
LocalException
as
e
:
self
.
_audio_reader
=
AudioReader
.
from_mns
(
self
.
_mns
)
def
_receive_audio_from_memory
(
self
,
audio
:
Audio
):
waveform
:
np
.
ndarray
=
np
.
stack
([
np
.
squeeze
(
c
.
waveform
)
...
...
This diff is collapsed.
Click to expand it.
python/asr_base/asr_base/base.py
+
11
−
5
View file @
4589dde6
...
...
@@ -3,11 +3,12 @@ import logging
import
threading
from
typing
import
Optional
from
Ice
import
LocalException
from
armarx_memory.client
import
MemoryNameSystem
from
armarx_memory.core
import
MemoryID
from
armarx_memory.segments.SpeechToText
import
SpeechToTextWriter
logger
=
logging
.
getLogger
(
__name__
)
class
BaseASR
(
abc
.
ABC
):
...
...
@@ -17,10 +18,11 @@ class BaseASR(abc.ABC):
channel
=
0
):
super
().
__init__
()
log
ger
.
info
(
f
"
Getting MNS.
"
)
self
.
log
=
logging
.
getLogger
(
name
=
output_provider_name
)
self
.
log
.
info
(
f
"
Getting MNS.
"
)
self
.
_mns
=
MemoryNameSystem
.
wait_for_mns
()
self
.
_writer
=
SpeechToTextWriter
.
from_mns
(
self
.
_mns
,
wait
=
True
)
self
.
_output_entity_id
=
self
.
_writer
.
make_entity_name
(
output_provider_name
)
self
.
_recorder_thread
=
threading
.
Thread
(
target
=
self
.
recording_loop
,
daemon
=
True
)
...
...
@@ -40,8 +42,12 @@ class BaseASR(abc.ABC):
pass
def
publish_hypothesis
(
self
,
hypo
:
str
,
confidence
:
float
=
1
,
speaker
:
Optional
[
MemoryID
]
=
None
):
logger
.
info
(
f
"
Committing hypothesis
'
{
hypo
}
'
with confidence
{
confidence
:
.
4
f
}
.
"
)
self
.
_writer
.
commit
(
self
.
_output_entity_id
,
text
=
hypo
,
confidence
=
confidence
,
speaker
=
speaker
)
try
:
self
.
_writer
.
commit
(
self
.
_output_entity_id
,
text
=
hypo
,
confidence
=
confidence
,
speaker
=
speaker
)
self
.
log
.
info
(
f
"
Committing hypothesis
'
{
hypo
}
'
.
"
)
except
LocalException
as
e
:
self
.
_writer
=
SpeechToTextWriter
.
from_mns
(
self
.
_mns
,
wait
=
True
)
@classmethod
def
add_argparse_args
(
cls
,
parser
):
...
...
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