The post has been translated automatically. Original language: Russian
At Akcent Group, we are making a mobile game for learning English. One of the exercises is "Say the word": the player sees a picture and says the word out loud. The most obvious way is to send the recording to a cloud—based speech recognition service. We have abandoned it and recognize speech directly on the device. We share why and what kind of rake we stepped on.
Why not a cloud
- Privacy. The voice is personal data, and among our players there are children from 6 years old. If the recording does not leave the phone, it cannot be lost, it does not need to be stored and protected, and the privacy policy becomes shorter and more honest.
- Cost. Cloud APIs charge for every second of audio. As the audience grows, this is a significant expense item, and it grows with engagement — that is, with what you are striving for.
- Connection. Mobile Internet is not stable everywhere. Local recognition works both on the train and in the village, and without delay on the network.
What we use
Starting from Android 12, the system has a recognizer that only works on the device (SpeechRecognizer.createOnDeviceSpeechRecognizer). It is important that it does not switch to the server "quietly": if it cannot be recognized locally, you will receive an error rather than sending a voice to the network.
The pitfalls
There may not be a language pack. The English model is not installed on many phones. Starting with Android 13, an application can ask the system to download it; Android 14 reports progress as a percentage, Android 13 only reports the download itself. Check the status in advance, at the first start, and not in the middle of the lesson: otherwise, the user will click on the microphone and nothing will happen.
Microphone permission. Ask him at the moment when the user clicks on the microphone for the first time, and explain why. If the person refused, remember this and do not ask on every screen; give the opportunity to enable the function later in the settings.
The recognizer doesn't write what you expect. Say "two" and get "2" or "to". Say "four" and get "for". Therefore, the answer needs to be normalized: numbers should be turned into words, homophones and plural should be taken into account, and the correct word should be searched among all the options that the system returned, not just in the first one.
Phrases are more complicated than words. For short sentences, we compare words in order, consider articles optional, and skip one word in long phrases. The purpose of the exercise is to speak, not to take the diction exam.
About UX
The player has two attempts. After the first error, the app pronounces the word as a sample. After the second one, the exercise turns into a regular choice of an answer — without punishment. There is a button "I can't talk right now" (in transport, sleeping nearby): it simply replaces the question with a tap, without losing the reward. A person who is ashamed or uncomfortable speaking out loud should not feel like they are losing.
Result
Today, local recognition is quite good for individual words and short phrases of the A1–A2 level. It is still not enough to evaluate free speech, but it is enough for educational exercises. If you're making an EdTech product with voice, start with three things: checking whether the device supports local recognition, an honest fallback without a microphone, and normalizing responses. This closes most of the problems even before you write the first line of the lesson logic.
Мы в Akcent Group делаем мобильную игру для изучения английского. Одно из упражнений — «Скажи слово»: игрок видит картинку и произносит слово вслух. Самый очевидный путь — отправлять запись в облачный сервис распознавания речи. Мы от него отказались и распознаём речь прямо на устройстве. Делимся, почему и на какие грабли наступили.
Почему не облако
- Приватность. Голос — это персональные данные, а среди наших игроков есть дети от 6 лет. Если запись не покидает телефон, её нельзя потерять, не нужно хранить и защищать, а политика конфиденциальности становится короче и честнее.
- Стоимость. Облачные API берут плату за каждую секунду аудио. При росте аудитории это заметная статья расходов, причём растущая вместе с вовлечённостью — то есть с тем, к чему вы и стремитесь.
- Связь. Мобильный интернет не везде стабилен. Локальное распознавание работает и в поезде, и в селе, и без задержки на сеть.
Что мы используем
Начиная с Android 12 в системе есть распознаватель, который работает только на устройстве (SpeechRecognizer.createOnDeviceSpeechRecognizer). Важно, что он не переключается на сервер «по-тихому»: если локально распознать нельзя, вы получите ошибку, а не отправку голоса в сеть.
Подводные камни
Языкового пакета может не быть. На многих телефонах английская модель не установлена. Начиная с Android 13 приложение может попросить систему скачать её; Android 14 сообщает прогресс в процентах, Android 13 — только сам факт загрузки. Проверяйте статус заранее, при первом запуске, а не посреди урока: иначе пользователь нажмёт на микрофон и ничего не произойдёт.
Разрешение на микрофон. Спрашивайте его в момент, когда пользователь впервые нажимает на микрофон, и объясняйте зачем. Если человек отказал — запомните это и не спрашивайте на каждом экране; дайте возможность включить функцию позже в настройках.
Распознаватель пишет не то, что вы ждёте. Скажите «two» — получите «2» или «to». Скажите «four» — получите «for». Поэтому ответ нужно нормализовать: цифры превращать в слова, учитывать омофоны и множественное число, а искать правильное слово среди всех вариантов, которые вернула система, а не только в первом.
Фразы сложнее слов. Для коротких предложений мы сравниваем слова по порядку, считаем артикли необязательными и в длинных фразах допускаем пропуск одного слова. Цель упражнения — заговорить, а не пройти экзамен по дикции.
Про UX
У игрока две попытки. После первой ошибки приложение произносит слово как образец. После второй упражнение превращается в обычный выбор ответа — без наказания. Есть кнопка «Не могу сейчас говорить» (в транспорте, рядом спят): она просто заменяет вопрос на нажатие, без потери награды. Человек, которому стыдно или неудобно говорить вслух, не должен чувствовать, что проигрывает.
Итог
Локальное распознавание сегодня достаточно хорошо для отдельных слов и коротких фраз уровня A1–A2. Для оценки свободной речи его пока мало, но для учебных упражнений — с запасом. Если вы делаете EdTech-продукт с голосом, начните с трёх вещей: проверки, поддерживает ли устройство локальное распознавание, честного запасного варианта без микрофона и нормализации ответов. Это закрывает большую часть проблем ещё до того, как вы напишете первую строку логики урока.
Comments 3
Newest Popular