Вы можете использовать Pocketsphinx для выполнения этой задачи. Проверьте демо-версию Pocketsphinx android , например, как эффективно прослушивать ключевое слово в автономном режиме и реагировать на конкретные команды, такие как ключевая фраза «о могучий компьютер». Код для этого прост:
вы создаете распознаватель и просто добавляете поиск по ключевым словам:
recognizer = SpeechRecognizerSetup.defaultSetup()
.setAcousticModel(new File(modelsDir, "hmm/en-us-semi"))
.setDictionary(new File(modelsDir, "lm/cmu07a.dic"))
.setKeywordThreshold(1e-40f)
.getRecognizer();
recognizer.addListener(this);
recognizer.addKeyphraseSearch("keywordSearch", "oh mighty computer");
recognizer.startListening("keywordSearch);
и определяете слушателя:
@Override
public void onPartialResult(Hypothesis hypothesis) {
if (hypothesis == null)
return;
String text = hypothesis.getHypstr();
if (text.equals(KEYPHRASE)) {
// do something and restart listening
recognizer.cancel();
doSomething();
recognizer.startListening("keywordSearch");
}
}
Вы можете настроить порог ключевого слова для наилучшего совпадения обнаружения / ложного срабатывания. Для идеального ключевого слова с проверкой должно быть не менее 3 слогов, лучше 4 слога.
С помощью плагина Geocoder вы можете получить адрес по широте и долготе
getUserLocation() async {//call this async method from whereever you need
Map<String, double> currentLocation = new Map();
Map<String, double> myLocation;
String error;
Location location = new Location();
try {
myLocation = await location.getLocation();
} on PlatformException catch (e) {
if (e.code == 'PERMISSION_DENIED') {
error = 'please grant permission';
print(error);
}
if (e.code == 'PERMISSION_DENIED_NEVER_ASK') {
error = 'permission denied- please enable it from app settings';
print(error);
}
myLocation = null;
}
currentLocation = myLocation;
final coordinates = new Coordinates(
currentLocation['latitude'], currentLocation['longitude']);
var addresses = await Geocoder.local.findAddressesFromCoordinates(
coordinates);
var first = addresses.first;
print(' ${first.locality}, ${first.adminArea},${first.subLocality}, ${first.subAdminArea},${first.addressLine}, ${first.featureName},${first.thoroughfare}, ${first.subThoroughfare}');
return first;
}
Вам потребуется использовать службу «обратного геокодирования», например API Google: https://developers.google.com/maps/documentation/geocoding/start . Есть и другие ... просто Google для "геокодирования".
Обновление: очевидно, есть и локальный API. См .: https://pub.dartlang.org/packages/geocoder
.