Skip to content

Commit

Permalink
Merge pull request #1 from sergejey/master
Browse files Browse the repository at this point in the history
Voice/Proximity activation, remote actions
  • Loading branch information
Galakart committed Jan 30, 2015
2 parents 657a43a + 48a51d8 commit 839012e
Show file tree
Hide file tree
Showing 25 changed files with 109,388 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
4 changes: 4 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>

<application
android:allowBackup="true"
Expand Down
Binary file modified MajorDroid.apk
Binary file not shown.
4 changes: 4 additions & 0 deletions assets/dict/ru/hotwords
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
умный uu m n ay j
дом d oo m
проснись p r a s nn ii ss
вставай v s t a v aa j
15 changes: 15 additions & 0 deletions assets/hmm/ru/feat.params
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-alpha 0.97
-dither yes
-doublebw no
-nfilt 40
-ncep 13
-lowerf 133.33334
-upperf 6855.4976
-nfft 512
-wlen 0.0256
-transform legacy
-feat 1s_c_d_dd
-agc none
-cmn current
-varnorm no

108,391 changes: 108,391 additions & 0 deletions assets/hmm/ru/mdef

Large diffs are not rendered by default.

Binary file added assets/hmm/ru/means
Binary file not shown.
Binary file added assets/hmm/ru/mixture_weights
Binary file not shown.
4 changes: 4 additions & 0 deletions assets/hmm/ru/noisedict
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<s> SIL
</s> SIL
<sil> SIL
- SIL
Binary file added assets/hmm/ru/transition_matrices
Binary file not shown.
Binary file added assets/hmm/ru/variances
Binary file not shown.
Binary file added libs/armeabi-v7a/libpocketsphinx_jni.so
Binary file not shown.
Binary file added libs/armeabi/libpocketsphinx_jni.so
Binary file not shown.
Binary file added libs/commons-io-2.4.jar
Binary file not shown.
Binary file added libs/pocketsphinx-android-0.8-nolib.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
target=android-16
13 changes: 13 additions & 0 deletions res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,17 @@
<item>Выкл</item>
<item>Вкл</item>
</string-array>
<string-array name="voiceactivation">
<item>Выкл</item>
<item>Вкл</item>
</string-array>
<string-array name="proximitylist">
<item>Выкл</item>
<item>Вкл</item>
</string-array>
<string-array name="voicelist">
<item>проснись</item>
<item>умный дом</item>
<item>дом проснись</item>
</string-array>
</resources>
4 changes: 4 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<string name="vid">Интерфейс</string>
<string name="vid_summary">Обычный или полноэкранный</string>
<string name="gps_switch">GPS-трекер</string>
<string name="voice_switch">Голосовая активация</string>
<string name="voice_phrase">Фраза активации</string>
<string name="voice_proximity">Активация при приближении</string>
<string name="gps_period_title">Периодичность отправки координат (в мин.)</string>
<string name="gps_period">Периодичность</string>
<string name="path_homepage">Домашняя страница</string>
Expand All @@ -43,5 +46,6 @@
<string name="about_url">v1.3b http:https://smartliving.ru</string>
<string name="about_donate">Приложение для управления сервером умного дома MajorDomo.\n\nЛицензия Beerware - каждый довольный пользователь может выпить пива в честь автора android-приложения, или поддержать материально:\nWebMoney: R052376421830</string>
<string name="wifihomenet">Wifi домашняя сеть</string>
<string name="hotword">проснись</string>

</resources>
32 changes: 32 additions & 0 deletions res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,38 @@
android:title="@string/passw" />
</PreferenceCategory>
<PreferenceCategory android:title="Сервисы" >
<PreferenceScreen
android:summary="Голосовая активация запроса команды"
android:title="Активация голосом" >
<ListPreference
android:defaultValue="Выкл"
android:dialogTitle="Активация"
android:entries="@array/voiceactivation"
android:entryValues="@array/voiceactivation"
android:key="@string/voice_switch"
android:summary="Вкл/выкл"
android:title="@string/voice_switch" />
<ListPreference
android:defaultValue="проснись"
android:dialogTitle="Фраза"
android:entries="@array/voicelist"
android:entryValues="@array/voicelist"
android:key="@string/voice_phrase"
android:summary="Активирующая фраза"
android:title="@string/voice_phrase" />


