Metadata-Version: 2.4
Name: acps-pronunciation-coach
Version: 1.0.0
Summary: Multi-agent English pronunciation studio on ACPs. A Phoneme Agent pinpoints mispronounced vowels and consonants with IPA minimal-pair drills; a Prosody Agent repairs stress, rhythm and intonation; a Shadowing Agent turns both diagnoses into a model-audio shadowing protocol. Three acps-sdk 2.1.0 AIP agents collaborate in parallel to deliver examiner-grade feedback for IELTS speaking, keynote delivery and accent polishing.
Author-email: ACPs Pronunciation Coach Engineering <team@acps-pronunciation-coach.dev>
License-Expression: MIT
Project-URL: Homepage, https://github.com/acps-labs/acps-pronunciation-coach
Project-URL: Repository, https://github.com/acps-labs/acps-pronunciation-coach
Project-URL: Documentation, https://github.com/acps-labs/acps-pronunciation-coach#readme
Project-URL: Changelog, https://github.com/acps-labs/acps-pronunciation-coach/releases
Keywords: acps,acps-sdk,multi-agent,agent-collaboration,pronunciation,phoneme,ipa,prosody,intonation,shadowing,english-speaking,accent-reduction,ielts-speaking,speech-training
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: End Users/Desktop
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Education
Classifier: Topic :: Education :: Computer Aided Instruction (CAI)
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: acps-sdk==2.1.0
Requires-Dist: fastapi>=0.110.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: uvicorn>=0.27.0
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"
Dynamic: license-file

# acps-pronunciation-coach

