Skip to content

Commit 31bc9f6

Browse files
authored
Create Basic Jarvis-like AI
1 parent 70c8c4e commit 31bc9f6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Basic Jarvis-like AI

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import java.util.Scanner;
2+
3+
public class Jarvis {
4+
5+
private SpeechRecognizer speechRecognizer;
6+
private TextToSpeech textToSpeech;
7+
private NaturalLanguageProcessor nlp;
8+
private KnowledgeBase knowledgeBase;
9+
10+
public Jarvis(SpeechRecognizer speechRecognizer, TextToSpeech textToSpeech, NaturalLanguageProcessor nlp, KnowledgeBase knowledgeBase) {
11+
this.speechRecognizer = speechRecognizer;
12+
this.textToSpeech = textToSpeech;
13+
this.nlp = nlp;
14+
this.knowledgeBase = knowledgeBase;
15+
}
16+
17+
public void listenAndRespond() {
18+
String userInput = speechRecognizer.recognizeSpeech();
19+
String response = nlp.processInput(userInput, knowledgeBase);
20+
textToSpeech.speak(response);
21+
}
22+
23+
public static void main(String[] args) {
24+
SpeechRecognizer speechRecognizer = new GoogleCloudSpeechRecognizer();
25+
TextToSpeech textToSpeech = new GoogleCloudTextToSpeech();
26+
NaturalLanguageProcessor nlp = new OpenNLPProcessor();
27+
KnowledgeBase knowledgeBase = new WikidataKnowledgeBase();
28+
29+
Jarvis jarvis = new Jarvis(speechRecognizer, textToSpeech, nlp, knowledgeBase);
30+
31+
jarvis.listenAndRespond();
32+
}
33+
}

0 commit comments

Comments
 (0)