Skip to content

Commit 1316d32

Browse files
committed
multi-language support
1 parent 5dbe2e3 commit 1316d32

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

java-ai/src/main/java/oracleai/aiholo/AIHoloController.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import java.io.FileWriter;
55
import java.io.IOException;
66
import java.io.OutputStream;
7+
import java.util.concurrent.Executors;
8+
import java.util.concurrent.ScheduledExecutorService;
9+
import java.util.concurrent.TimeUnit;
710

811
import org.json.JSONObject;
912
import org.springframework.web.bind.annotation.*;
@@ -33,16 +36,33 @@
3336
// @CrossOrigin(origins = "*")
3437
public class AIHoloController {
3538
private String theValue = "mirrorme";
36-
37-
38-
private static final String API_URL = "http://129.x.x.x/v1/chat/completions?client=server";
39+
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
40+
private static final String API_URL = "http://129.x.x.x/v1/chat/completions?client=server";
3941
private static final String AUTH_TOKEN = "Bearer asdf";
4042

4143
@Autowired
4244
private DataSource dataSource;
4345

46+
private volatile long lastRequestTime = System.currentTimeMillis();
47+
48+
public AIHoloController() {
49+
startInactivityMonitor();
50+
}
51+
52+
private void startInactivityMonitor() {
53+
scheduler.scheduleAtFixedRate(() -> {
54+
long currentTime = System.currentTimeMillis();
55+
if (currentTime - lastRequestTime > TimeUnit.MINUTES.toMillis(10)) {
56+
sendToAudio2Face("testing123-brazil.wav");
57+
lastRequestTime = currentTime; // Reset timer to prevent repeated execution
58+
}
59+
}, 1, 3, TimeUnit.MINUTES);
60+
}
61+
62+
63+
4464
@GetMapping("/set")
45-
public String setValue(@RequestParam("value") String value) { // TTSoutput.wav
65+
public String setValue(@RequestParam("value") String value) {
4666
theValue = value;
4767
System.out.println("EchoController set: " + theValue);
4868
String filePath = "C:/Users/opc/aiholo_output.txt";

java-ai/src/main/resources/static/aiholo/AIHolo-Brazil.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ <h1>Oracle Database hologramas de IA interativos</h1>
150150
return;
151151
}
152152
const selectedMode = document.querySelector('input[name="mode"]:checked').value;
153-
const modifiedText = `${transcriptionText} . responda em 20 palavras ou menos`;
153+
const modifiedText = `${transcriptionText} . responda em 20 palavras ou menos e em português brasileiro`;
154154
const apiUrl = `http://141.148.204.74:8444/aiholo/play?question=${encodeURIComponent(modifiedText)}&selectedMode=${encodeURIComponent(selectedMode)}&languagecode=${encodeURIComponent("pt-BR")}&voicename=${encodeURIComponent("pt-BR-Wavenet-D")}`;
155155
try {
156156
const response = await fetch(apiUrl, {

0 commit comments

Comments
 (0)