Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: keras
|
| 3 |
+
tags:
|
| 4 |
+
- audio-classification
|
| 5 |
+
- cnn
|
| 6 |
+
- cebuano
|
| 7 |
+
- sinama
|
| 8 |
+
- mel-spectrogram
|
| 9 |
+
pipeline_tag: audio-classification
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Sinama Audio Classifier
|
| 13 |
+
|
| 14 |
+
A CNN-based audio classification model trained to recognise spoken
|
| 15 |
+
Cebuano / Sinama words from short audio clips.
|
| 16 |
+
|
| 17 |
+
## Usage
|
| 18 |
+
|
| 19 |
+
### Via Inference API
|
| 20 |
+
|
| 21 |
+
```python
|
| 22 |
+
import requests
|
| 23 |
+
|
| 24 |
+
API_URL = "https://api-inference.huggingface.co/models/YOUR_USERNAME/sinama-translator"
|
| 25 |
+
headers = {"Authorization": "Bearer hf_YOUR_TOKEN"}
|
| 26 |
+
|
| 27 |
+
with open("audio.wav", "rb") as f:
|
| 28 |
+
response = requests.post(API_URL, headers=headers, data=f.read())
|
| 29 |
+
|
| 30 |
+
print(response.json())
|
| 31 |
+
# [{"label": "ako", "score": 0.95}, ...]
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
### Local inference
|
| 35 |
+
|
| 36 |
+
```python
|
| 37 |
+
import tensorflow as tf, json, librosa, numpy as np
|
| 38 |
+
|
| 39 |
+
model = tf.keras.models.load_model("best_model.keras")
|
| 40 |
+
with open("label_map.json") as f:
|
| 41 |
+
label_map = {int(k): v for k, v in json.load(f).items()}
|
| 42 |
+
|
| 43 |
+
# preprocess your audio the same way as training …
|
| 44 |
+
pred = model.predict(features)
|
| 45 |
+
print(label_map[pred.argmax()])
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Training details
|
| 49 |
+
|
| 50 |
+
- **Architecture:** 3-block CNN (Conv2D → BN → ReLU → MaxPool → Dropout)
|
| 51 |
+
- **Features:** 128-bin Mel Spectrogram, 4 s clips, 22 050 Hz
|
| 52 |
+
- **Optimiser:** Adam
|
| 53 |
+
- **Loss:** Categorical cross-entropy
|