**ACPs Pronunciation Coach** is a multi-agent English pronunciation studio built on
[ACPs](https://github.com/acps-labs) and `acps-sdk==2.1.0`. It turns one spoken
attempt into three coordinated diagnoses and one deliberate-practice plan:
phoneme-level correction, prosody repair, and a model-audio shadowing protocol.

The name combines the collaboration protocol (**ACPs**), the training target
(**Pronunciation**) and the delivery format (**Coach**): a coaching board whose
members speak the same Agent Interaction Protocol instead of a single monolithic
scoring model.

---

## Why multi-agent?

Pronunciation is not one problem. A learner can produce every consonant correctly
and still sound flat; another can have excellent intonation but substitute `/θ/`
with `/s/`. Splitting the work lets each specialist own one dimension and pass a
typed product to the next stage:

| Agent | Skill tag | Responsibility | Output |
| --- | --- | --- | --- |
| **PhonemeAgent** | `phoneme-assessment` | IPA-aligns each word, isolates the offending vowel/consonant, classifies place, voicing, length or quality errors | `PhonemeReport` with minimal pairs and articulation cues |
| **ProsodyAgent** | `prosody-coaching` | Measures rate, pitch range, stress placement, pause placement and final tone | `ProsodyReport` with thought groups and repair steps |
| **ShadowingAgent** | `shadowing-coaching` | Renders a model-audio SSML timeline and a five-step shadowing loop from both diagnoses | `ShadowingPlan` with drills and pass criteria |

Typical deployment scenarios:

* IELTS / TOEFL speaking diagnostics where examiners ask "which sound exactly is wrong?".
* Keynote and media-interview delivery polishing for non-native speakers.
* Phoneme-focused accent reduction blocks inside corporate L&D programmes.
* Pronunciation clinics that need an auditable, repeatable feedback report.

---

## Architecture

```
                    ┌─────────────────────────────────────────────┐
                    │  PronunciationCoachSession (Leader, ACPs)   │
                    │  discovers skills through ADP, drives AIP   │
                    └──────────────┬──────────────────────────────┘
                                   │ AIP v2 RPC (JSON-RPC over HTTP)
          ┌────────────────────────┼────────────────────────┐
          ▼                        ▼                        ▼
 ┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
 │  PhonemeAgent   │     │  ProsodyAgent   │     │ ShadowingAgent  │
 │  IPA alignment  │     │ stress / rhythm │     │ model audio +   │
 │  minimal pairs  │     │ intonation      │     │ shadowing loop  │
 └────────┬────────┘     └────────┬────────┘     └────────┬────────┘
          │                       │                       │
          └─────────── parallel ──┘                       │
                    PhonemeReport + ProsodyReport ───────▶┘
                                   │
                                   ▼
                     weighted SessionReport + AIP trace
```

The Leader dispatches Phoneme and Prosody **in parallel**, waits for both
products, then starts Shadowing with the two reports as its payload. Every agent
is a real FastAPI service exposing the AIP RPC endpoint; the local mesh runs all
three on loopback ports so the demo needs no broker or cloud credentials.

---

## Quickstart

Python 3.10+ is required.

```bash
cd acps-pronunciation-coach
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activate

pip install -e ".[dev]"
```

If `acps-sdk==2.1.0` is not available from your index yet, install the wheel first:

```bash
pip install /path/to/acps_sdk-2.1.0-py3-none-any.whl
pip install -e ".[dev]"
```

### One-command demo

```bash
pronunciation-coach demo
# or, without installing the console script:
python -m pronunciation_coach demo
```

The demo starts three AIP agents, submits a simulated IELTS-style attempt, and
prints the complete multi-agent report. No keyboard input or audio device is
required.

### Self-check

```bash
pronunciation-coach verify
```

Prints the Leader and partner AICs after validating them with `acps_sdk.aic`.

---

## Example: what the board reports

Input attempt (simulated ASR plus forced alignment):

```
Target:      I think this is a very good idea, and I would like to work on it with the team.
Recognised:  I sink dis is a wery good idea, and I would like to walk on it with the team.
Duration:    5.2s  ->  219 wpm
```

PhonemeAgent output (excerpt):

```
think  /θ/ -> /s/  [place-of-articulation · major · 42]
  音标: θɪŋk -> sɪŋk
  要领: 舌尖轻触上齿边缘，让气流从舌齿缝隙摩擦而出；对着镜子应能看到舌尖。
  最小对立: think /θɪŋk/ ↔ sink /sɪŋk/
very   /v/ -> /w/  [place-of-articulation · major · 45]
work   /ɜː/ -> /ɔː/ [vowel-quality · major · 40]
with   /ð/ -> /θ/  [voicing · moderate · 58]
idea   /ɪ/ -> /iː/ [vowel-length · moderate · 62]
```

ProsodyAgent output (excerpt):

```
Score 53/100 (rhythm 51 / stress 50 / intonation 58)
Rushed:   219 wpm, target 110-165
Monotone: pitch range 2.8 st, target >= 4.0
End tone: rising on a statement, target falling
Stress:   function words "and", "to" carry the beat
```

ShadowingAgent output (excerpt):

```
Readiness 65/100
Model audio: en-US-AvaNeural, rate -10%, estimated 8.1s
Segments:
  S1 [0.0s +3.4s] I think this is a very good idea,
  S2 [3.4s +4.7s] and I would like to work on it with the team.
Steps:
  1. 盲听建模  2. 拆句慢读  3. 同步影子跟读
  4. 延迟影子跟读  5. 录音对比
Pass:
  音素得分 -> >= 90; 语速 -> 110-165 wpm; 句末 -> falling
```

Leader output:

```
Phoneme 75 | Prosody 53 | Shadowing 65 | Overall 66
PhonemeAgent  state=completed   ~190ms
ProsodyAgent  state=completed   ~190ms   (dispatched in parallel)
ShadowingAgent state=completed   ~40ms   (consumed both reports)
```

---

## Build the wheel

```bash
python -m build
```

Artifacts are written to `dist/`:

```
dist/acps_pronunciation_coach-1.0.0-py3-none-any.whl
dist/acps_pronunciation_coach-1.0.0.tar.gz
```

Check the metadata and contents before publishing:

```bash
twine check dist/*
unzip -l dist/acps_pronunciation_coach-1.0.0-py3-none-any.whl
```

## Publish to PyPI

Always rehearse on TestPyPI first:

```bash
# TestPyPI
twine upload --repository testpypi dist/*
pip install --index-url https://test.pypi.org/simple/ \
  --extra-index-url https://pypi.org/simple/ acps-pronunciation-coach

# Production PyPI
twine upload dist/*
```

Use an API token instead of a password when prompted:

```bash
twine upload --username __token__ --password pypi-<YOUR_TOKEN> dist/*
```

`~/.pypirc` can store the token mapping:

```ini
[distutils]
index-servers =
    pypi
    testpypi

[pypi]
username = __token__
password = pypi-<PRODUCTION_TOKEN>

[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-<TEST_TOKEN>
```

---

## Project layout

```
acps-pronunciation-coach/
├── pyproject.toml                  # build config, metadata, entry point
├── README.md
├── LICENSE
├── src/pronunciation_coach/
│   ├── __init__.py                 # public version and models
│   ├── __main__.py                 # python -m pronunciation_coach
│   ├── py.typed
│   ├── models.py                   # AIP payload schema (Pydantic v2)
│   ├── engine.py                   # IPA / prosody / shadowing knowledge
│   ├── identity.py                 # AIC + ACS builders
│   ├── registry.py                 # in-process ADP discovery service
│   ├── runtime.py                  # AIP RPC server, payload codecs
│   ├── mesh.py                     # starts the three partner agents
│   ├── leader.py                   # parallel task orchestration
│   ├── demo.py                     # scripted end-to-end session
│   ├── cli.py                      # pronunciation-coach entry point
│   └── agents/
│       ├── base.py                 # AIP lifecycle for every partner
│       ├── phoneme.py
│       ├── prosody.py
│       └── shadowing.py
└── tests/
    └── test_end_to_end.py
```

## Plugging in a real acoustic front end

`PronunciationSample` is the only contract the agents need. A production ASR or
forced aligner should emit:

* `word_scores`: word, reference IPA, observed IPA, 0-100 accuracy;
* `pitch_contour_st`: normalised pitch track in semitones;
* `pauses_sec`: pause lengths inside the utterance;
* `stressed_words`: words the acoustic model marked as stressed.

The deterministic `PronunciationEngine` can then be replaced by an LLM or a
pronunciation-assessment API without touching the ACPs wiring.

## Tests

```bash
pytest
```

The suite covers ADP discovery, the full three-agent AIP round trip, IPA error
classification, prosody flags and the shadowing plan.

## License

MIT. See [LICENSE](LICENSE).
