diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AudioTestNow.flac b/AudioTestNow.flac
new file mode 100644
index 0000000..56e1a56
Binary files /dev/null and b/AudioTestNow.flac differ
diff --git a/java-string-similarity-0.19.jar b/java-string-similarity-0.19.jar
new file mode 100644
index 0000000..4ffe7c3
Binary files /dev/null and b/java-string-similarity-0.19.jar differ
diff --git a/src/com/company/Ambient.java b/src/com/company/Ambient.java
new file mode 100644
index 0000000..c1928d4
--- /dev/null
+++ b/src/com/company/Ambient.java
@@ -0,0 +1,84 @@
+package com.company;
+
+import com.darkprograms.speech.microphone.MicrophoneAnalyzer;
+import com.darkprograms.speech.recognizer.GoogleResponse;
+import com.darkprograms.speech.recognizer.Recognizer;
+import javaFlacEncoder.FLACFileWriter;
+
+import java.io.File;
+
+/**
+ * Created by user on 16.11.16.
+ */
+public class Ambient {
+
+ public static void main(String[] args) {
+
+ MicrophoneAnalyzer mic = new MicrophoneAnalyzer(FLACFileWriter.FLAC);
+ mic.setAudioFile(new File("AudioTestNow.flac"));
+ while(true){
+ mic.open();
+ final int THRESHOLD = 20;
+ int volume = mic.getAudioVolume(10);
+ boolean isSpeaking = (volume > THRESHOLD);
+
+ if(isSpeaking){
+ try {
+ System.out.println("RECORDING...");
+ mic.captureAudioToFile(mic.getAudioFile());//Saves audio to file.
+ do{
+ Thread.sleep(2000);//Updates every second
+ }
+ while(mic.getAudioVolume(100) > THRESHOLD);
+ System.out.println("Recording Complete!");
+ System.out.println("Recognizing...");
+ Recognizer rec = new Recognizer(Recognizer.Languages.RUSSIAN, "AIzaSyDMRFZsdncfP2udmTbozAQ2owJuL5RRm34");
+ GoogleResponse response = rec.getRecognizedDataForFlac(mic.getAudioFile(), 3);
+ displayResponse(response);//Displays output in Console
+
+ reckognizeResponce(response);
+
+ System.out.println("Looping back");//Restarts loops
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ System.out.println("Error Occured");
+ }
+ finally{
+ mic.close();//Makes sure microphone closes on exit.
+ }
+ }
+ }
+ }
+
+ private static void displayResponse(GoogleResponse gr){
+ if(gr.getResponse() == null){
+ System.out.println((String)null);
+ return;
+ }
+ System.out.println("Google Response: " + gr.getResponse());
+ System.out.println("Google is " + Double.parseDouble(gr.getConfidence())*100 + "% confident in"
+ + " the reply");
+ System.out.println("Other Possible responses are: ");
+ for(String s: gr.getOtherPossibleResponses()){
+ System.out.println("\t" + s);
+ }
+ }
+
+ private static void reckognizeResponce(GoogleResponse gr){
+ if(gr.getResponse() == null){
+ System.out.println((String)null);
+ return;
+ }
+
+ VoiceCommands vc = new VoiceCommands();
+
+ vc.isCommand(gr.getResponse());
+
+
+ for(String s: gr.getOtherPossibleResponses()){
+ vc.isCommand(s);
+ }
+ }
+
+}
diff --git a/src/com/company/StringSimilarityTest.java b/src/com/company/StringSimilarityTest.java
new file mode 100644
index 0000000..7352a54
--- /dev/null
+++ b/src/com/company/StringSimilarityTest.java
@@ -0,0 +1,18 @@
+package com.company;
+
+import info.debatty.java.stringsimilarity.JaroWinkler;
+
+/**
+ * Created by user on 17.11.16.
+ */
+public class StringSimilarityTest {
+ public static void main (String[]args) {
+ JaroWinkler jw = new JaroWinkler();
+
+ // substitution of s and t
+ System.out.println(jw.similarity("начать обучение", "начать обучение"));
+
+ // substitution of s and n
+ System.out.println(jw.similarity("My string", "My ntrisg"));
+ }
+}
diff --git a/src/com/company/VoiceCommands.java b/src/com/company/VoiceCommands.java
new file mode 100644
index 0000000..9924e11
--- /dev/null
+++ b/src/com/company/VoiceCommands.java
@@ -0,0 +1,51 @@
+package com.company;
+
+import info.debatty.java.stringsimilarity.JaroWinkler;
+
+/**
+ * Created by user on 17.11.16.
+ */
+public class VoiceCommands {
+
+ private static final String startTraining = "начать";
+ private static final String poseType = "новая поза";
+ private static final String capturePose = "фиксация";
+ private static final String completeTraining = "закончить";
+
+ private JaroWinkler jaroWinkler = new JaroWinkler();
+
+ public boolean isCommand(String command) {
+
+ if(isLooksLike(command, startTraining)) {
+ System.out.println(startTraining);
+ }
+
+ if(isLooksLike(command, poseType)) {
+ System.out.println(poseType);
+ }
+
+ if(isLooksLike(command, capturePose)) {
+ System.out.println(capturePose);
+ }
+
+ if(isLooksLike(command, completeTraining)) {
+ System.out.println(completeTraining);
+ }
+
+ return false;
+
+ }
+
+ private boolean isLooksLike(String command, String etalon) {
+
+ double tresHold = 0.7;
+ double similaruty = jaroWinkler.similarity(command, etalon);
+
+ if(similaruty >= tresHold) {
+ return true;
+ }
+
+ return false;
+ }
+
+}
diff --git a/test_google_speach_api.iml b/test_google_speach_api.iml
index b3bd4b0..d06a801 100644
--- a/test_google_speach_api.iml
+++ b/test_google_speach_api.iml
@@ -36,5 +36,6 @@
+
\ No newline at end of file
diff --git a/wav.test b/wav.test
new file mode 100644
index 0000000..9bbfc72
Binary files /dev/null and b/wav.test differ