Passive, continuous mood tracking, from the voice on iPhone and the face on Android: AI models on the phone and in the cloud, complex data-processing pipelines

Models that run inside the patient’s phone, all day long, without draining the battery or making it run hot.

  • On-device AI

Running a vision model on a server is commonplace. Running such a model inside a patient’s phone, for months, while they use it for something else, is another trade: managing battery, heat, a system that stops apps whenever it can, a camera and a microphone that other apps ask for.

On Android, EmoDTx estimates mood from facial expressions, and the app performs all the computing inside the phone: only numbers leave it. On iPhone, where mood is estimated from the voice, the app keeps only the moments someone speaks, and a server analyses them.

This is the work of Emobot’s whole team. My contribution, as a co-founder, was to make it viable on real phones: managing heat, battery life, overflowing queues, restarts after disconnections, and ensuring the microphone is not taken over by a dictation.

The result

Perspective drawing of two phones standing side by side, each before a frame of the same size, at the same height. The first looks at a face through a dotted cone; the second has a minute of sound before its microphone, as vertical bars. Depending on the step: a day where captures appear only in the moments of use; an image as a grid, then a face, then a row of bars, then a point on two axes, alone to the right of a line; three heads and three rows of bars, with two gauges, one full, the other almost empty; the minute of sound where two stretches are hatched and a lone peak is not; a curve that climbs in steps, falls back under a hatched band then levels off, beside a temperature that goes past a line; beats that stop then resume after a filled dot, and two interruptions one after the other, a struck-out arrow between them.

What was done

  1. 01

    Face analysis, inside the phone

    Three models in a row on Android, from the face found to the two numbers sent. During tracking, the image does not leave the phone.

    Kotlin · ONNX Runtime · CameraX

  2. 02

    Recognizing the patient

    A reference signature from three photos at enrolment, then each measurement marked according to whether the face is the patient’s.

    Kotlin · Python

  3. 03

    Detecting speech

    On iPhone, a model that keeps only the moments someone speaks, before anything is sent.

    Swift · AVFoundation

  4. 04

    Computing on charge

    Images kept encrypted, analysed when the phone is plugged in, erased at once, and a queue with a ceiling when it never is.

    Kotlin · WorkManager

  5. 05

    Heat and battery

    A capture and models that stop when the phone runs hot or the battery is low, and start again by themselves.

    Kotlin · Swift

  6. 06

    The restarts

    A watchdog that restarts the app and says why it did nothing, and numbered microphone interruptions, so listening does not resume in place of a dictation.

    Kotlin · Swift

  7. 07

    On the computer

    The same models on Mac and Windows, where each image is analysed in memory.

    Electron · ONNX Runtime

  8. 08

    The tests

    Tests on the iPhone’s audio engine: listening windows, recovery after an interruption, quality of the extracts.

    XCTest

Perspective drawing of two phones standing side by side, each before a frame of the same size, at the same height. The first looks at a face through a dotted cone; the second has a minute of sound before its microphone, as vertical bars. Depending on the step: a day where captures appear only in the moments of use; an image as a grid, then a face, then a row of bars, then a point on two axes, alone to the right of a line; three heads and three rows of bars, with two gauges, one full, the other almost empty; the minute of sound where two stretches are hatched and a lone peak is not; a curve that climbs in steps, falls back under a hatched band then levels off, beside a temperature that goes past a line; beats that stop then resume after a filled dot, and two interruptions one after the other, a struck-out arrow between them.

How it works

  1. Scroll: the drawing follows.

  2. 01 / 06

    Measure during ordinary use

    The patient has nothing special to do, and the phone is spared: no drained battery, no overheating. On Android, the front camera is used only while the phone is unlocked, with a permanent notification, as the system requires. On iPhone, listening stays within the limits iOS sets for apps in the background. In both cases, the patient can pause the tracking whenever they want.

  3. 02 / 06

    On Android, compute everything inside the phone

    Three models run one after the other inside the phone. The first finds the face in the image. The second reduces it to a signature, a sequence of numbers, to know whose it is. The third reads the expression and sums it up in two numbers: how pleasant it is, how lively it is. These numbers, with their time, are what is sent. During tracking, the image does not leave the phone.

  4. 03 / 06

    Recognize the patient, and only them

    At enrolment, the patient photographs themselves from the front and from each side: these three photos, the only ones sent, are used to compute a reference signature. After that, every face seen is compared with this signature. If someone else is holding the phone, the measurement is marked as not being the patient’s. If there are several faces, only the largest in the image is looked at.

  5. 04 / 06

    On iPhone, keep only the speech

    The microphone picks up everything: silence, the street, a door. Inside the phone, a model spots the moments someone speaks and keeps only those. Each extract goes through a quality check, which sets aside what is too short or too poor in speech, then waits to be sent. A server then analyses it, in batches, and checks that the voice is indeed the patient’s.

  6. 05 / 06

    Last all day

    Analysing an image costs energy. So on Android the phone only captures while it is being used, keeps the images encrypted, and runs the models only once it is charging; each image is erased as soon as it has been analysed. If it is never plugged in, the queue reaches a ceiling and the oldest images are dropped: a gap in the data is better than a flat battery. If the phone runs hot, the capture and the models stop, then start again by themselves once it has cooled. On iPhone, listening happens in short windows, further apart at night, in low-power mode or when the device runs hot.

  7. 06 / 06

    Start again alone, breaking nothing

    The system can stop the app at any moment. A watchdog checks regularly that it still shows a sign of life, starts it again, and says why when it does nothing: a failure no longer looks like a phone switched off. On iPhone, a call or a dictation can take the microphone. Each interruption bears a number, and listening resumes only when that very one has ended, so as not to cut off a dictation in progress. And if the server refuses an account, capturing and sending stop instead of insisting.

Specifications

Role
Co-founder and chief product officer; reliability of the capture on Android and iPhone, with Emobot’s team
Built with
Kotlin · Swift · ONNX Runtime · React Native