diff --git a/README.md b/README.md index a050273..2060176 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,10 @@ ### [Esperanto] -Jen eta provi fari parolrekonilon uzante la Vosk parolrekona modelo.01 -(vosk-model-small-eo-0.22) +Android Esperanto Parolrekono rekonas vian parolon en Esperanto kaj provizas la tekston. + +Ĝi baziĝas sur la Vosk parolrekona modelo por Esperanto (vosk-model-small-eo-0.42) trovebla ĉe https://alphacephei.com/vosk/models. + Vi povas elŝuti de https://javabog.dk/privat/EsperantoParolRekono.apk @@ -46,34 +48,7 @@ If you want to use the application with your language just replace the models in - Does not work with Google's keyboard "GBoard". - Not all record applications read the voice text properly, there must be another way---and if you know how, it is probably a trivial fix. -- DeepSpeech models were removed, they didn't build! Maybe it can be fixed? - -#### Future Work - -- Support query alphacephei.com and suppport selection+download of optional models. Then this apk can be packaged _without_ a language (much smaller!). #### Demo ![LocalSTT in action](./demo.gif) - -### [Català] - -> **Nota: Aquesta aplicació de moment només és una prova de concepte** - -LocalSTT és una aplicació per Android que proporciona reconeixement automàtic de la parla sense necessitat de conexió a internet ja que tot el processament és local al mòbil. - -Això és possible gràcies a: -- un RecognitionService que utilitza la llibreria de Vosk -- un RecognitionService que utilitza la lliberia de Mozilla Deepspeech -- una Activity que gestiona intents RECOGNIZE_SPEECH entre altres - -El codi és actualment una prova de concepte i es basa fortament en els següents projectes: -- [Kõnele](https://github.com/Kaljurand/K6nele) -- [Vosk Android Demo](https://github.com/alphacep/vosk-android-demo) - -LocalSTT hauria de funcionar amb la majoria de teclats i aplicacions que implementen la funció de reconeixement de veu a través d'un intent RECOGNIZE_SPEECH o directament fent servir la classe SpeechRecognizer d'Android. Ha estat provada amb èxit fent servir les següent aplicacions en un terminal Android 9: -- [AnySoftKeyboard](https://github.com/AnySoftKeyboard/AnySoftKeyboard) -- [Kõnele](https://github.com/Kaljurand/K6nele) -- [SwiftKey](https://www.swiftkey.com) - -Us podeu descarregar un APK que inclou models de Vosk i DeepSpeech pel català [aquí](https://github.com/ccoreilly/LocalSTT/releases/download/2020-12-03/localstt.apk). diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9ad8fbb..31e3b84 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,7 +18,7 @@ @@ -100,7 +100,7 @@ diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..c13bb3d Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/dk/nordfalk/esperanto/parolrekono/MainActivity.java b/app/src/main/java/dk/nordfalk/esperanto/parolrekono/MainActivity.java index e4fb21a..8e3829f 100644 --- a/app/src/main/java/dk/nordfalk/esperanto/parolrekono/MainActivity.java +++ b/app/src/main/java/dk/nordfalk/esperanto/parolrekono/MainActivity.java @@ -52,18 +52,14 @@ protected void toast(String message) { protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.speech_activity); - if (ContextCompat.checkSelfPermission(this, - Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { - checkPermission(); - } editText = findViewById(R.id.editText); speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this); - speechRecognizer.setRecognitionListener(new RecognitionListener() { @Override public void onReadyForSpeech(Bundle bundle) { - + Log.i(TAG, "onReadyForSpeech "+bundle); + editText.setHint("onReadyForSpeech"); } @Override @@ -122,7 +118,11 @@ public void onEvent(int i, Bundle bundle) { public void onStart() { super.onStart(); Log.i(TAG, "onStart"); + if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { + checkPermission(); + } final Intent speechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Parolu nun"); speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); speechRecognizer.startListening(speechRecognizerIntent); @@ -137,19 +137,16 @@ protected void onDestroy() { private void checkPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.RECORD_AUDIO }, - RecordAudioRequestCode); + ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.RECORD_AUDIO }, RecordAudioRequestCode); } } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, - @NonNull int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == RecordAudioRequestCode && grantResults.length > 0) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED) Toast.makeText(this, "Permission Granted", Toast.LENGTH_SHORT).show(); } } - } diff --git a/app/src/main/res/drawable/ic_esperanta_parolrekono.xml b/app/src/main/res/drawable/ic_esperanta_parolrekono.xml new file mode 100644 index 0000000..054d6f3 --- /dev/null +++ b/app/src/main/res/drawable/ic_esperanta_parolrekono.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..ca3826a --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..41a2b30 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/app/src/main/res/layout/speech_activity.xml b/app/src/main/res/layout/speech_activity.xml index db00cad..2fb522d 100644 --- a/app/src/main/res/layout/speech_activity.xml +++ b/app/src/main/res/layout/speech_activity.xml @@ -32,10 +32,12 @@ android:layout_marginBottom="20dp" android:layout_marginLeft="16dp" android:hint="@string/loading" - android:textColorHint="@color/colorPrimaryDark" - android:textColor="@color/colorPrimary" android:id="@+id/editText" android:layout_centerInParent="true" /> + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..bbd3e02 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..bbd3e02 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..3c4ac60 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..831104c Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..511f574 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..52b02c5 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..fee4ad3 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..d4c426f Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..464fe57 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..a03a001 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4ffd410 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..180908d Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/esperanta_parolrekono.svg b/esperanta_parolrekono.svg new file mode 100644 index 0000000..dbfd556 --- /dev/null +++ b/esperanta_parolrekono.svg @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + +