jaizendra-netizen / talk-listen-ratio
PHP CLI and library: add up the seconds each speaker talked per call from a CSV you give, and show the rep's share of the talk time against minimum and maximum shares you set.
Package info
github.com/jaizendra-netizen/talk-listen-ratio
Type:project
pkg:composer/jaizendra-netizen/talk-listen-ratio
Requires
- php: >=8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-30 06:50:56 UTC
README
PHP command line tool and library. Give it a CSV with one row per speaking segment of a call: the call id, a speaker label and the number of seconds that speaker talked in that segment. The speaker whose label matches --rep-label (default rep) is your rep; every other label counts as others. For each call it adds up the seconds and shows rep seconds, others seconds, the total, the rep share of the talk time, the number of segments, the longest single rep segment and a flag: rep above max or rep below min, against a minimum and a maximum share you set (otherwise within). A call with no rep rows has a rep share of 0.0%; a call whose seconds are all 0 has no share (n/a) and no flag. Calls are sorted by rep share (highest first, then by call id). The summary counts the calls above, below and within, the overall rep share (rep seconds over all seconds of all calls), the median per-call rep share (for an even number of calls, the mean of the two middle values) and the p90 (nearest rank: the ceil(0.9 x n)-th smallest share); calls without a share are left out of the median and p90. Labels and call ids are compared without regard to case and the first spelling seen is shown. Percentages are rounded to 1 decimal, half away from zero; seconds are shown with up to 4 decimals. It adds up the seconds you give: it reads no transcript or audio, and it does not say what a good ratio is. The numbers describe your file.
Part of the OneGTMLab free GTM tools. Background on the idea: Outreach.
Install
composer require jaizendra-netizen/talk-listen-ratio
Use
Input is a CSV with the columns call_id, speaker and seconds. Column names are matched without regard to case, may be in any order, and extra columns are ignored; a UTF-8 BOM and CRLF line endings are fine. seconds is a plain non-negative number such as 45 or 50.5. Options, all set by you: --rep-label LABEL (default rep, matched without regard to case), --min-rep-share N (0 to 100, default 35) and --max-rep-share N (0 to 100, default 65; the minimum may not be above the maximum). A share exactly on an edge is within. The command stops at the first bad row and names it. A bad or negative number of seconds, an empty call_id or speaker, a missing column, a row with the wrong number of cells, a file with no rows, a share out of range, a minimum above the maximum or a blank --rep-label exits 1 with a message; an unreadable file, an unknown option or a missing argument exits 2.
$ php bin/talk-listen-ratio sample.csv --min-rep-share 35 --max-rep-share 65
rows read: 17, calls: 6, rep label: rep (set by you), min rep share: 35% (set by you), max rep share: 65% (set by you)
call-3: rep 70 s, others 30 s, total 100 s, rep share 70.0%, segments 3, longest rep segment 45 s, rep above max
call-6: rep 100 s, others 50 s, total 150 s, rep share 66.7%, segments 3, longest rep segment 60 s, rep above max
call-1: rep 120 s, others 80 s, total 200 s, rep share 60.0%, segments 4, longest rep segment 60 s, within
call-4: rep 50.5 s, others 49.5 s, total 100 s, rep share 50.5%, segments 2, longest rep segment 50.5 s, within
call-2: rep 30 s, others 70 s, total 100 s, rep share 30.0%, segments 3, longest rep segment 30 s, rep below min
call-5: rep 0 s, others 100 s, total 100 s, rep share 0.0%, segments 2, longest rep segment 0 s, rep below min
summary: calls 6, rep above max 2, rep below min 2, within 2
overall rep share (sum of seconds): 49.4%, median per-call rep share: 55.3%, p90 per-call rep share: 70.0%
Test
php tests/run.php
Offline, no network calls, no dependencies beyond the language runtime. MIT licensed.