Skip to content

Commit 2dbe128

Browse files
error fixes: crashes due to invalid gesture name
1 parent b7b5e69 commit 2dbe128

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

app/src/main/java/com/sidharth/lg_motion/util/SpeechLandmarkerResultParser.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ object SpeechLandmarkerResultParser {
3737
}
3838

3939
private val faceGestureMap = mapOf(
40+
"null" to "null",
4041
"Brow Down Left" to "browDownLeft",
4142
"Brow Down Right" to "browDownRight",
4243
"Brow Inner Up" to "browInnerUp",
@@ -100,21 +101,21 @@ object SpeechLandmarkerResultParser {
100101

101102
val idleConfidence = blendshapes.getValue("neutral")
102103
val moveNorthConfidence =
103-
blendshapes.getValue(faceGestureMap.getValue(properties.moveNorthGesture))
104+
blendshapes.getOrDefault(faceGestureMap.getValue(properties.moveNorthGesture), 0.0F)
104105
val moveSouthConfidence =
105-
blendshapes.getValue(faceGestureMap.getValue(properties.moveSouthGesture))
106+
blendshapes.getOrDefault(faceGestureMap.getValue(properties.moveSouthGesture), 0.0F)
106107
val moveEastConfidence =
107-
blendshapes.getValue(faceGestureMap.getValue(properties.moveEastGesture))
108+
blendshapes.getOrDefault(faceGestureMap.getValue(properties.moveEastGesture), 0.0F)
108109
val moveWestConfidence =
109-
blendshapes.getValue(faceGestureMap.getValue(properties.moveWestGesture))
110+
blendshapes.getOrDefault(faceGestureMap.getValue(properties.moveWestGesture), 0.0F)
110111
val rotateLeftConfidence =
111-
blendshapes.getValue(faceGestureMap.getValue(properties.rotateLeftGesture))
112+
blendshapes.getOrDefault(faceGestureMap.getValue(properties.rotateLeftGesture), 0.0F)
112113
val rotateRightConfidence =
113-
blendshapes.getValue(faceGestureMap.getValue(properties.rotateRightGesture))
114+
blendshapes.getOrDefault(faceGestureMap.getValue(properties.rotateRightGesture), 0.0F)
114115
val zoomInConfidence =
115-
blendshapes.getValue(faceGestureMap.getValue(properties.zoomInGesture))
116+
blendshapes.getOrDefault(faceGestureMap.getValue(properties.zoomInGesture), 0.0F)
116117
val zoomOutConfidence =
117-
blendshapes.getValue(faceGestureMap.getValue(properties.zoomOutGesture))
118+
blendshapes.getOrDefault(faceGestureMap.getValue(properties.zoomOutGesture), 0.0F)
118119

119120
return when {
120121
moveNorthConfidence >= properties.moveNorthSensitivity -> LiquidGalaxyManager.State.MOVE_NORTH

0 commit comments

Comments
 (0)