Skip to content

Commit

Permalink
fixed setting speech type (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick authored Nov 12, 2023
1 parent d5b3f49 commit 43416e0
Showing 1 changed file with 60 additions and 12 deletions.
72 changes: 60 additions & 12 deletions src/main/java/org/myrobotlab/service/InMoov2.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.myrobotlab.service.abstracts.AbstractSpeechSynthesis;
import org.myrobotlab.service.config.InMoov2Config;
import org.myrobotlab.service.config.OpenCVConfig;
import org.myrobotlab.service.config.ServiceConfig;
import org.myrobotlab.service.config.SpeechSynthesisConfig;
import org.myrobotlab.service.data.JoystickData;
import org.myrobotlab.service.data.LedDisplayData;
import org.myrobotlab.service.data.Locale;
Expand Down Expand Up @@ -913,6 +913,19 @@ public OpenCVData onOpenCVData(OpenCVData data) {
// FIXME - publish event with or without data ? String file reference
return data;
}

/**
* onPeak volume callback TODO - maybe make it variable with volume ?
*
* @param volume
*/
public void onPeak(double volume) {
if (config.neoPixelFlashWhenSpeaking && !configStarted) {
if (volume > 0.5) {
invoke("publishSpeakingFlash", "speaking");
}
}
}

/**
* initial callback for Pir sensor Default behavior will be: send fsm event
Expand Down Expand Up @@ -1555,11 +1568,6 @@ public void setRightHandSpeed(Integer thumb, Integer index, Integer majeure, Int
setHandSpeed("right", (double) thumb, (double) index, (double) majeure, (double) ringFinger, (double) pinky, (double) wrist);
}

public String setSpeechType(String speechType) {
updatePeerType("mouth" /* getPeerName("mouth") */, speechType);
return speechType;
}

public void setTorsoSpeed(Double topStom, Double midStom, Double lowStom) {
sendToPeer("torso", "setSpeed", topStom, midStom, lowStom);
}
Expand Down Expand Up @@ -1928,6 +1936,44 @@ public void waitTargetPos() {
sendToPeer("leftArm", "waitTargetPos");
sendToPeer("torso", "waitTargetPos");
}

public boolean setSpeechType(String speechType) {

if (speechType == null) {
error("cannot change speech type to null");
return false;
}

if (!speechType.contains(".")) {
speechType = "org.myrobotlab.service." + speechType;
}

Runtime runtime = Runtime.getInstance();
String peerName = getName() + ".mouth";
Plan plan = runtime.getDefault(peerName, speechType);
try {
SpeechSynthesisConfig mouth = (SpeechSynthesisConfig)plan.get(peerName);
mouth.speechRecognizers = new String[] { getName() + ".ear" };

savePeerConfig("mouth", plan.get(peerName));

if (isPeerStarted("mouth")) {
// restart
releasePeer("mouth");
startPeer("mouth");
}

} catch(Exception e) {
error("could not create config for %s", speechType);
return false;
}

return true;

// updatePeerType("mouth" /* getPeerName("mouth") */, speechType);
// return speechType;
}


public static void main(String[] args) {
try {
Expand All @@ -1937,15 +1983,21 @@ public static void main(String[] args) {
// Runtime.start("s01", "Servo");
// Runtime.start("intro", "Intro");

// Runtime.startConfig("pr-1213-1");
Runtime.startConfig("dev");

WebGui webgui = (WebGui) Runtime.create("webgui", "WebGui");
// webgui.setSsl(true);
webgui.autoStartBrowser(false);
// webgui.setPort(8888);
webgui.startService();

InMoov2 i01 = (InMoov2)Runtime.start("i01","InMoov2");

boolean done = true;
if (done) {
return;
}


OpenCVConfig ocvConfig = i01.getPeerConfig("opencv", new StaticType<>() {});
ocvConfig.flip = true;
i01.setPeerConfigValue("opencv", "flip", true);
Expand All @@ -1955,10 +2007,6 @@ public static void main(String[] args) {

// Runtime.main(new String[] { "--log-level", "info", "-s", "webgui", "WebGui", "intro", "Intro", "python", "Python" });

boolean done = true;
if (done) {
return;
}


Runtime.start("python", "Python");
Expand Down

0 comments on commit 43416e0

Please sign in to comment.