Skip to content

feat: Add question-based onboarding with phone microphone - #3859

Merged
beastoin merged 6 commits into
mainfrom
feature/onboarding-goals-questions
Dec 23, 2025
Merged

beastoin merged 6 commits into
mainfrom
feature/onboarding-goals-questions

Conversation

@kodjima33

@kodjima33 kodjima33 commented Dec 22, 2025 •

Copy link
Copy Markdown
Collaborator

This is a new onboarding that combines these goals:

- collect speech profile

- collect goals


- generage conversation + memories + action items to show examples to user


- make speech profile from microphone cuz we don’t ned device







It works, however i need help to


  • make it faster (currently i have 5 second silence detection and request to AI, i’d prefer it to be conversation like chatgpt
  • better transcription quality (accuracy is only 60%)
  • sometimes skips words (very critical)
    
If i don’t get help, im merging this tmrw

AI-generated description

  • Replace random phrase prompts with goal-oriented questions in speech profile
  • Questions: age, location, work, long-term goals, monthly goals, daily plans
  • Use phone microphone instead of Omi device for speech profiling
  • Auto-detect when user finishes answering (5s silence + word count)
  • Track transcript per question to avoid counting previous answers
  • Auto-process conversation when user clicks 'All done'
  • Create onboarding conversation and memories from user responses
  • Flow: Rate App -> Speech Profile (skip device connection during onboarding)
  • Add backend endpoint for AI-based answer detection (/v1/onboarding/check-answer)
  • Add backend endpoint for onboarding conversation creation (/v1/onboarding/conversation)
RPReplay_Final1766384317.MP4

- Replace random phrase prompts with goal-oriented questions in speech profile
- Questions: age, location, work, long-term goals, monthly goals, daily plans
- Use phone microphone instead of Omi device for speech profiling
- Auto-detect when user finishes answering (5s silence + word count)
- Track transcript per question to avoid counting previous answers
- Auto-process conversation when user clicks 'All done'
- Create onboarding conversation and memories from user responses
- Flow: Rate App -> Speech Profile (skip device connection during onboarding)
- Add backend endpoint for AI-based answer detection (/v1/onboarding/check-answer)
- Add backend endpoint for onboarding conversation creation (/v1/onboarding/conversation)
@kodjima33

kodjima33 commented Dec 22, 2025 •

Copy link
Copy Markdown
Collaborator Author




It works, however i need help to


  • make it faster (currently i have 5 second silence detection and request to AI, i’d prefer it to be conversation like chatgpt
  • better transcription quality (accuracy is only 60%)
  • sometimes skips words (very critical)
    
If i don’t get help, im merging this tmrw
    

    
cc @beastoin

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new question-based onboarding flow using the phone's microphone, which is a significant and valuable feature. My review has identified a few critical and high-severity issues that should be addressed. On the backend, there are blocking I/O calls in async functions which will degrade performance. On the client-side, there's a critical bug where the speech profile is marked as saved even if the upload fails. Additionally, the logic to detect if a user has answered a question is overly simplistic and doesn't use the new AI-powered backend endpoint, which could lead to a poor user experience. Addressing these points will improve the robustness and performance of this new onboarding flow.

Comment on lines 485 to 498
try {
await uploadProfile(data.item1);
} catch (e) {}
await uploadProfile(data.item1).timeout(
const Duration(seconds: 30),
onTimeout: () {
debugPrint('Profile upload timed out after 30 seconds');
return false; // Return false on timeout
},
);
debugPrint('Profile upload completed');
} catch (e) {
debugPrint('Error uploading profile: $e');
}

updateLoadingText('Personalizing your experience...');
SharedPreferencesUtil().hasSpeakerProfile = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There's a critical bug in the finalize method. The hasSpeakerProfile preference is set to true regardless of whether the uploadProfile call succeeds, fails, or times out. The result of the timeout operation is not being checked. This will lead to a state where the app believes a speech profile exists when it was never successfully uploaded, which can cause issues later.

      bool profileUploaded = false;
      try {
        profileUploaded = await uploadProfile(data.item1).timeout(
          const Duration(seconds: 30),
          onTimeout: () {
            debugPrint('Profile upload timed out after 30 seconds');
            return false; // Return false on timeout
          },
        );
        if (profileUploaded) {
          debugPrint('Profile upload completed');
        }
      } catch (e) {
        debugPrint('Error uploading profile: $e');
        profileUploaded = false;
      }

      if (profileUploaded) {
        SharedPreferencesUtil().hasSpeakerProfile = true;
      }

Comment on lines +250 to +266
// Simple client-side answer detection: if user spoke at least 2 words, consider it answered
final wordCount = currentTranscriptForQuestion.trim().split(RegExp(r'\s+')).where((s) => s.isNotEmpty).length;
debugPrint('Answer detection: word count = $wordCount');

if (wordCount >= 2) {
debugPrint('Answer detection: User spoke $wordCount words. Moving to next question.');
// Save the answer
questions[currentQuestionIndex].answer = currentTranscriptForQuestion;
questions[currentQuestionIndex].isAnswered = true;

// Move to next question (this will reset all tracking)
_moveToNextQuestion();
} else {
debugPrint('Answer detection: Not enough words ($wordCount), waiting for more input...');
isProcessingAnswer = false;
notifyListeners();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The function _detectAnswerWithAI is misleadingly named as it doesn't use AI. It uses a simple word count (>= 2) to determine if a question is answered. This logic is not robust and can lead to a poor user experience by prematurely moving to the next question. For example, a two-word response to "What is your long-term goal?" is unlikely to be a complete answer.

You have already created a backend endpoint checkQuestionAnswered for this purpose. You should use it here to get a more accurate determination of whether the user has answered the question.

    final answered = await checkQuestionAnswered(currentQuestion, currentTranscriptForQuestion);

    if (answered == true) {
      debugPrint('Answer detection: AI confirmed answer. Moving to next question.');
      // Save the answer
      questions[currentQuestionIndex].answer = currentTranscriptForQuestion;
      questions[currentQuestionIndex].isAnswered = true;
      
      // Move to next question (this will reset all tracking)
      _moveToNextQuestion();
    } else {
      debugPrint('Answer detection: AI determined not answered, waiting for more input...');
      isProcessingAnswer = false;
      notifyListeners();
    }
References
  1. Prefer using existing helper functions over inlining their logic, especially when they handle complex cases like fallbacks or error handling. Inlining can introduce subtle bugs by missing parts of the original logic.

Comment thread backend/routers/onboarding.py Outdated
"""

try:
response = llm_mini.invoke(prompt)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The llm_mini.invoke() call is synchronous, which blocks the event loop in an async FastAPI route. This can severely degrade the performance of the application, especially under load. You should use the asynchronous version ainvoke() to perform the LLM call without blocking.

This aligns with the general rule: "In an async application, use asynchronous HTTP clients like httpx instead of synchronous ones like requests to avoid blocking the event loop and degrading performance." The same principle applies to LLM client calls.

Suggested change
response = llm_mini.invoke(prompt)
response = await llm_mini.ainvoke(prompt)
References
  1. In an async application, use asynchronous HTTP clients like httpx instead of synchronous ones like requests to avoid blocking the event loop and degrading performance.

Comment thread backend/routers/onboarding.py Outdated

Write a friendly, personalized overview that captures the key information shared. Return ONLY the overview text, nothing else."""

response = llm_mini.invoke(overview_prompt)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the check_question_answered endpoint, the llm_mini.invoke() call here is synchronous and will block the event loop in this async route. This can lead to performance issues. Please use the asynchronous ainvoke() method instead.

Suggested change
response = llm_mini.invoke(overview_prompt)
response = await llm_mini.ainvoke(overview_prompt)
References
  1. In an async application, use asynchronous HTTP clients like httpx instead of synchronous ones like requests to avoid blocking the event loop and degrading performance.

@beastoin

Copy link
Copy Markdown
Collaborator

It works, however i need help to


* make it faster (currently i have 5 second silence detection and request to AI, i’d prefer it to be conversation like chatgpt

* better transcription quality (accuracy is only 60%)

* sometimes skips words (very critical)
  
  If i don’t get help, im merging this tmrw
  
  
  
  cc @beastoin

haha i see. let me > btw what's wrong with > air wearable hard door lol

@beastoin

Copy link
Copy Markdown
Collaborator

good catch, AI

---
You want to:

1 Use WebSocket + MessageEvent in transcribe.py for real-time communication
2 No separate REST endpoints - Bad UX (extra roundtrips, delays)
3 Backend handles answer detection via the existing speech profile websocket

                                                  Flow:

1 App connects to speech profile websocket with onboarding_mode=true
2 User speaks, backend receives audio + transcripts
3 Backend detects 4 seconds silence → calls AI to check if answered
4 Backend sends MessageEvent back: {"type": "onboarding_answer_detected", "answered": true, "question_index": 0}
5 App receives event, moves to next question
6 When all questions done → create conversation/memories on backend side

                                           Implementation Plan:

Backend (transcribe.py):

• Add onboarding_mode query param to websocket
• Track questions + silence timer
• After 4s silence → AI check → send MessageEvent

App (SpeechProfileProvider):

• Handle new MessageEvent types (onboarding_answer_detected)
• Remove local answer detection logic (word count, REST calls)

Remove:

• routers/onboarding.py (REST endpoints)
• backend/http/api/onboarding.dart (API client)

--

@beastoin

Copy link
Copy Markdown
Collaborator

Bro @kodjima33, I tried my best in the limited time to make it better, so feel free to test the PR again. You can ask AI to make some adjustments to the experiences. You can also fine-tune the questions on the backend side in backend/utils/onboarding.py, whether they are static questions or the LLM-generated ones. Whatever adjustments you make, please test them carefully before merging.

P.S. bro, I appreciate your help. By the way, sorry, but this PR is bad and potentially harmful haha

@beastoin

beastoin commented Dec 23, 2025 •

Copy link
Copy Markdown
Collaborator

concerns need to be addressed so far:

  • the audio quality from the phone mic will not be as good as the audio quality from the device (omi devices, i mean). the speech profile might be affected.

  • the current approach is question-based, meaning if users answer all of the questions (they can skip), then they're done. however, the speech profile needs at least 30+ seconds to be effective for speaker (user) identification.

  • the audio from the mic might not be consistent with the audio from the device, so the speech profile might be off if users switch to using devices (from the mic) or other devices.

@beastoin
beastoin merged commit 5c61ab6 into main Dec 23, 2025
@beastoin
beastoin deleted the feature/onboarding-goals-questions branch December 23, 2025 02:47
@beastoin

beastoin commented Dec 23, 2025 •

Copy link
Copy Markdown
Collaborator

@kodjima33

Copy link
Copy Markdown
Collaborator Author

good but shoudl be improved:

  • memories should be created normally from conversation (no question-answer)
  • action items were not created (should be)
  • push Nik to replace retarded questions (50% of them are)

@kodjima33

Copy link
Copy Markdown
Collaborator Author

@beastoin

Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
…are#3859)

* feat: Add question-based onboarding with phone microphone

- Replace random phrase prompts with goal-oriented questions in speech profile
- Questions: age, location, work, long-term goals, monthly goals, daily plans
- Use phone microphone instead of Omi device for speech profiling
- Auto-detect when user finishes answering (5s silence + word count)
- Track transcript per question to avoid counting previous answers
- Auto-process conversation when user clicks 'All done'
- Create onboarding conversation and memories from user responses
- Flow: Rate App -> Speech Profile (skip device connection during onboarding)
- Add backend endpoint for AI-based answer detection (/v1/onboarding/check-answer)
- Add backend endpoint for onboarding conversation creation (/v1/onboarding/conversation)

* Integrate onboarding mode into transcribe.py websocket with WebSocket MessageEvents

* Enhance onboarding with single language and valid conversation source

* Enhance onboarding with more engaging questions and skip support

* Reduce silence check timer from 4 to 2 seconds

* Enhance onboarding with more engaging questions and skip functionality

---------

Co-authored-by: thịnh <[email protected]>
mdmohsin7 added a commit that referenced this pull request Aug 13, 2026
… session starts (#11505)

# fix(listen): send the first onboarding question when a speech-profile
session starts

## Problem

The speech profile page (onboarding and Settings > Profile > Speech
Profile) shows no question and its progress bar never moves. Audio still
streams and a conversation/recording appears later, so the session looks
half-alive.

The question flow is server-driven: the client renders whatever
`onboarding_question` event the backend pushes, and computes progress as
`question_index / total_questions`. PR #9853 split `transcribe.py` into
`routers/listen/`, and the split dropped the one-shot kickoff
`spawn(onboarding_handler.send_current_question(), ...)` that existed
since the flow shipped (#3859). `ListenSessionRuntime._bootstrap` still
constructs the `OnboardingHandler`, but nothing ever sends question 0 —
`OnboardingHandler.send_current_question` is only reachable after an
answer or a skip, which can never happen before the first question
exists. The client waits forever on an empty screen at 0%.

## Fix

Restore the kickoff at handler creation in `_bootstrap`, spawned through
the session task supervisor (same placement and semantics as the
pre-refactor code).

## Regression test

`test_bootstrap_sends_first_onboarding_question_before_any_audio` runs
the real `_bootstrap` with a real `OnboardingHandler` and a recording
websocket, and asserts that — with no segments having arrived — the
client receives exactly one `onboarding_question` event (question 0 of
`len(ONBOARDING_QUESTIONS)`) and the question transcript segment is
enqueued with the Omi speaker id. This test fails on `main` today and
would have caught the drop in #9853.

The existing `_bootstrap` onboarding test's stub handler grew a
`send_current_question` coroutine and a real task supervisor, since the
production path now calls it.

## Failure class

Failure-Class: none

No existing class matches "one-shot side effect dropped while splitting
a module"; this is the first known instance of that cause in this
subsystem, so it lands as an instance fix plus the behavioral guard test
above.

## Verification

- `BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-target.txt bash test.sh` (file =
`tests/unit/test_listen_runtime_regressions.py`): **20 passed**
(includes the new test and the two updated bootstrap tests).
- Full unit-suite run surfaced 7 unrelated files exiting status 1 with
**all assertions passing** (e.g. "13 passed" + status 1) — the fast-unit
CPU duration guard tripping under heavy parallel load on my machine;
those files pass when run normally and none touch the listen runtime.
- Not exercised against a live device end-to-end: the fix is
backend-only and the affected path needs a prod-like STT session; the
regression test drives the real `_bootstrap` + `OnboardingHandler`
wiring.

## Product invariants affected

none


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/11505?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants