k2py 0.2.1__cp313-cp313-win_amd64.whl → 0.2.4__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
k2py/__init__.py CHANGED
@@ -35,7 +35,18 @@ class AlignedToken:
35
35
 
36
36
  class OnlineDenseIntersecter(_OnlineDenseIntersecter):
37
37
  """Wrapper around C++ OnlineDenseIntersecter to produce Python-friendly results."""
38
-
38
+
39
+ def get_partial_labels(self) -> List[int]:
40
+ """Get partial per-frame labels for streaming confidence calculation.
41
+
42
+ Returns per-frame token IDs from the current lattice state.
43
+ Used for computing emission-based confidence scores in streaming mode.
44
+
45
+ Returns:
46
+ List of token IDs, one per frame.
47
+ """
48
+ return list(super().get_partial_labels())
49
+
39
50
  def finish(self) -> Tuple[List[List["AlignedToken"]], List[List[int]]]:
40
51
  """Finish decoding and return results including AlignedToken objects.
41
52
 
@@ -69,9 +80,10 @@ def AlignSegments(
69
80
  min_active_states: int,
70
81
  max_active_states: int,
71
82
  use_double_scores: bool = True,
83
+ allow_partial: bool = True,
72
84
  ) -> Tuple[List[List["AlignedToken"]], List[List[int]]]:
73
85
  """Align segments using offline dense intersection.
74
-
86
+
75
87
  Args:
76
88
  graph_result: Dictionary returned by CreateFsaVecFromStr
77
89
  scores: Numpy array of scores (rows, cols)
@@ -80,14 +92,16 @@ def AlignSegments(
80
92
  min_active_states: Minimum active states
81
93
  max_active_states: Maximum active states
82
94
  use_double_scores: Whether to use double precision for scores
83
-
95
+ allow_partial: If True, treat all states on last frame as final
96
+ when no final state is active. Default True.
97
+
84
98
  Returns:
85
99
  A tuple containing:
86
100
  - results: List of List of AlignedToken objects (wrapped in list for batch consistency)
87
101
  - labels: List of List of timestamps (wrapped in list for batch consistency)
88
102
  """
89
103
  from ._k2 import AlignSegments as _AlignSegments
90
-
104
+
91
105
  final_result = _AlignSegments(
92
106
  graph_result,
93
107
  scores,
@@ -95,7 +109,8 @@ def AlignSegments(
95
109
  output_beam,
96
110
  min_active_states,
97
111
  max_active_states,
98
- use_double_scores
112
+ use_double_scores,
113
+ allow_partial,
99
114
  )
100
115
 
101
116
  # Convert to AlignedToken objects
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: k2py
3
- Version: 0.2.1
3
+ Version: 0.2.4
4
4
  Summary: Python bindings for k2
5
5
  Keywords: k2,forced-alignment,speech,asr
6
6
  Author: The LattifAI Development Team
@@ -0,0 +1,5 @@
1
+ k2py/__init__.py,sha256=KR-D9Luea5f6G6-O9pHsQoJTPH7kn2zLwuFXSIDs-M8,4741
2
+ k2py/_k2.cp313-win_amd64.pyd,sha256=-lcy3zKedUlNvy703SY73hQg8timFpPk3IHoqB2ZgI8,680448
3
+ k2py-0.2.4.dist-info/METADATA,sha256=YZxTxwdJp7Hawm0YeUP1tPYebyv0Lbc17TB2hjgO8OY,2306
4
+ k2py-0.2.4.dist-info/WHEEL,sha256=vkL3wTIkhjZa3RmEXX20hldNp6Q8qtwRjrXW6K5sw_Q,106
5
+ k2py-0.2.4.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- k2py/__init__.py,sha256=fD-0RgkT-0zda8QSVWiDkTnRqyvgv3t9ZejCFdB4qRU,4151
2
- k2py/_k2.cp313-win_amd64.pyd,sha256=jHcGH06bG7RusyhzVbaV23ht2Knedz_524dOyVcjfvU,676864
3
- k2py-0.2.1.dist-info/METADATA,sha256=WZj7TvtzS_CVPsCWiQexJhu2JIE727HBgur1ZuCBatw,2306
4
- k2py-0.2.1.dist-info/WHEEL,sha256=vkL3wTIkhjZa3RmEXX20hldNp6Q8qtwRjrXW6K5sw_Q,106
5
- k2py-0.2.1.dist-info/RECORD,,
File without changes