paisa-parse 0.1.0__tar.gz
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.
- paisa_parse-0.1.0/.github/workflows/ci.yml +29 -0
- paisa_parse-0.1.0/.gitignore +13 -0
- paisa_parse-0.1.0/LICENSE +21 -0
- paisa_parse-0.1.0/PKG-INFO +202 -0
- paisa_parse-0.1.0/PUBLISHING.md +60 -0
- paisa_parse-0.1.0/README.md +164 -0
- paisa_parse-0.1.0/benchmarks/RESULTS.md +24 -0
- paisa_parse-0.1.0/benchmarks/results.json +60 -0
- paisa_parse-0.1.0/benchmarks/run_benchmark.py +232 -0
- paisa_parse-0.1.0/benchmarks/stress_test.json +831 -0
- paisa_parse-0.1.0/examples/livekit_demo.py +25 -0
- paisa_parse-0.1.0/examples/mcp_client_demo.py +18 -0
- paisa_parse-0.1.0/examples/pipecat_demo.py +23 -0
- paisa_parse-0.1.0/pyproject.toml +79 -0
- paisa_parse-0.1.0/src/paisa_parse/__init__.py +37 -0
- paisa_parse-0.1.0/src/paisa_parse/cli.py +102 -0
- paisa_parse-0.1.0/src/paisa_parse/engine.py +141 -0
- paisa_parse-0.1.0/src/paisa_parse/integrations/__init__.py +28 -0
- paisa_parse-0.1.0/src/paisa_parse/integrations/livekit.py +132 -0
- paisa_parse-0.1.0/src/paisa_parse/integrations/mcp_server.py +95 -0
- paisa_parse-0.1.0/src/paisa_parse/integrations/pipecat.py +101 -0
- paisa_parse-0.1.0/src/paisa_parse/lexicon.py +620 -0
- paisa_parse-0.1.0/src/paisa_parse/parsers/__init__.py +8 -0
- paisa_parse-0.1.0/src/paisa_parse/parsers/amount.py +495 -0
- paisa_parse-0.1.0/src/paisa_parse/parsers/digits.py +275 -0
- paisa_parse-0.1.0/src/paisa_parse/parsers/ifsc.py +429 -0
- paisa_parse-0.1.0/src/paisa_parse/parsers/upi.py +599 -0
- paisa_parse-0.1.0/src/paisa_parse/policy.py +180 -0
- paisa_parse-0.1.0/src/paisa_parse/types.py +113 -0
- paisa_parse-0.1.0/tests/test_amounts.py +93 -0
- paisa_parse-0.1.0/tests/test_cli_and_benchmark.py +60 -0
- paisa_parse-0.1.0/tests/test_digits.py +69 -0
- paisa_parse-0.1.0/tests/test_engine_and_policy.py +55 -0
- paisa_parse-0.1.0/tests/test_ifsc.py +35 -0
- paisa_parse-0.1.0/tests/test_integrations.py +216 -0
- paisa_parse-0.1.0/tests/test_upi.py +40 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test-and-benchmark:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.12", "3.13"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- name: Install dev dependencies and package
|
|
21
|
+
run: |
|
|
22
|
+
python -m pip install --upgrade pip
|
|
23
|
+
pip install -e ".[dev]"
|
|
24
|
+
- name: Lint with ruff
|
|
25
|
+
run: ruff check src tests benchmarks examples
|
|
26
|
+
- name: Run unit tests
|
|
27
|
+
run: pytest -v
|
|
28
|
+
- name: Run stress-test benchmark gate
|
|
29
|
+
run: python benchmarks/run_benchmark.py --check
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 paisa-parse contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: paisa-parse
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Hinglish & Indian-English spoken financial entity parser with confidence scores, confirm-back policy, and Pipecat/LiveKit/MCP integrations.
|
|
5
|
+
Project-URL: Homepage, https://github.com/paisa-parse/paisa-parse
|
|
6
|
+
Project-URL: Repository, https://github.com/paisa-parse/paisa-parse
|
|
7
|
+
Project-URL: Issues, https://github.com/paisa-parse/paisa-parse/issues
|
|
8
|
+
Author: paisa-parse contributors
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: hinglish,ifsc,indian-english,inverse-text-normalization,itn,livekit,mcp,pipecat,upi,voice-ai
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Provides-Extra: all
|
|
25
|
+
Requires-Dist: livekit-agents>=1.0.0; extra == 'all'
|
|
26
|
+
Requires-Dist: mcp>=1.0.0; extra == 'all'
|
|
27
|
+
Requires-Dist: pipecat-ai>=0.0.50; extra == 'all'
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.8; extra == 'dev'
|
|
31
|
+
Provides-Extra: livekit
|
|
32
|
+
Requires-Dist: livekit-agents>=1.0.0; extra == 'livekit'
|
|
33
|
+
Provides-Extra: mcp
|
|
34
|
+
Requires-Dist: mcp>=1.0.0; extra == 'mcp'
|
|
35
|
+
Provides-Extra: pipecat
|
|
36
|
+
Requires-Dist: pipecat-ai>=0.0.50; extra == 'pipecat'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# paisa-parse
|
|
40
|
+
|
|
41
|
+
**Zero-dependency Hinglish & Indian-English spoken financial entity parser** with confidence scores, a confirm-back policy, and drop-in plugins for **Pipecat**, **LiveKit Agents**, and **MCP**.
|
|
42
|
+
|
|
43
|
+
Turns noisy ASR transcripts into structured Indian financial values:
|
|
44
|
+
|
|
45
|
+
- `"dedh lakh"` -> `Decimal("150000")`, formatted `"₹1,50,000"`, `action="confirm"` (`high_value_threshold`)
|
|
46
|
+
- `"paune do hazaar"` -> `Decimal("1750")`, formatted `"₹1,750"`
|
|
47
|
+
- `"nau aath saat chhe paanch chaar teen do ek shunya"` -> `"9876543210"` (`subtype="phone"`)
|
|
48
|
+
- `"rahul dot verma at ok icici"` -> `"rahul.verma@okicici"` (validated against ~75 NPCI PSP handles)
|
|
49
|
+
- `"IFSC SBIN triple zero ek do teen chaar"` -> `"SBIN0001234"` (RBI structure + bank prefix check + 5th-char `O->0` repair)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
Core library (pure Python 3.10+, **zero runtime dependencies**):
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install paisa-parse
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
With optional voice-agent / tool integrations:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install "paisa-parse[pipecat]"
|
|
65
|
+
pip install "paisa-parse[livekit]"
|
|
66
|
+
pip install "paisa-parse[mcp]"
|
|
67
|
+
pip install "paisa-parse[all]"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Quickstart
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from paisa_parse import ConfirmPolicy, parse
|
|
76
|
+
|
|
77
|
+
result = parse(
|
|
78
|
+
"bhai rahul dot verma at ok icici pe dedh lakh bhej do",
|
|
79
|
+
policy=ConfirmPolicy.balanced(language="hinglish"),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
print(result.normalized_text)
|
|
83
|
+
# bhai rahul.verma@okicici pe ₹1,50,000 bhej do
|
|
84
|
+
|
|
85
|
+
for entity in result.entities:
|
|
86
|
+
print(entity.kind.value, entity.value, entity.confidence, entity.action.value)
|
|
87
|
+
if entity.confirm_prompt:
|
|
88
|
+
print(" TTS confirm-back:", entity.confirm_prompt)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Confirm-Back Policy Presets
|
|
92
|
+
|
|
93
|
+
Voice agents should not blindly execute a `₹1,50,000` transfer or trust an ambiguous ASR token like `"ded sau"` or `"SBINO001234"`. `ConfirmPolicy` outputs one of three actions (`accept`, `confirm`, `reprompt`) plus a TTS-ready `confirm_prompt` in `"en-IN"` or `"hinglish"`:
|
|
94
|
+
|
|
95
|
+
- `ConfirmPolicy.balanced()` (default): auto-accept `>= 0.85`, confirm `0.55–0.85` or amounts `>= ₹50,000`, reprompt `< 0.55`.
|
|
96
|
+
- `ConfirmPolicy.strict()`: always confirms `upi_id` and `ifsc`, and escalates amounts `>= ₹10,000`.
|
|
97
|
+
- `ConfirmPolicy.permissive()`: lower friction (`accept >= 0.75`, `high_value >= ₹5,00,000`).
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Framework Integrations
|
|
102
|
+
|
|
103
|
+
### 1. Pipecat (`FrameProcessor`)
|
|
104
|
+
|
|
105
|
+
Place `PaisaParseProcessor` right after your STT service in a Pipecat pipeline (`examples/pipecat_demo.py`):
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from paisa_parse import ConfirmPolicy
|
|
109
|
+
from paisa_parse.integrations.pipecat import PaisaParseProcessor
|
|
110
|
+
|
|
111
|
+
processor = PaisaParseProcessor(
|
|
112
|
+
policy=ConfirmPolicy.balanced(language="hinglish"),
|
|
113
|
+
mode="annotate", # "annotate" | "replace" | "callback_only"
|
|
114
|
+
)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 2. LiveKit Agents (`Agent` mixin & `stt_node` hook)
|
|
118
|
+
|
|
119
|
+
Attach `PaisaParseAgentMixin` to your `livekit.agents.Agent` subclass (`examples/livekit_demo.py`):
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from livekit.agents import Agent
|
|
123
|
+
from paisa_parse import ConfirmPolicy
|
|
124
|
+
from paisa_parse.integrations.livekit import PaisaParseAgentMixin, PaisaParseHook
|
|
125
|
+
|
|
126
|
+
class HinglishBankingAgent(PaisaParseAgentMixin, Agent):
|
|
127
|
+
def __init__(self) -> None:
|
|
128
|
+
super().__init__()
|
|
129
|
+
self.paisa_hook = PaisaParseHook(
|
|
130
|
+
policy=ConfirmPolicy.strict(language="en-IN"),
|
|
131
|
+
inject_context=True,
|
|
132
|
+
)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 3. Model Context Protocol (MCP) Server
|
|
136
|
+
|
|
137
|
+
Run over stdio:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
paisa-parse-mcp
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Exposes four tools: `tool_parse_financial_text`, `tool_parse_amount`, `tool_validate_upi_id`, and `tool_validate_ifsc_code`.
|
|
144
|
+
|
|
145
|
+
### 4. CLI
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
paisa-parse "bhai rahul dot verma at ok icici pe dedh lakh bhej do, IFSC SBIN triple zero ek do teen chaar" --json
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Prior Art & Differentiation
|
|
154
|
+
|
|
155
|
+
**NVIDIA NeMo Text Processing** provides mature WFST-based Inverse Text Normalization (ITN) for Devanagari Hindi (`hi`), and is the right tool if you want general-purpose sentence-level WFST normalization inside a NeMo/Riva stack.
|
|
156
|
+
|
|
157
|
+
`paisa-parse` targets a distinct, voice-agent-specific gap:
|
|
158
|
+
|
|
159
|
+
1. **Romanized Hinglish + Mixed Indian-English**: handles what Whisper, Deepgram, Sarvam, and Google STT emit in practice (`dedh lakh`, `sava do crore`, `chhattees hazaar`, `teen baar shunya`, `rahul dot verma at ok icici`), alongside Devanagari digits/words.
|
|
160
|
+
2. **Colloquial Indian Fractions**: native support for `dedh` (1.5), `dhai` (2.5), `sava` (+0.25), `paune` (-0.25), `saade` (+0.5), `aadha` (0.5), and `paav` (0.25) across Indian scales.
|
|
161
|
+
3. **Domain Validators**: UPI ID parsing with ~75 NPCI PSP handles (and email rejection) plus 11-character IFSC parsing with RBI bank prefixes and 5th-character `O -> 0` repair.
|
|
162
|
+
4. **Confidence + Confirm-Back Policy**: calibrates confidence for ASR ambiguities (`oh` -> `0`, `so` -> `100`, unknown PSP/bank, truncated phone/IFSC) and produces ready-to-speak `accept` / `confirm` / `reprompt` prompts.
|
|
163
|
+
5. **Zero-Dependency Portability**: pure Python (`pip install paisa-parse`), sub-millisecond latency, with native Pipecat, LiveKit Agents, and MCP adapters.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Stress-Test Benchmark Results
|
|
168
|
+
|
|
169
|
+
Evaluated on [`benchmarks/stress_test.json`](benchmarks/stress_test.json) (130 realistic & adversarial Hinglish financial utterances across 7 categories) using `python benchmarks/run_benchmark.py --no-write`:
|
|
170
|
+
|
|
171
|
+
- **Utterance Exact-Match Accuracy**: **100.00%** (`130/130`)
|
|
172
|
+
- **Entity Precision / Recall / F1**: **1.0000 / 1.0000 / 1.0000** (`TP=134, FP=0, FN=0`)
|
|
173
|
+
- **Confirm-Back Policy Accuracy**: **100.00%** (`134` matched entities)
|
|
174
|
+
- **Latency**: p50 = **0.250 ms**, p95 = **0.544 ms**, p99 = **0.809 ms**
|
|
175
|
+
|
|
176
|
+
| Category | Exact / Total | Accuracy |
|
|
177
|
+
| --- | ---: | ---: |
|
|
178
|
+
| `colloquial_fractions` | 25 / 25 | 100.00% |
|
|
179
|
+
| `compound_amounts` | 20 / 20 | 100.00% |
|
|
180
|
+
| `spoken_digits` | 20 / 20 | 100.00% |
|
|
181
|
+
| `upi_ids` | 20 / 20 | 100.00% |
|
|
182
|
+
| `ifsc_codes` | 15 / 15 | 100.00% |
|
|
183
|
+
| `multi_entity` | 15 / 15 | 100.00% |
|
|
184
|
+
| `adversarial_negatives` | 15 / 15 | 100.00% |
|
|
185
|
+
|
|
186
|
+
> **Scope note**: `stress_test.json` is an author-curated stress suite (not an external multi-vendor ASR corpus). Real-world audio transcripts with unseen regional spellings or severe acoustic misrecognitions may score lower; contributions of real failure utterances are welcome.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Adoption & Community Status (Honest Reporting)
|
|
191
|
+
|
|
192
|
+
Current status as of **v0.1.0** (pre-publish local release):
|
|
193
|
+
|
|
194
|
+
- **PyPI Downloads**: `0` (package not yet uploaded to PyPI; see [`PUBLISHING.md`](PUBLISHING.md) for upload steps)
|
|
195
|
+
- **GitHub Stars / Open Issues**: `0 stars / 0 issues` (repository not yet pushed publicly)
|
|
196
|
+
- **Pipecat / LiveKit Community Listings**: `Pending submission` (adapters and demos included; community PR/listing links will be added once published)
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Publishing & Community Launch Checklist
|
|
2
|
+
|
|
3
|
+
This guide covers releasing `paisa-parse` to PyPI, listing the adapters on Pipecat & LiveKit community pages, and tracking honest adoption numbers.
|
|
4
|
+
|
|
5
|
+
## 1. Pre-Publish Verification
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
ruff check src tests benchmarks examples
|
|
9
|
+
pytest -v
|
|
10
|
+
python benchmarks/run_benchmark.py --check
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 2. Build & Upload to PyPI
|
|
14
|
+
|
|
15
|
+
Install build/publish tooling (or use `uv`):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
python -m pip install --upgrade build twine
|
|
19
|
+
python -m build
|
|
20
|
+
twine check dist/*
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Test on TestPyPI first:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
twine upload --repository testpypi dist/*
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Publish to PyPI:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
twine upload dist/*
|
|
33
|
+
# Or with uv:
|
|
34
|
+
# uv build && uv publish
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Verify fresh install in a clean environment:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install paisa-parse
|
|
41
|
+
paisa-parse "bhai dedh lakh bhej do rahul dot verma at ok icici pe" --json
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 3. Submit to Pipecat & LiveKit Community Pages
|
|
45
|
+
|
|
46
|
+
1. **Pipecat**: Open a PR or community showcase post linking `PaisaParseProcessor` (`src/paisa_parse/integrations/pipecat.py`) and `examples/pipecat_demo.py`.
|
|
47
|
+
2. **LiveKit Agents**: Share `PaisaParseHook` and `PaisaParseAgentMixin` (`src/paisa_parse/integrations/livekit.py`) in the LiveKit community plugins/recipes forum or showcase PR.
|
|
48
|
+
3. **MCP Registry / Directories**: Submit `paisa-parse-mcp` (`src/paisa_parse/integrations/mcp_server.py`) with its four tool schemas.
|
|
49
|
+
|
|
50
|
+
## 4. Track Real Usage Numbers Honestly
|
|
51
|
+
|
|
52
|
+
Once published, record real metrics in `README.md`:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install pypistats
|
|
56
|
+
pypistats recent paisa-parse
|
|
57
|
+
pypistats overall paisa-parse
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Update `README.md` with actual PyPI download counts, GitHub stars/issues, and live community listing URLs.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# paisa-parse
|
|
2
|
+
|
|
3
|
+
**Zero-dependency Hinglish & Indian-English spoken financial entity parser** with confidence scores, a confirm-back policy, and drop-in plugins for **Pipecat**, **LiveKit Agents**, and **MCP**.
|
|
4
|
+
|
|
5
|
+
Turns noisy ASR transcripts into structured Indian financial values:
|
|
6
|
+
|
|
7
|
+
- `"dedh lakh"` -> `Decimal("150000")`, formatted `"₹1,50,000"`, `action="confirm"` (`high_value_threshold`)
|
|
8
|
+
- `"paune do hazaar"` -> `Decimal("1750")`, formatted `"₹1,750"`
|
|
9
|
+
- `"nau aath saat chhe paanch chaar teen do ek shunya"` -> `"9876543210"` (`subtype="phone"`)
|
|
10
|
+
- `"rahul dot verma at ok icici"` -> `"rahul.verma@okicici"` (validated against ~75 NPCI PSP handles)
|
|
11
|
+
- `"IFSC SBIN triple zero ek do teen chaar"` -> `"SBIN0001234"` (RBI structure + bank prefix check + 5th-char `O->0` repair)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Core library (pure Python 3.10+, **zero runtime dependencies**):
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install paisa-parse
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
With optional voice-agent / tool integrations:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install "paisa-parse[pipecat]"
|
|
27
|
+
pip install "paisa-parse[livekit]"
|
|
28
|
+
pip install "paisa-parse[mcp]"
|
|
29
|
+
pip install "paisa-parse[all]"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quickstart
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from paisa_parse import ConfirmPolicy, parse
|
|
38
|
+
|
|
39
|
+
result = parse(
|
|
40
|
+
"bhai rahul dot verma at ok icici pe dedh lakh bhej do",
|
|
41
|
+
policy=ConfirmPolicy.balanced(language="hinglish"),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
print(result.normalized_text)
|
|
45
|
+
# bhai rahul.verma@okicici pe ₹1,50,000 bhej do
|
|
46
|
+
|
|
47
|
+
for entity in result.entities:
|
|
48
|
+
print(entity.kind.value, entity.value, entity.confidence, entity.action.value)
|
|
49
|
+
if entity.confirm_prompt:
|
|
50
|
+
print(" TTS confirm-back:", entity.confirm_prompt)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Confirm-Back Policy Presets
|
|
54
|
+
|
|
55
|
+
Voice agents should not blindly execute a `₹1,50,000` transfer or trust an ambiguous ASR token like `"ded sau"` or `"SBINO001234"`. `ConfirmPolicy` outputs one of three actions (`accept`, `confirm`, `reprompt`) plus a TTS-ready `confirm_prompt` in `"en-IN"` or `"hinglish"`:
|
|
56
|
+
|
|
57
|
+
- `ConfirmPolicy.balanced()` (default): auto-accept `>= 0.85`, confirm `0.55–0.85` or amounts `>= ₹50,000`, reprompt `< 0.55`.
|
|
58
|
+
- `ConfirmPolicy.strict()`: always confirms `upi_id` and `ifsc`, and escalates amounts `>= ₹10,000`.
|
|
59
|
+
- `ConfirmPolicy.permissive()`: lower friction (`accept >= 0.75`, `high_value >= ₹5,00,000`).
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Framework Integrations
|
|
64
|
+
|
|
65
|
+
### 1. Pipecat (`FrameProcessor`)
|
|
66
|
+
|
|
67
|
+
Place `PaisaParseProcessor` right after your STT service in a Pipecat pipeline (`examples/pipecat_demo.py`):
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from paisa_parse import ConfirmPolicy
|
|
71
|
+
from paisa_parse.integrations.pipecat import PaisaParseProcessor
|
|
72
|
+
|
|
73
|
+
processor = PaisaParseProcessor(
|
|
74
|
+
policy=ConfirmPolicy.balanced(language="hinglish"),
|
|
75
|
+
mode="annotate", # "annotate" | "replace" | "callback_only"
|
|
76
|
+
)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 2. LiveKit Agents (`Agent` mixin & `stt_node` hook)
|
|
80
|
+
|
|
81
|
+
Attach `PaisaParseAgentMixin` to your `livekit.agents.Agent` subclass (`examples/livekit_demo.py`):
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from livekit.agents import Agent
|
|
85
|
+
from paisa_parse import ConfirmPolicy
|
|
86
|
+
from paisa_parse.integrations.livekit import PaisaParseAgentMixin, PaisaParseHook
|
|
87
|
+
|
|
88
|
+
class HinglishBankingAgent(PaisaParseAgentMixin, Agent):
|
|
89
|
+
def __init__(self) -> None:
|
|
90
|
+
super().__init__()
|
|
91
|
+
self.paisa_hook = PaisaParseHook(
|
|
92
|
+
policy=ConfirmPolicy.strict(language="en-IN"),
|
|
93
|
+
inject_context=True,
|
|
94
|
+
)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 3. Model Context Protocol (MCP) Server
|
|
98
|
+
|
|
99
|
+
Run over stdio:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
paisa-parse-mcp
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Exposes four tools: `tool_parse_financial_text`, `tool_parse_amount`, `tool_validate_upi_id`, and `tool_validate_ifsc_code`.
|
|
106
|
+
|
|
107
|
+
### 4. CLI
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
paisa-parse "bhai rahul dot verma at ok icici pe dedh lakh bhej do, IFSC SBIN triple zero ek do teen chaar" --json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Prior Art & Differentiation
|
|
116
|
+
|
|
117
|
+
**NVIDIA NeMo Text Processing** provides mature WFST-based Inverse Text Normalization (ITN) for Devanagari Hindi (`hi`), and is the right tool if you want general-purpose sentence-level WFST normalization inside a NeMo/Riva stack.
|
|
118
|
+
|
|
119
|
+
`paisa-parse` targets a distinct, voice-agent-specific gap:
|
|
120
|
+
|
|
121
|
+
1. **Romanized Hinglish + Mixed Indian-English**: handles what Whisper, Deepgram, Sarvam, and Google STT emit in practice (`dedh lakh`, `sava do crore`, `chhattees hazaar`, `teen baar shunya`, `rahul dot verma at ok icici`), alongside Devanagari digits/words.
|
|
122
|
+
2. **Colloquial Indian Fractions**: native support for `dedh` (1.5), `dhai` (2.5), `sava` (+0.25), `paune` (-0.25), `saade` (+0.5), `aadha` (0.5), and `paav` (0.25) across Indian scales.
|
|
123
|
+
3. **Domain Validators**: UPI ID parsing with ~75 NPCI PSP handles (and email rejection) plus 11-character IFSC parsing with RBI bank prefixes and 5th-character `O -> 0` repair.
|
|
124
|
+
4. **Confidence + Confirm-Back Policy**: calibrates confidence for ASR ambiguities (`oh` -> `0`, `so` -> `100`, unknown PSP/bank, truncated phone/IFSC) and produces ready-to-speak `accept` / `confirm` / `reprompt` prompts.
|
|
125
|
+
5. **Zero-Dependency Portability**: pure Python (`pip install paisa-parse`), sub-millisecond latency, with native Pipecat, LiveKit Agents, and MCP adapters.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Stress-Test Benchmark Results
|
|
130
|
+
|
|
131
|
+
Evaluated on [`benchmarks/stress_test.json`](benchmarks/stress_test.json) (130 realistic & adversarial Hinglish financial utterances across 7 categories) using `python benchmarks/run_benchmark.py --no-write`:
|
|
132
|
+
|
|
133
|
+
- **Utterance Exact-Match Accuracy**: **100.00%** (`130/130`)
|
|
134
|
+
- **Entity Precision / Recall / F1**: **1.0000 / 1.0000 / 1.0000** (`TP=134, FP=0, FN=0`)
|
|
135
|
+
- **Confirm-Back Policy Accuracy**: **100.00%** (`134` matched entities)
|
|
136
|
+
- **Latency**: p50 = **0.250 ms**, p95 = **0.544 ms**, p99 = **0.809 ms**
|
|
137
|
+
|
|
138
|
+
| Category | Exact / Total | Accuracy |
|
|
139
|
+
| --- | ---: | ---: |
|
|
140
|
+
| `colloquial_fractions` | 25 / 25 | 100.00% |
|
|
141
|
+
| `compound_amounts` | 20 / 20 | 100.00% |
|
|
142
|
+
| `spoken_digits` | 20 / 20 | 100.00% |
|
|
143
|
+
| `upi_ids` | 20 / 20 | 100.00% |
|
|
144
|
+
| `ifsc_codes` | 15 / 15 | 100.00% |
|
|
145
|
+
| `multi_entity` | 15 / 15 | 100.00% |
|
|
146
|
+
| `adversarial_negatives` | 15 / 15 | 100.00% |
|
|
147
|
+
|
|
148
|
+
> **Scope note**: `stress_test.json` is an author-curated stress suite (not an external multi-vendor ASR corpus). Real-world audio transcripts with unseen regional spellings or severe acoustic misrecognitions may score lower; contributions of real failure utterances are welcome.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Adoption & Community Status (Honest Reporting)
|
|
153
|
+
|
|
154
|
+
Current status as of **v0.1.0** (pre-publish local release):
|
|
155
|
+
|
|
156
|
+
- **PyPI Downloads**: `0` (package not yet uploaded to PyPI; see [`PUBLISHING.md`](PUBLISHING.md) for upload steps)
|
|
157
|
+
- **GitHub Stars / Open Issues**: `0 stars / 0 issues` (repository not yet pushed publicly)
|
|
158
|
+
- **Pipecat / LiveKit Community Listings**: `Pending submission` (adapters and demos included; community PR/listing links will be added once published)
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# paisa-parse Stress-Test Benchmark Results
|
|
2
|
+
|
|
3
|
+
- **Dataset**: `stress_test.json` (130 Hinglish & Indian-English utterances)
|
|
4
|
+
- **Policy**: `ConfirmPolicy.balanced()` (auto-accept >= 0.85, confirm >= 0.55 or >= ₹50,000, reprompt < 0.55)
|
|
5
|
+
- **Utterance Exact-Match Accuracy**: **100.00%** (130/130)
|
|
6
|
+
- **Entity Precision / Recall / F1**: **1.0000 / 1.0000 / 1.0000** (TP=134, FP=0, FN=0)
|
|
7
|
+
- **Confirm-Back Policy Accuracy**: **100.00%** (134 matched entities)
|
|
8
|
+
- **Latency**: p50 = **0.250 ms**, p95 = **0.544 ms**, p99 = **0.809 ms**
|
|
9
|
+
|
|
10
|
+
## Per-Category Accuracy
|
|
11
|
+
|
|
12
|
+
| Category | Exact / Total | Accuracy |
|
|
13
|
+
| --- | ---: | ---: |
|
|
14
|
+
| `colloquial_fractions` | 25 / 25 | 100.00% |
|
|
15
|
+
| `compound_amounts` | 20 / 20 | 100.00% |
|
|
16
|
+
| `spoken_digits` | 20 / 20 | 100.00% |
|
|
17
|
+
| `upi_ids` | 20 / 20 | 100.00% |
|
|
18
|
+
| `ifsc_codes` | 15 / 15 | 100.00% |
|
|
19
|
+
| `multi_entity` | 15 / 15 | 100.00% |
|
|
20
|
+
| `adversarial_negatives` | 15 / 15 | 100.00% |
|
|
21
|
+
|
|
22
|
+
## Failures
|
|
23
|
+
|
|
24
|
+
None (0 failures on this run).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dataset": "stress_test.json",
|
|
3
|
+
"total_cases": 130,
|
|
4
|
+
"exact_matches": 130,
|
|
5
|
+
"utterance_accuracy": 1.0,
|
|
6
|
+
"entity_metrics": {
|
|
7
|
+
"true_positives": 134,
|
|
8
|
+
"false_positives": 0,
|
|
9
|
+
"false_negatives": 0,
|
|
10
|
+
"precision": 1.0,
|
|
11
|
+
"recall": 1.0,
|
|
12
|
+
"f1": 1.0
|
|
13
|
+
},
|
|
14
|
+
"policy_accuracy": 1.0,
|
|
15
|
+
"policy_matched_entities": 134,
|
|
16
|
+
"latency_ms": {
|
|
17
|
+
"p50": 0.25,
|
|
18
|
+
"p95": 0.544,
|
|
19
|
+
"p99": 0.809,
|
|
20
|
+
"mean": 0.293
|
|
21
|
+
},
|
|
22
|
+
"categories": {
|
|
23
|
+
"colloquial_fractions": {
|
|
24
|
+
"total": 25,
|
|
25
|
+
"exact": 25,
|
|
26
|
+
"accuracy": 1.0
|
|
27
|
+
},
|
|
28
|
+
"compound_amounts": {
|
|
29
|
+
"total": 20,
|
|
30
|
+
"exact": 20,
|
|
31
|
+
"accuracy": 1.0
|
|
32
|
+
},
|
|
33
|
+
"spoken_digits": {
|
|
34
|
+
"total": 20,
|
|
35
|
+
"exact": 20,
|
|
36
|
+
"accuracy": 1.0
|
|
37
|
+
},
|
|
38
|
+
"upi_ids": {
|
|
39
|
+
"total": 20,
|
|
40
|
+
"exact": 20,
|
|
41
|
+
"accuracy": 1.0
|
|
42
|
+
},
|
|
43
|
+
"ifsc_codes": {
|
|
44
|
+
"total": 15,
|
|
45
|
+
"exact": 15,
|
|
46
|
+
"accuracy": 1.0
|
|
47
|
+
},
|
|
48
|
+
"multi_entity": {
|
|
49
|
+
"total": 15,
|
|
50
|
+
"exact": 15,
|
|
51
|
+
"accuracy": 1.0
|
|
52
|
+
},
|
|
53
|
+
"adversarial_negatives": {
|
|
54
|
+
"total": 15,
|
|
55
|
+
"exact": 15,
|
|
56
|
+
"accuracy": 1.0
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"failures": []
|
|
60
|
+
}
|