Skip to content

Conversation

@mdmohsin7
Copy link
Member

Summary

  • Usage tracking was recording wall-clock elapsed time (every 60s) as transcription_seconds regardless of whether any speech was actually transcribed
  • This caused free-tier/basic plan users to burn through their monthly minute quota while the device was idle or picking up only silence
  • Example: a user showing 25 minutes of actual transcription but 246 minutes of "used" quota

Root Cause

In _record_usage_periodically() and the finally cleanup block, the condition was:

if transcription_seconds > 0 or words_to_record > 0:
    record_usage(...)

Since transcription_seconds is wall-clock elapsed time (always > 0), usage was always recorded even when words_to_record == 0 (no speech in that interval).

Fix

Changed the condition to only record usage when words were actually transcribed:

if words_to_record > 0:
    record_usage(...)

The transcription_seconds still reflects the time window those words arrived in, which is a reasonable measure of active listening time — it just no longer records seconds for periods of pure silence.

Test plan

  • Backend tests pass
  • Verify free-tier user's monthly usage only increments when speech is detected
  • Confirm usage page shows accurate minutes after idle periods

🤖 Generated with Claude Code

Usage was recording wall-clock elapsed time every 60s regardless of
whether any speech was transcribed, causing free-tier users to burn
through their monthly minute quota while the device was idle/silent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mdmohsin7 mdmohsin7 requested a review from beastoin February 8, 2026 15:45
Copy link
Contributor

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

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 correctly addresses a critical bug in usage tracking where idle time was being counted towards a user's transcription quota. The change to only record usage when words are actually transcribed is a direct and effective fix. The modification has been applied consistently in both the periodic usage recording and the final cleanup logic, ensuring that users are no longer incorrectly charged for periods of silence. The code is clean and the fix is well-explained in the summary. This is a solid improvement.

@beastoin
Copy link
Collaborator

beastoin commented Feb 9, 2026

How does Deegram charge us?

@beastoin
Copy link
Collaborator

Connection: This PR directly fixes P1 #4700 — "Listening minutes increase while device is OFF + app closed"

Re: @beastoin's question on Deepgram billing:

Deepgram charges per audio duration streamed — not per word or per API call. As long as the WebSocket connection is open and sending audio frames, Deepgram bills for that time, regardless of whether speech is detected.

Two separate concerns here:

  1. User-facing quota (this PR fixes): Users' free-tier/basic plan minutes were counting wall-clock time instead of active transcription time. This PR correctly gates record_usage() on words_to_record > 0.
  2. Deepgram cost to us (separate issue): Deepgram still charges for full stream duration including silence. The cost reduction for that is addressed by #4644 (auto-pause on silent connections).

This PR is the right fix for the user-facing billing bug — +2/-2, minimal risk.

@Chen (RepoOps)

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