RadeAI commited on
Commit
dc316d1
·
verified ·
1 Parent(s): 9a079d2

Replace with notebook.ipynb

Browse files
Files changed (1) hide show
  1. inference_colab.ipynb +0 -167
inference_colab.ipynb DELETED
@@ -1,167 +0,0 @@
1
- {
2
- "nbformat": 4,
3
- "nbformat_minor": 0,
4
- "metadata": {
5
- "colab": {
6
- "provenance": [],
7
- "gpuType": "T4"
8
- },
9
- "kernelspec": {
10
- "name": "python3",
11
- "display_name": "Python 3"
12
- },
13
- "language_info": {
14
- "name": "python"
15
- },
16
- "accelerator": "GPU"
17
- },
18
- "cells": [
19
- {
20
- "cell_type": "markdown",
21
- "metadata": {},
22
- "source": [
23
- "# Rade-ASR-CTC-3B-fa — Persian Speech-to-Text\n",
24
- "\n",
25
- "Run Meta's **Omnilingual ASR CTC-3B**, fine-tuned on **Persian** by [Rade AI](https://huggingface.co/RadeAI).\n",
26
- "\n",
27
- "**Steps:** set a **GPU** runtime (`Runtime ▸ Change runtime type ▸ T4 GPU`), run **Cell 1**, then **`Runtime ▸ Restart session`**, then run the rest. Audio clips must be **< 40 s**.\n"
28
- ]
29
- },
30
- {
31
- "cell_type": "markdown",
32
- "metadata": {},
33
- "source": [
34
- "## Cell 1 — install (then RESTART the session)\n"
35
- ]
36
- },
37
- {
38
- "cell_type": "code",
39
- "metadata": {},
40
- "execution_count": null,
41
- "outputs": [],
42
- "source": [
43
- "!apt-get -qq install -y libsndfile1\n",
44
- "!pip install -q omnilingual-asr huggingface_hub\n",
45
- "# fairseq2 needs the CUDA 12.8 torch build; pin all three or you hit libcudart/torchvision errors\n",
46
- "!pip install -q torch==2.8.0 torchaudio==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cu128\n",
47
- "print('installed — now click Runtime ▸ Restart session, then run the cells below')\n"
48
- ]
49
- },
50
- {
51
- "cell_type": "markdown",
52
- "metadata": {},
53
- "source": [
54
- "## ⚠️ Now do `Runtime ▸ Restart session`, then continue ↓\n"
55
- ]
56
- },
57
- {
58
- "cell_type": "markdown",
59
- "metadata": {},
60
- "source": [
61
- "## Cell 2 — check GPU\n"
62
- ]
63
- },
64
- {
65
- "cell_type": "code",
66
- "metadata": {},
67
- "execution_count": null,
68
- "outputs": [],
69
- "source": [
70
- "import torch\n",
71
- "print('torch', torch.__version__, '| CUDA', torch.cuda.is_available(),\n",
72
- " torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'NO GPU')\n"
73
- ]
74
- },
75
- {
76
- "cell_type": "markdown",
77
- "metadata": {},
78
- "source": [
79
- "## Cell 3 — download the fine-tuned weights (single fp16 file, ~6.2 GB)\n"
80
- ]
81
- },
82
- {
83
- "cell_type": "code",
84
- "metadata": {},
85
- "execution_count": null,
86
- "outputs": [],
87
- "source": [
88
- "from huggingface_hub import hf_hub_download\n",
89
- "# single consolidated fp16 file — half the download of the fp32 shards, identical output\n",
90
- "ckpt = hf_hub_download('RadeAI/Rade-ASR-CTC-3B-fa', 'model_fp16.pt')\n",
91
- "print('weights at', ckpt)\n"
92
- ]
93
- },
94
- {
95
- "cell_type": "markdown",
96
- "metadata": {},
97
- "source": [
98
- "## Cell 4 — register the model with fairseq2\n"
99
- ]
100
- },
101
- {
102
- "cell_type": "code",
103
- "metadata": {},
104
- "execution_count": null,
105
- "outputs": [],
106
- "source": [
107
- "import pathlib\n",
108
- "ad = pathlib.Path.home()/'.config/fairseq2/assets'; ad.mkdir(parents=True, exist_ok=True)\n",
109
- "(ad/'rade.yaml').write_text(f'''name: rade_CTC_3B_fa\n",
110
- "model_family: wav2vec2_asr\n",
111
- "model_arch: 3b_v2\n",
112
- "checkpoint: \"{ckpt}\"\n",
113
- "tokenizer_ref: omniASR_tokenizer_written_v2\n",
114
- "''')\n",
115
- "print('asset card ready')\n"
116
- ]
117
- },
118
- {
119
- "cell_type": "markdown",
120
- "metadata": {},
121
- "source": [
122
- "## Cell 5 — provide a Persian clip (< 40 s): upload a file\n"
123
- ]
124
- },
125
- {
126
- "cell_type": "code",
127
- "metadata": {},
128
- "execution_count": null,
129
- "outputs": [],
130
- "source": [
131
- "from google.colab import files\n",
132
- "up = files.upload()\n",
133
- "audio_path = list(up.keys())[0]\n",
134
- "print('using', audio_path)\n"
135
- ]
136
- },
137
- {
138
- "cell_type": "markdown",
139
- "metadata": {},
140
- "source": [
141
- "## Cell 6 — transcribe 🎙️ → 📝\n"
142
- ]
143
- },
144
- {
145
- "cell_type": "code",
146
- "metadata": {},
147
- "execution_count": null,
148
- "outputs": [],
149
- "source": [
150
- "from omnilingual_asr.models.inference.pipeline import ASRInferencePipeline\n",
151
- "pipe = ASRInferencePipeline(model_card='rade_CTC_3B_fa',\n",
152
- " device='cuda' if torch.cuda.is_available() else 'cpu',\n",
153
- " dtype=torch.float16) # ~199x real time, 6.4 GB VRAM\n",
154
- "text = pipe.transcribe([audio_path], lang=['pes_Arab'], batch_size=1)\n",
155
- "print('📝', text[0])\n"
156
- ]
157
- },
158
- {
159
- "cell_type": "markdown",
160
- "metadata": {},
161
- "source": [
162
- "---\n",
163
- "Made by [Rade AI](https://huggingface.co/RadeAI) · base: [facebook/omniASR-CTC-3B](https://huggingface.co/facebook/omniASR-CTC-3B) · Apache-2.0\n"
164
- ]
165
- }
166
- ]
167
- }