|
4 | 4 | import java.io.FileWriter;
|
5 | 5 | import java.io.IOException;
|
6 | 6 | import java.io.OutputStream;
|
| 7 | +import java.util.concurrent.Executors; |
| 8 | +import java.util.concurrent.ScheduledExecutorService; |
| 9 | +import java.util.concurrent.TimeUnit; |
7 | 10 |
|
8 | 11 | import org.json.JSONObject;
|
9 | 12 | import org.springframework.web.bind.annotation.*;
|
|
33 | 36 | // @CrossOrigin(origins = "*")
|
34 | 37 | public class AIHoloController {
|
35 | 38 | 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"; |
39 | 41 | private static final String AUTH_TOKEN = "Bearer asdf";
|
40 | 42 |
|
41 | 43 | @Autowired
|
42 | 44 | private DataSource dataSource;
|
43 | 45 |
|
| 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 | + |
44 | 64 | @GetMapping("/set")
|
45 |
| - public String setValue(@RequestParam("value") String value) { // TTSoutput.wav |
| 65 | + public String setValue(@RequestParam("value") String value) { |
46 | 66 | theValue = value;
|
47 | 67 | System.out.println("EchoController set: " + theValue);
|
48 | 68 | String filePath = "C:/Users/opc/aiholo_output.txt";
|
|
0 commit comments