-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEchosight.java
More file actions
47 lines (38 loc) · 1.72 KB
/
Copy pathEchosight.java
File metadata and controls
47 lines (38 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import javax.speech.Central;
import javax.speech.synthesis.Synthesizer;
import javax.speech.synthesis.SynthesizerModeDesc;
import java.util.Locale;
public class EchoSightPrototype {
// Simulated Object Detection Function
gu public static String detectObjectFromCamera() {
// In a full build, connect OpenCV or Google Vision API here.
// Returning mock detected objects for hackathon demo:
return "Warning: An obstacle ahead 2 feet away.";
}
// Text-To-Speech Function
public static void speakText(String message) {
try {
// Set up Voice Synthesizer
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
Central.registerEngineCentral("com.sun.speech.freetts.jsapi.FreeTTSEngineCentral");
Synthesizer synthesizer = Central.createSynthesizer(new SynthesizerModeDesc(Locale.US));
synthesizer.allocate();
synthesizer.resume();
// Speak the description to the user
System.out.println("EchoSight Speaking: " + message);
synthesizer.speakPlainText(message, null);
synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);
synthesizer.deallocate();
} catch (Exception e) {
// Fallback for demo if TTS library is missing: print to console
System.out.println("[Speech Output]: " + message);
}
}
public static void main(String[] args) {
System.out.println("--- Starting EchoSight Assistive Device ---");
// 1. Detect object
String description = detectObjectFromCamera();
// 2. Announce to user via Voice
speakText(description);
}
}