<ListPreference
android:defaultValue="Выкл"
android:dialogTitle="Статус"
android:entries="@array/proximitylist"
android:entryValues="@array/proximitylist"
android:key="@string/voice_proximity"
android:summary="Активация при приближении"
android:title="@string/voice_proximity" />
</PreferenceScreen>


<PreferenceScreen
android:summary="Отсылка GPS-координат на домашний сервер"
android:title="GPS-трекер" >
Expand Down
109 changes: 109 additions & 0 deletions src/com/example/recognizer/DataFiles.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright 2012, Institute of Cybernetics at Tallinn University of Technology
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.recognizer;

import android.os.Environment;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;

public class DataFiles {

private static final int VERSION = 1;

private final int mSampleRateInHz;

private final File mFileHmm;
private final File mFileJsgf;
private final File mFileDict;
private final File mFileLog;
private final File mDirRawLog;

public DataFiles(String packageName, String lang) {
this(packageName, lang, 16000);
}

public DataFiles(String packageName, String lang, int sampleRate) {
String baseDirAsString = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + packageName + "/" + lang + "/" + VERSION;

mFileHmm = new File(baseDirAsString +"/hmm/" + sampleRate);
mFileJsgf = new File(baseDirAsString + "/lm/" + "lm.jsgf");
mFileDict = new File(baseDirAsString + "/lm/" + "lm.dic");
mFileLog = new File(baseDirAsString + "/pocketsphinx.log");
mDirRawLog = new File(baseDirAsString + "/raw/");
mSampleRateInHz = sampleRate;
}

public boolean deleteDict() {
return mFileDict.delete();
}

public boolean deleteLogfile() {
return mFileLog.delete();
}

public boolean deleteJsgf() {
return mFileJsgf.delete();
}

public boolean deleteRawLogDir() {
try {
FileUtils.cleanDirectory(mDirRawLog);
} catch (IOException e) {
return false;
}
return true;
}

public boolean createRawLogDir() {
if (! mDirRawLog.exists()) {
try {
FileUtils.forceMkdir(mDirRawLog);
} catch (IOException e) {
return false;
}
}
return true;
}

public String getLogfile() {
return mFileLog.getAbsolutePath();
}

public String getRawLogDir() {
return mDirRawLog.getAbsolutePath();
}

public String getHmm() {
return mFileHmm.getAbsolutePath();
}

public String getDict() {
return mFileDict.getAbsolutePath();
}

public String getJsgf() {
return mFileJsgf.getAbsolutePath();
}

public int getSampleRateInHz() {
return mSampleRateInHz;
}

}
43 changes: 43 additions & 0 deletions src/com/example/recognizer/Dict.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2012, Institute of Cybernetics at Tallinn University of Technology
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.recognizer;

import java.util.HashSet;
import java.util.Set;

public class Dict {

private final StringBuilder mDict = new StringBuilder();
private final Set<String> mWords = new HashSet<String>();

private static final String NL = System.getProperty("line.separator");

public void add(String key, String value) {
if (! mWords.contains(key)) {
mDict.append(key);
mDict.append(" "); // two spaces
mDict.append(value);
mDict.append(NL);
mWords.add(key);
}
}

public String toString() {
return mDict.toString();
}

}
43 changes: 43 additions & 0 deletions src/com/example/recognizer/Grammar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.example.recognizer;

public class Grammar {

private final String mJsgf;
private final Dict mDict;
private final PhonMapper mPhonMapper;

public Grammar(String[] commands, PhonMapper phonMapper) {
mDict = new Dict();
mPhonMapper = phonMapper;

StringBuilder sb = new StringBuilder();
sb.append("#JSGF V1.0;\ngrammar commands;\n");
sb.append("public <command> = <commands>+;\n");
sb.append("<commands> = ");

for (int i = 0; i < commands.length; i++) {
String command = commands[i];
addWords(command);
if (i > 0) sb.append(" | ");
sb.append("[").append(command).append("]");
}

sb.append(";\n");
mJsgf = sb.toString();
}

public String getJsgf() {
return mJsgf;
}

public String getDict() {
return mDict.toString();
}

public void addWords(String text) {
String[] words = text.split(" ");
for (String word : words) {
mDict.add(word, mPhonMapper.getPronoun(word));
}
}
}
Loading

0 comments on commit 839012e

Please sign in to comment.