Views
No views yet
🚀 A PyTorch model for contextless phoneme prediction from speech audio
📊 Three 30.1M parameter models available
| 🏷️ Model | 🌍 Languages | 📊 PER | 📊 GER | 📝 Description |
|---|---|---|---|---|
| 🇬🇧 English | English | 0.24 | 0.21 | 🏆 Best quality for English speech |
| 🌍 Multilingual MLS | 8 European | 0.31 | 0.26 | 🇪🇺 en, de, fr, es, pt, it, pl, nl |
| 🌐 Multilingual MSWC | 38 languages | 0.49 | 0.39 | 🗺️ Broad language coverage |
⚠️ Note: CUPE models are designed for contextless phoneme prediction and are not optimal for phoneme classification tasks that require contextual information. CUPE excels at extracting pure, frame-level embeddings that represent the acoustic properties of each phoneme independently of surrounding context.
pl, pt, it, es, fr, nl, de, enen, de, fr, ca, es, fa, it, ru, pl, eu, cy, eo, nl, pt, tt, cs, tr, et, ky, id, sv-SE, ar, el, ro, lv, sl, zh-CN, ga-IE, ta, vi, gn, or)lt, mt, ia, sk, ka, as)💡 Need a new language? Start a new discussion and we'll train it for you!
1# 📦 Install the package
2pip install bournemouth-forced-aligner
3
4# 🔧 Install dependencies
5apt-get install espeak-ng ffmpeg
6
7# ❓ Show help
8balign --help1# 📦 Install core dependencies
2pip install torch torchaudio huggingface_hub🎯 Zero-setup required - automatic downloads from Hugging Face Hub
1🔄 Loading CUPE english model...
2✅ Model loaded on cpu
3🎵 Processing audio: 1.26s duration
4📊 Processed 75 frames (1200ms total)
5
6📋 Results:
7🔤 Phoneme predictions shape: (75,)
8🏷️ Group predictions shape: (75,)
9ℹ️ Model info: {'model_name': 'english', 'sample_rate': 16000, 'frames_per_second': 62.5}
10
11🔍 First 10 frame predictions:
12Frame 0: phoneme=66, group=16
13Frame 1: phoneme=66, group=16
14Frame 2: phoneme=29, group=7
15...
16
17🔤 Phonemes: ['b', 'ʌ', 't', 'h', 'ʌ', 'f', 'l', 'æ']...
18🏷️ Groups: ['voiced_stops', 'central_vowels', 'voiceless_stops']...1import torch
2import torchaudio
3from huggingface_hub import hf_hub_download
4import importlib.util
5
6def load_cupe_model(model_name="english", device="auto"):
7 """🔄 Load CUPE model with automatic downloading from Hugging Face Hub"""
8
9 model_files = {
10 "english": "en_libri1000_uj01d_e199_val_GER=0.2307.ckpt",
11 "multilingual-mls": "multi_MLS8_uh02_e36_val_GER=0.2334.ckpt",
12 "multilingual-mswc": "multi_mswc38_ug20_e59_val_GER=0.5611.ckpt"
13 }
14
15 if device == "auto":
16 device = "cuda" if torch.cuda.is_available() else "cpu"
17
18 # 📥 Download files automatically from Hugging Face Hub
19 repo_id = "Tabahi/CUPE-2i"
20 model_file = hf_hub_download(repo_id=repo_id, filename="model2i.py")
21 windowing_file = hf_hub_download(repo_id=repo_id, filename="windowing.py")
22 checkpoint = hf_hub_download(repo_id=repo_id, filename=f"ckpt/{model_files[model_name]}")
23 model_utils_file = hf_hub_download(repo_id=repo_id, filename="model_utils.py")
24
25 # 🔧 Import modules dynamically
26 _ = import_module_from_file("model_utils", model_utils_file)
27 spec = importlib.util.spec_from_file_location("model2i", model_file)
28 model2i = importlib.util.module_from_spec(spec)
29 spec.loader.exec_module(model2i)
30
31 spec = importlib.util.spec_from_file_location("windowing", windowing_file)
32 windowing = importlib.util.module_from_spec(spec)
33 spec.loader.exec_module(windowing)
34
35 # 🚀 Initialize model
36 extractor = model2i.CUPEEmbeddingsExtractor(checkpoint, device=device)
37 return extractor, windowing
38
39# 🎯 Example usage
40extractor, windowing = load_cupe_model("english")
41
42# 🎵 Load and process your audio
43audio, sr = torchaudio.load("your_audio.wav")
44if sr != 16000:
45 resampler = torchaudio.transforms.Resample(sr, 16000)
46 audio = resampler(audio)
47
48# 📊 Add batch dimension and process
49audio_batch = audio.unsqueeze(0)
50windowed_audio = windowing.slice_windows(audio_batch, 16000, 120, 80)
51batch_size, num_windows, window_size = windowed_audio.shape
52windows_flat = windowed_audio.reshape(-1, window_size)
53
54# 🔮 Get predictions
55logits_phonemes, logits_groups = extractor.predict(windows_flat, return_embeddings=False, groups_only=False)
56
57print(f"🔤 Phoneme logits shape: {logits_phonemes.shape}") # [num_windows, frames_per_window, 66]
58print(f"🏷️ Group logits shape: {logits_groups.shape}") # [num_windows, frames_per_window, 16]1import torch
2import torchaudio
3from model2i import CUPEEmbeddingsExtractor # 🎯 Main CUPE model feature extractor
4import windowing # 🔧 Provides slice_windows, stich_window_predictions
5
6# 📁 Load model from local checkpoint
7cupe_ckpt_path = "./ckpt/en_libri1000_uj01d_e199_val_GER=0.2307.ckpt"
8extractor = CUPEEmbeddingsExtractor(cupe_ckpt_path, device="cuda")
9
10# 🎵 Prepare audio
11sample_rate = 16000
12window_size_ms = 120
13stride_ms = 80
14max_wav_len = 10 * sample_rate # 10 seconds
15
16dummy_wav = torch.zeros(1, max_wav_len, dtype=torch.float32, device="cpu")
17audio_batch = dummy_wav.unsqueeze(0) # Add batch dimension
18
19# 🪟 Window the audio
20windowed_audio = windowing.slice_windows(
21 audio_batch.to("cuda"),
22 sample_rate,
23 window_size_ms,
24 stride_ms
25)
26batch_size, num_windows, window_size = windowed_audio.shape
27windows_flat = windowed_audio.reshape(-1, window_size)
28
29# 🔮 Get predictions
30logits, _ = extractor.predict(windows_flat, return_embeddings=False, groups_only=False)
31
32# 🔄 Reshape and stitch window predictions
33frames_per_window = logits.shape[1]
34logits = logits.reshape(batch_size, num_windows, frames_per_window, -1)
35logits = windowing.stich_window_predictions(
36 logits,
37 original_audio_length=audio_batch.size(2),
38 cnn_output_size=frames_per_window,
39 sample_rate=sample_rate,
40 window_size_ms=window_size_ms,
41 stride_ms=stride_ms
42)
43
44print(f"📊 Output shape: {logits.shape}") # [B, T, 66](time_frames, 66) - 66 IPA phoneme classes(time_frames, 16) - 16 phoneme groups


1@inproceedings{rehman2025cupe,
2 title = {CUPE: Contextless Universal Phoneme Encoder for Language-Agnostic Speech Processing},
3 author = {Abdul Rehman and Jian-Jun Zhang and Xiaosong Yang},
4 booktitle = {Proceedings of the 8th International Conference on Natural Language and Speech Processing (ICNLSP 2025)},
5 year = {2025},
6 organization = {ICNLSP},
7 publisher = {International Conference on Natural Language and Speech Processing},
8}