File size: 6,253 Bytes
9eda889
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
---
license: mit
language:
- en
library_name: pytorch
tags:
- audio
- turn-detection
- whisper
- conversation
- speech
- voice-assistant
pipeline_tag: audio-classification
datasets:
- pipecat-ai/smart-turn-data-v3.2-train
metrics:
- recall
- accuracy
- precision
- f1
base_model:
- openai/whisper-tiny
---

# Tiny Turn Detector

A lightweight real-time audio turn detection model that predicts whether a speaker is **DONE speaking** or **PAUSING/CONTINUING** in conversational audio.

## Model Description

This model addresses a critical challenge in building responsive voice assistants and conversation systems: determining when a speaker has actually finished their turn versus just pausing mid-sentence.

**Key Features:**
- โšก Fast inference (~100ms on CPU)
- ๐ŸŽฏ High accuracy (95.5% on training set, 73% on validation)
- ๐Ÿ”Š Works with 8-second audio clips
- ๐Ÿš€ Easy to integrate with existing systems
- ๐Ÿ“ฆ Small model size (~150MB with Whisper Tiny)

## Architecture

```
Audio (8 sec, 16kHz)
    โ†“
Whisper Tiny Encoder (frozen/fine-tuned)
    โ†“
Mean Pooling
    โ†“
MLP Head (384 โ†’ 64 โ†’ 1)
    โ†“
Sigmoid โ†’ P(end_turn)
    โ†“
Binary Decision: END or CONTINUE
```

**Components:**
- **Encoder:** OpenAI Whisper Tiny (pretrained)
- **Classifier:** 2-layer MLP with ReLU activation
- **Input:** 8-second audio clips at 16kHz
- **Output:** Binary classification (0=CONTINUE, 1=END)

## Training Results

The model was trained on the [pipecat-ai/smart-turn-data-v3.2-train](https://huggingface.co/datasets/pipecat-ai/smart-turn-data-v3.2-train) dataset.

### Final Metrics (Best Model)

| Split      | Loss   | Accuracy | Precision | Recall | F1 Score |
|------------|--------|----------|-----------|--------|----------|
| **Train**  | 0.1391 | 95.50%   | 95.90%    | 95.34% | **95.62%** |
| **Val**    | 4.9075 | 73.00%   | 70.00%    | 89.09% | **78.40%** |

**Training Configuration:**
- Epochs: Multiple epochs with early stopping
- Optimizer: AdamW
- Loss Function: Binary Cross-Entropy with Logits
- Best model selected based on validation F1 score (0.7840)

**Note:** The validation loss is higher due to the model being optimized for F1 score rather than loss. The high recall (89%) indicates the model is conservative about marking turn endings, which is desirable for real-time applications to avoid premature interruptions.

## Usage

### Download the Model

```python
from huggingface_hub import hf_hub_download
import torch

# Download model
model_path = hf_hub_download(
    repo_id="YOUR_USERNAME/tiny-turn-detector",
    filename="best_model.pt"
)

# Load model
model = torch.load(model_path, map_location='cpu')
model.eval()
```

### Run Inference

```python
import torch
import librosa
from transformers import WhisperProcessor

# Load processor
processor = WhisperProcessor.from_pretrained("openai/whisper-tiny")

# Load audio (8 seconds at 16kHz)
audio, sr = librosa.load("your_audio.wav", sr=16000, duration=8.0)

# Process audio
inputs = processor(audio, sampling_rate=16000, return_tensors="pt")

# Predict
with torch.no_grad():
    outputs = model(inputs.input_features)
    probability = torch.sigmoid(outputs).item()
    
# Decision
threshold = 0.5
decision = "END" if probability > threshold else "CONTINUE"

print(f"Probability: {probability:.4f}")
print(f"Decision: {decision}")
```

### Full Inference Script

For complete inference code with audio loading, preprocessing, and visualization, see the [GitHub repository](YOUR_GITHUB_REPO_URL).

## Installation

```bash
pip install torch torchaudio transformers librosa huggingface_hub
```

## Use Cases

- ๐ŸŽ™๏ธ Voice assistants and chatbots
- ๐Ÿ“ž Real-time conversation systems
- ๐ŸŽง Meeting transcription tools
- ๐Ÿค– Interactive voice response (IVR) systems
- ๐Ÿ’ฌ Voice-based interfaces
- ๐ŸŽฎ Voice-controlled applications

## Model Details

- **Model Type:** Audio Classification (Binary)
- **Base Model:** OpenAI Whisper Tiny
- **Language:** English (primarily)
- **Sampling Rate:** 16kHz
- **Input Duration:** 8 seconds
- **Framework:** PyTorch
- **Parameters:** ~39M (Whisper) + ~25K (Classifier)

## Training Data

**Dataset:** [pipecat-ai/smart-turn-data-v3.2-train](https://huggingface.co/datasets/pipecat-ai/smart-turn-data-v3.2-train)

The dataset contains conversational audio clips labeled with turn-taking information:
- `endpoint_bool`: Binary label (0=continue, 1=end)
- Audio clips of varying lengths (processed to 8 seconds)
- Real-world conversational scenarios

## Limitations

- **Validation Gap:** The model shows some overfitting (95.5% train vs 73% val accuracy). This could be improved with:
  - Data augmentation
  - Regularization techniques
  - More diverse training data
  
- **8-Second Window:** Requires exactly 8 seconds of audio context
  
- **English Focus:** Primarily trained on English conversations

- **VAD Dependency:** Works best when combined with Voice Activity Detection (VAD) for silence removal

## Future Improvements

- [ ] Add multi-language support
- [ ] Reduce validation gap through regularization
- [ ] Variable-length audio support
- [ ] Real-time streaming inference
- [ ] Integration with VAD systems
- [ ] Ensemble with acoustic features (pause duration, pitch)

## GitHub Repository

Full training code, evaluation scripts, and inference examples:  
๐Ÿ”— **https://github.com/Nitin1613/Turn_detector/tree/main** 

The repository includes:
- Complete training pipeline
- Dataset preparation scripts
- Evaluation and benchmarking tools
- Inference examples
- Google Colab notebook for easy experimentation

## Citation

If you use this model in your research or application, please cite:

```bibtex
@misc{tiny-turn-detector-2026,
  title={Tiny Turn Detector: Real-time Audio Turn Detection with Whisper},
  author=Nitinbudania,
  year={2026},
  publisher={Hugging Face},
  howpublished={\url{https://huggingface.co/Nitinbudania/tiny-turn-detector}}
}
```

## License

MIT License - See [LICENSE](YOUR_GITHUB_REPO_URL/blob/main/LICENSE) file for details

## Acknowledgments

- OpenAI for the Whisper model
- Pipecat.ai for the training dataset
- Hugging Face for hosting and tools

---

**Model Card Authors:** YOUR_NAME  
**Contact:** YOUR_EMAIL or GitHub  
**Last Updated:** August 2026