Commit 0a4c613
committed
fix(expressive): correctness and pacing fixes for transcript markup stripping
Addresses the issues found reviewing this branch:
- room output: rotate segments by opening the replacement writer before
closing the current one, so a failed stream_text no longer strands
self._writer on a closed writer and drops the rest of the turn.
- room output: record _latest_text before the isconnected() check, so a
brief disconnect no longer finalizes the turn with an earlier chunk.
- room output: lk.expression rides the opening header only, matching the
ATTRIBUTE_TRANSCRIPTION_EXPRESSION docstring (drops the closing-header
fallback that contradicted it).
- markup: vanish_trail now sees the character preceding a tag in the
OUTPUT (new scan_and_replace helper plus a prev_char threaded through
split_all_markup/_split_expr/extract_and_strip). Fixes words gluing
across chunk boundaries (Ready.Go) and stacked markers leaving a
doubled space.
- markup: _emit strips only spaces/tabs, so newlines and indentation
straddling a chunk boundary survive in every delta transcript.
- markup: the stripper holds only the partial tag, not the text in front
of it, so words spoken before a marker stay in the current segment and
a tag-shaped angle bracket no longer stalls the turn until flush.
- markup: strip_all_markup takes an opt-in drop_open_tail. It was applied
to every input, truncating complete text in final transcripts and in
stored chat history.
- synchronizer: _visible_hyphens advances a cursor instead of re-stripping
and re-hyphenating the whole prefix twice per word. An 800-word turn
drops from 4.40s to 0.0145s of blocking CPU with identical counts, and
no longer needs prefix truncation.
Adds 19 tests, including a property test asserting streaming output
matches whole-text stripping at every 2- and 3-way split.1 parent 7c8d07f commit 0a4c613
5 files changed
Lines changed: 273 additions & 62 deletions
File tree
- livekit-agents/livekit/agents
- tts
- voice
- room_io
- transcription
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
752 | 757 | | |
753 | 758 | | |
754 | 759 | | |
755 | | - | |
| 760 | + | |
756 | 761 | | |
757 | 762 | | |
758 | 763 | | |
| |||
766 | 771 | | |
767 | 772 | | |
768 | 773 | | |
769 | | - | |
| 774 | + | |
770 | 775 | | |
771 | 776 | | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
776 | 786 | | |
777 | 787 | | |
778 | 788 | | |
| |||
891 | 901 | | |
892 | 902 | | |
893 | 903 | | |
894 | | - | |
| 904 | + | |
895 | 905 | | |
896 | 906 | | |
897 | 907 | | |
| |||
909 | 919 | | |
910 | 920 | | |
911 | 921 | | |
912 | | - | |
913 | | - | |
| 922 | + | |
| 923 | + | |
914 | 924 | | |
915 | 925 | | |
916 | 926 | | |
| |||
942 | 952 | | |
943 | 953 | | |
944 | 954 | | |
945 | | - | |
| 955 | + | |
946 | 956 | | |
947 | 957 | | |
948 | | - | |
949 | | - | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
950 | 964 | | |
951 | | - | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
952 | 968 | | |
953 | 969 | | |
954 | 970 | | |
| |||
1001 | 1017 | | |
1002 | 1018 | | |
1003 | 1019 | | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1008 | 1023 | | |
1009 | 1024 | | |
1010 | 1025 | | |
| |||
1013 | 1028 | | |
1014 | 1029 | | |
1015 | 1030 | | |
1016 | | - | |
1017 | | - | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
1018 | 1035 | | |
1019 | | - | |
| 1036 | + | |
1020 | 1037 | | |
1021 | 1038 | | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
1022 | 1048 | | |
1023 | 1049 | | |
1024 | 1050 | | |
1025 | 1051 | | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
1031 | 1056 | | |
1032 | 1057 | | |
1033 | 1058 | | |
1034 | 1059 | | |
1035 | 1060 | | |
1036 | | - | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
| 1061 | + | |
1040 | 1062 | | |
1041 | 1063 | | |
1042 | 1064 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
20 | 51 | | |
21 | 52 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
25 | 60 | | |
26 | | - | |
| 61 | + | |
27 | 62 | | |
28 | 63 | | |
29 | 64 | | |
30 | 65 | | |
31 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
32 | 69 | | |
33 | 70 | | |
34 | 71 | | |
| |||
46 | 83 | | |
47 | 84 | | |
48 | 85 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
53 | 89 | | |
54 | 90 | | |
55 | 91 | | |
56 | 92 | | |
| 93 | + | |
| 94 | + | |
57 | 95 | | |
58 | 96 | | |
59 | 97 | | |
| |||
71 | 109 | | |
72 | 110 | | |
73 | 111 | | |
74 | | - | |
| 112 | + | |
75 | 113 | | |
76 | 114 | | |
77 | 115 | | |
| |||
84 | 122 | | |
85 | 123 | | |
86 | 124 | | |
87 | | - | |
| 125 | + | |
88 | 126 | | |
89 | | - | |
| 127 | + | |
90 | 128 | | |
91 | 129 | | |
92 | 130 | | |
| |||
96 | 134 | | |
97 | 135 | | |
98 | 136 | | |
99 | | - | |
| 137 | + | |
100 | 138 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
| 282 | + | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
| 484 | + | |
488 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
489 | 489 | | |
490 | | - | |
491 | | - | |
492 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
493 | 499 | | |
494 | 500 | | |
495 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
496 | 507 | | |
497 | 508 | | |
498 | 509 | | |
| |||
548 | 559 | | |
549 | 560 | | |
550 | 561 | | |
551 | | - | |
| 562 | + | |
552 | 563 | | |
| 564 | + | |
| 565 | + | |
553 | 566 | | |
554 | 567 | | |
| 568 | + | |
| 569 | + | |
555 | 570 | | |
556 | 571 | | |
557 | 572 | | |
| |||
587 | 602 | | |
588 | 603 | | |
589 | 604 | | |
590 | | - | |
591 | | - | |
592 | | - | |
| 605 | + | |
593 | 606 | | |
594 | 607 | | |
595 | 608 | | |
| |||
600 | 613 | | |
601 | 614 | | |
602 | 615 | | |
603 | | - | |
604 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
605 | 619 | | |
606 | 620 | | |
607 | 621 | | |
| |||
0 commit comments