File size: 1,930 Bytes
239b430
594c3e0
 
 
 
239b430
 
 
594c3e0
239b430
 
 
594c3e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
title: ShadowLoop
emoji: πŸ”
colorFrom: gray
colorTo: green
sdk: gradio
sdk_version: 6.13.0
app_file: app.py
python_version: "3.11"
pinned: false
---

# ShadowLoop

Local sentence-level repetition trainer for English shadowing practice. Upload audio, review sentence segments, configure repeats and pauses, download a practice MP3.

## Requirements

- Python 3.11+
- ffmpeg (`sudo apt install ffmpeg` or `brew install ffmpeg`)

## Install

```bash
python3.11 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
```

First run will download the Whisper `base` model (~140 MB).

## Usage

```bash
source .venv/bin/activate
python app.py
```

Open the URL shown in the terminal (typically `http://0.0.0.0:7860`).

### Workflow

1. **Upload** an audio file and click **Transcribe** (or upload a `.txt` transcript instead)
2. **Review** the detected sentences β€” merge, split, or delete as needed
3. **Configure** repeat count, pauses, and playback speed
4. Click **Build Practice Audio**, preview, and download the MP3

### Settings

| Setting | Default | Range |
|---|---|---|
| Repeat count | 8 | 1–20 |
| Pause between repeats | 2.5s | 0–10s |
| Pause between sentences | 4s | 1–15s |
| Playback speed | 1.0x | 0.5x–2.0x |

Speed is applied to the exported MP3 (pitch-preserving via ffmpeg atempo).

## Tests

```bash
python -m pytest
```

## Project Structure

```
app.py                        # Gradio UI
src/shadowloop/
    config.py                 # Segment + ShadowingConfig dataclasses
    ingest.py                 # Audio loading and normalization
    segmenter.py              # Whisper transcription + sentence splitting + edit ops
    planner.py                # Repeat/pause plan generation
    builder.py                # Audio assembly with speed change
    exporters.py              # MP3 export
tests/
    test_config.py
    test_segmenter.py
    test_planner.py
    test_builder.py
```