Text-to-Speech
Transformers
Safetensors
tts
vits
mms
indic
english
hindi
marathi
Sudhanshu619 commited on
Commit
ec50f07
·
verified ·
1 Parent(s): e526cfb

Restructure model card as multilingual: unified loader for bundled and 1,100+ MMS languages

Browse files
Files changed (1) hide show
  1. README.md +148 -115
README.md CHANGED
@@ -27,13 +27,14 @@ base_model:
27
 
28
  # SDLC Corp · Multilingual Text-to-Speech
29
 
30
- **Lightweight speech synthesis for English, Hindi and Marathi, extensible to 1,100+ languages**
31
 
32
  [![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC%20BY--NC%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc/4.0/)
33
  [![Task: Text-to-Speech](https://img.shields.io/badge/Task-Text--to--Speech-blue.svg)](#quick-start)
34
- [![Languages](https://img.shields.io/badge/Languages-EN%20%7C%20HI%20%7C%20MR-green.svg)](#supported-languages)
 
35
  [![Transformers](https://img.shields.io/badge/%F0%9F%A4%97%20Transformers-VITS-orange.svg)](https://huggingface.co/docs/transformers/model_doc/vits)
36
- [![Sample rate](https://img.shields.io/badge/Audio-16%20kHz%20mono-purple.svg)](#technical-specifications)
37
 
38
  </div>
39
 
@@ -41,49 +42,60 @@ base_model:
41
 
42
  ## Overview
43
 
44
- This repository provides three end-to-end text-to-speech models (**English**, **Hindi** and
45
- **Marathi**) under a single model ID. Each language is an independent VITS checkpoint from
46
- Meta AI's [Massively Multilingual Speech (MMS)](https://arxiv.org/abs/2305.13516) project,
47
- packaged by SDLC Corp for straightforward use with 🤗 Transformers.
48
 
49
- **Highlights**
50
 
51
- - **Three languages, one repository.** Select a language with `subfolder="eng" | "hin" | "mar"`.
52
- - **Extends to 1,100+ languages.** The same code runs any of Meta's 1,100+ MMS-TTS
53
- checkpoints. See [Extended Language Coverage](#extended-language-coverage-1100-languages).
54
- - **End to end.** Text goes in and a waveform comes out, with no separate vocoder,
55
- phonemizer or romanizer.
 
 
 
 
 
 
 
 
 
56
  - **Lightweight.** About 36M parameters and 145 MB per language, fast enough for a CPU.
57
- - **Native script input.** Hindi and Marathi take Devanagari text directly.
58
- - **Drop-in.** Uses the standard `VitsModel` / `AutoTokenizer` APIs and the `text-to-speech`
59
- pipeline.
 
60
 
61
  ## Table of Contents
62
 
63
- 1. [Supported Languages](#supported-languages)
64
- 2. [Extended Language Coverage (1,100+ languages)](#extended-language-coverage-1100-languages)
65
- 3. [Quick Start](#quick-start)
66
- 4. [Usage](#usage)
67
- 5. [Generation Controls](#generation-controls)
68
- 6. [Performance and Hardware](#performance-and-hardware)
69
- 7. [Technical Specifications](#technical-specifications)
70
- 8. [Intended Use](#intended-use)
71
- 9. [Limitations](#limitations)
72
- 10. [Ethical Considerations](#ethical-considerations)
73
- 11. [Demo Application](#demo-application)
74
- 12. [License](#license)
75
- 13. [Citation](#citation)
76
-
77
- ## Supported Languages
78
-
79
- | Language | Subfolder | Script | Vocabulary | Source checkpoint |
 
 
 
80
  |---|---|---|---|---|
81
  | English | `eng` | Latin (lowercased automatically) | 38 symbols | [facebook/mms-tts-eng](https://huggingface.co/facebook/mms-tts-eng) |
82
  | Hindi (हिन्दी) | `hin` | Devanagari | 72 symbols | [facebook/mms-tts-hin](https://huggingface.co/facebook/mms-tts-hin) |
83
  | Marathi (मराठी) | `mar` | Devanagari | 73 symbols | [facebook/mms-tts-mar](https://huggingface.co/facebook/mms-tts-mar) |
84
 
85
- **Repository layout**
86
-
87
  ```
88
  SDLC-Corp/TTS
89
  ├── eng/ ─┐
@@ -93,59 +105,38 @@ SDLC-Corp/TTS
93
  └── README.md
94
  ```
95
 
96
- Only the requested subfolder is downloaded, so loading Hindi does not fetch the English or
97
- Marathi weights.
98
-
99
- ## Extended Language Coverage (1,100+ languages)
100
 
101
- The three languages above are bundled in this repository. The underlying MMS-TTS model family
102
- covers **more than 1,100 languages**, each published by Meta as a separate checkpoint named
103
- `facebook/mms-tts-<code>`, where `<code>` is the
104
- [ISO 639-3](https://iso639-3.sil.org/code_tables/639/data) language code. Every example in
105
- this card works with them: replace the repository ID and drop `subfolder`.
106
-
107
- ```python
108
- from transformers import AutoTokenizer, VitsModel
109
-
110
- model_id = "facebook/mms-tts-tam" # Tamil
111
- tokenizer = AutoTokenizer.from_pretrained(model_id)
112
- model = VitsModel.from_pretrained(model_id).eval()
113
- ```
114
 
115
- **Examples of available languages**
 
 
116
 
117
- | Region | Languages (model code) |
118
  |---|---|
119
  | India and South Asia | Bengali (`ben`) · Tamil (`tam`) · Telugu (`tel`) · Gujarati (`guj`) · Kannada (`kan`) · Malayalam (`mal`) · Punjabi (`pan`) · Odia (`ory`) · Assamese (`asm`) · Urdu (`urd-script_arabic`, `urd-script_devanagari`, `urd-script_latin`) |
120
  | Europe | Spanish (`spa`) · French (`fra`) · German (`deu`) · Portuguese (`por`) · Russian (`rus`) |
121
  | Middle East and Africa | Arabic (`ara`) · Swahili (`swh`) · Yoruba (`yor`) |
122
- | East and Southeast Asia | Indonesian (`ind`) · Vietnamese (`vie`) · Thai (`tha`) · Korean (`kor`, needs uroman) |
123
 
124
- Browse every checkpoint on the
125
- [Hugging Face Hub](https://huggingface.co/models?search=facebook/mms-tts), or check
126
  [Meta's language coverage list](https://dl.fbaipublicfiles.com/mms/misc/language_coverage_mms.html).
127
 
128
- **Romanized languages.** Some checkpoints were trained on romanized text. For these, the
129
- tokenizer reports `is_uroman = True`, and input must be romanized with
130
- [uroman](https://github.com/isi-nlp/uroman) first:
131
 
132
- ```python
133
- # pip install uroman
134
- import uroman
 
135
 
136
- if getattr(tokenizer, "is_uroman", False):
137
- text = uroman.Uroman().romanize_string(text)
138
- ```
139
-
140
- **Notes**
141
 
142
- - Only English, Hindi and Marathi are stored in `SDLC-Corp/TTS`. Other languages download
143
- from Meta's repositories (~145 MB each) and are provided by Meta under the same CC BY-NC 4.0
144
- license.
145
  - Coverage is broad but not universal. For example, Mandarin Chinese and Japanese have no
146
  MMS-TTS checkpoint.
147
- - Quality varies by language with the amount of training data. Evaluate a language before
148
- relying on it.
149
 
150
  ## Quick Start
151
 
@@ -155,12 +146,14 @@ if getattr(tokenizer, "is_uroman", False):
155
  pip install torch transformers soundfile
156
  ```
157
 
 
 
158
  ```python
159
  import torch
160
  import soundfile as sf
161
  from transformers import AutoTokenizer, VitsModel
162
 
163
- repo, lang = "SDLC-Corp/TTS", "hin" # lang: "eng", "hin" or "mar"
164
 
165
  tokenizer = AutoTokenizer.from_pretrained(repo, subfolder=lang)
166
  model = VitsModel.from_pretrained(repo, subfolder=lang).eval()
@@ -174,29 +167,29 @@ with torch.inference_mode():
174
  sf.write("output.wav", waveform, model.config.sampling_rate) # 16 kHz WAV
175
  ```
176
 
177
- ## Usage
178
-
179
- ### With the `text-to-speech` pipeline
180
 
181
  ```python
182
- import soundfile as sf
183
- from transformers import AutoTokenizer, VitsModel, pipeline
184
 
185
- repo, lang = "SDLC-Corp/TTS", "eng"
186
- tts = pipeline(
187
- "text-to-speech",
188
- model=VitsModel.from_pretrained(repo, subfolder=lang),
189
- tokenizer=AutoTokenizer.from_pretrained(repo, subfolder=lang),
190
- )
191
 
192
- result = tts("Welcome to SDLC Corp.")
193
- sf.write("welcome.wav", result["audio"].squeeze(), result["sampling_rate"])
 
 
 
 
194
  ```
195
 
196
- ### Serving all three languages
197
 
198
- A minimal service class that loads each language on first use, caches it in memory and runs
199
- on a GPU when one is available:
 
 
 
200
 
201
  ```python
202
  import torch
@@ -205,7 +198,13 @@ from transformers import AutoTokenizer, VitsModel
205
 
206
  class MultilingualTTS:
207
  REPO = "SDLC-Corp/TTS"
208
- LANGUAGES = {"english": "eng", "hindi": "hin", "marathi": "mar"}
 
 
 
 
 
 
209
 
210
  def __init__(self, device: str | None = None):
211
  self.device = device or ("cuda" if torch.cuda.is_available() else "cpu")
@@ -213,16 +212,23 @@ class MultilingualTTS:
213
 
214
  def _load(self, code: str):
215
  if code not in self._models:
216
- tokenizer = AutoTokenizer.from_pretrained(self.REPO, subfolder=code)
217
- model = VitsModel.from_pretrained(self.REPO, subfolder=code)
218
- self._models[code] = (tokenizer, model.to(self.device).eval())
 
 
 
 
219
  return self._models[code]
220
 
221
  @torch.inference_mode()
222
  def synthesize(self, text: str, language: str, seed: int = 0):
223
  """Return (waveform as float32 numpy array, sample_rate)."""
224
- code = self.LANGUAGES.get(language.lower(), language)
225
  tokenizer, model = self._load(code)
 
 
 
226
  inputs = tokenizer(text, return_tensors="pt").to(self.device)
227
  if inputs["input_ids"].shape[-1] == 0:
228
  raise ValueError(f"Text contains no characters supported by the '{code}' model.")
@@ -232,9 +238,30 @@ class MultilingualTTS:
232
 
233
 
234
  tts = MultilingualTTS()
235
- audio, sr = tts.synthesize("नमस्कार, आपले स्वागत आहे.", "marathi")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  ```
237
 
 
 
238
  ### Playback in a notebook
239
 
240
  ```python
@@ -244,7 +271,7 @@ Audio(audio, rate=sr)
244
 
245
  ## Generation Controls
246
 
247
- The following attributes can be adjusted on a loaded model before generation:
248
 
249
  | Attribute | Default | Description |
250
  |---|---|---|
@@ -267,9 +294,10 @@ need deterministic output.
267
  | Supported | Yes, out of the box | Yes, any CUDA-capable GPU |
268
  | Memory per loaded language | ~150 MB RAM | < 1 GB VRAM |
269
  | Typical latency (short sentence) | A few seconds on a laptop CPU | Well under a second |
 
270
 
271
- A free Google Colab or Kaggle T4 GPU is more than sufficient. Each language is downloaded
272
- once (~145 MB) and served from the local Hugging Face cache afterwards.
273
 
274
  ## Technical Specifications
275
 
@@ -280,9 +308,10 @@ once (~145 MB) and served from the local Hugging Face cache afterwards.
280
  | Waveform decoder | HiFi-GAN-style generator, upsampling ×8 · ×8 · ×2 · ×2 |
281
  | Parameters | ~36M per language |
282
  | Weights format | `safetensors`, float32 |
283
- | Tokenizer | `VitsTokenizer`, character-level, no phonemizer or uroman required |
284
  | Speakers | Single speaker per language |
285
  | Output | 16 kHz · mono · float32 waveform |
 
286
  | Training data | MMS read-speech recordings (predominantly religious texts), per Pratap et al. (2023) |
287
  | Original developer | Meta AI |
288
  | Packaged by | [SDLC Corp](https://huggingface.co/SDLC-Corp) |
@@ -291,27 +320,28 @@ once (~145 MB) and served from the local Hugging Face cache afterwards.
291
 
292
  **Suitable for**
293
 
294
- - Research and education in speech synthesis and Indic-language technology
295
- - Accessibility prototypes such as screen readers and read-aloud tools
296
- - Internal demos, proofs of concept and non-commercial applications
297
  - Lightweight on-device or CPU-only deployments
298
 
299
  **Out of scope**
300
 
301
  - Commercial products or services (prohibited by the license)
302
  - Voice cloning, speaker impersonation or expressive/emotional speech
303
- - Languages outside the MMS-TTS coverage list (for example Mandarin Chinese and Japanese)
304
 
305
  ## Limitations
306
 
307
- - **Script must match the model.** Hindi and Marathi expect Devanagari, and English expects
308
- Latin script. Unsupported characters are dropped by the tokenizer, which can result in
309
- empty input. Validate that `input_ids` is non-empty, as shown in the service class above.
310
  - **No text normalization.** Digits, dates, currency and abbreviations are not expanded.
311
  Spell them out (for example "twenty-five" or "पच्चीस") for correct pronunciation.
312
- - **No code-mixing.** Each model speaks one language. Segment mixed-language text (for
313
- example Hinglish) and route each segment to the appropriate model.
314
- - **Single voice.** There is one neutral voice per language, with no speaker or style selection.
 
315
  - **Domain shift.** Training data is predominantly read religious text, so conversational or
316
  technical content may sound less natural.
317
 
@@ -323,8 +353,9 @@ recording. Where generated audio is published, we recommend disclosing that it i
323
 
324
  ## Demo Application
325
 
326
- A Gradio web application built on these models is available on GitHub. It offers language
327
- tabs, a character counter, an audio player, WAV download and automatic CPU/GPU detection.
 
328
 
329
  ```bash
330
  git clone https://github.com/Sudhanshu619/TTS.git
@@ -336,15 +367,17 @@ python app.py # http://12
336
 
337
  ## License
338
 
339
- The model weights are developed by **Meta AI** and distributed under the
 
340
  **[Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)](https://creativecommons.org/licenses/by-nc/4.0/)**
341
  license.
342
 
343
  - **Non-commercial use only.** The models, and audio generated with them, may not be used
344
  for commercial purposes.
345
  - **Attribution.** Credit Meta AI and the MMS authors, and reference the license.
346
- - **Modifications.** The three original checkpoints are consolidated into one repository, and
347
- only the `safetensors` weights are distributed. Model weights are unchanged.
 
348
 
349
  ## Citation
350
 
 
27
 
28
  # SDLC Corp · Multilingual Text-to-Speech
29
 
30
+ **Lightweight, end-to-end speech synthesis for 1,100+ languages, with English, Hindi and Marathi bundled and ready to use**
31
 
32
  [![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC%20BY--NC%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc/4.0/)
33
  [![Task: Text-to-Speech](https://img.shields.io/badge/Task-Text--to--Speech-blue.svg)](#quick-start)
34
+ [![Languages: 1,100+](https://img.shields.io/badge/Languages-1%2C100%2B-green.svg)](#languages)
35
+ [![Bundled: EN | HI | MR](https://img.shields.io/badge/Bundled-EN%20%7C%20HI%20%7C%20MR-teal.svg)](#bundled-languages)
36
  [![Transformers](https://img.shields.io/badge/%F0%9F%A4%97%20Transformers-VITS-orange.svg)](https://huggingface.co/docs/transformers/model_doc/vits)
37
+ [![Audio](https://img.shields.io/badge/Audio-16%20kHz%20mono-purple.svg)](#technical-specifications)
38
 
39
  </div>
40
 
 
42
 
43
  ## Overview
44
 
45
+ **SDLC Corp Multilingual TTS** turns text into natural speech in **more than 1,100 languages**
46
+ through one consistent 🤗 Transformers interface. It is built on Meta AI's
47
+ [Massively Multilingual Speech (MMS)](https://arxiv.org/abs/2305.13516) text-to-speech models,
48
+ which use the VITS architecture.
49
 
50
+ Language support works on two levels:
51
 
52
+ | | Languages | Loaded from | What you change |
53
+ |---|---|---|---|
54
+ | **Bundled** | English, Hindi, Marathi | `SDLC-Corp/TTS` (this repository) | `subfolder="eng"`, `"hin"` or `"mar"` |
55
+ | **Extended** | 1,100+ others, such as Bengali, Tamil, Telugu, Spanish, French and Arabic | `facebook/mms-tts-<code>` (Meta) | The model ID |
56
+
57
+ The code, API and output format are the same for every language. The
58
+ [`MultilingualTTS` class](#one-interface-for-every-language) below handles both levels
59
+ automatically, so you pass a language name and get audio back.
60
+
61
+ ### Highlights
62
+
63
+ - **1,100+ languages, one interface.** Bundled and extended languages share the same API.
64
+ - **End to end.** Text goes in and a 16 kHz waveform comes out, with no separate vocoder or
65
+ phonemizer.
66
  - **Lightweight.** About 36M parameters and 145 MB per language, fast enough for a CPU.
67
+ - **Native scripts.** Devanagari, Bengali, Tamil, Arabic and many other scripts are taken
68
+ directly. A small number of languages need romanization, which is
69
+ [handled for you](#romanized-languages).
70
+ - **Load on demand.** Each language downloads only once, on first use, and is cached locally.
71
 
72
  ## Table of Contents
73
 
74
+ 1. [Languages](#languages)
75
+ 2. [Quick Start](#quick-start)
76
+ 3. [Usage](#usage)
77
+ 4. [Generation Controls](#generation-controls)
78
+ 5. [Performance and Hardware](#performance-and-hardware)
79
+ 6. [Technical Specifications](#technical-specifications)
80
+ 7. [Intended Use](#intended-use)
81
+ 8. [Limitations](#limitations)
82
+ 9. [Ethical Considerations](#ethical-considerations)
83
+ 10. [Demo Application](#demo-application)
84
+ 11. [License](#license)
85
+ 12. [Citation](#citation)
86
+
87
+ ## Languages
88
+
89
+ ### Bundled languages
90
+
91
+ Stored in this repository and loaded with `subfolder=`:
92
+
93
+ | Language | Code | Script | Vocabulary | Source checkpoint |
94
  |---|---|---|---|---|
95
  | English | `eng` | Latin (lowercased automatically) | 38 symbols | [facebook/mms-tts-eng](https://huggingface.co/facebook/mms-tts-eng) |
96
  | Hindi (हिन्दी) | `hin` | Devanagari | 72 symbols | [facebook/mms-tts-hin](https://huggingface.co/facebook/mms-tts-hin) |
97
  | Marathi (मराठी) | `mar` | Devanagari | 73 symbols | [facebook/mms-tts-mar](https://huggingface.co/facebook/mms-tts-mar) |
98
 
 
 
99
  ```
100
  SDLC-Corp/TTS
101
  ├── eng/ ─┐
 
105
  └── README.md
106
  ```
107
 
108
+ Only the requested subfolder is downloaded, so loading Hindi does not fetch English or Marathi.
 
 
 
109
 
110
+ ### Extended languages (1,100+)
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
+ Every other language uses Meta's checkpoint `facebook/mms-tts-<code>`, where `<code>` is the
113
+ [ISO 639-3](https://iso639-3.sil.org/code_tables/639/data) language code. Some languages have
114
+ script variants, such as `urd-script_arabic`. Commonly used examples:
115
 
116
+ | Region | Languages (code) |
117
  |---|---|
118
  | India and South Asia | Bengali (`ben`) · Tamil (`tam`) · Telugu (`tel`) · Gujarati (`guj`) · Kannada (`kan`) · Malayalam (`mal`) · Punjabi (`pan`) · Odia (`ory`) · Assamese (`asm`) · Urdu (`urd-script_arabic`, `urd-script_devanagari`, `urd-script_latin`) |
119
  | Europe | Spanish (`spa`) · French (`fra`) · German (`deu`) · Portuguese (`por`) · Russian (`rus`) |
120
  | Middle East and Africa | Arabic (`ara`) · Swahili (`swh`) · Yoruba (`yor`) |
121
+ | East and Southeast Asia | Indonesian (`ind`) · Vietnamese (`vie`) · Thai (`tha`) · Korean (`kor`, romanized) |
122
 
123
+ **Find your language:** browse all checkpoints on the
124
+ [Hugging Face Hub](https://huggingface.co/models?search=facebook/mms-tts) or in
125
  [Meta's language coverage list](https://dl.fbaipublicfiles.com/mms/misc/language_coverage_mms.html).
126
 
127
+ ### Romanized languages
 
 
128
 
129
+ A few checkpoints, such as Korean, were trained on romanized text. Their tokenizer reports
130
+ `is_uroman = True`, and input must first be converted to Latin script with
131
+ [uroman](https://github.com/isi-nlp/uroman) (`pip install uroman`). The
132
+ [`MultilingualTTS` class](#one-interface-for-every-language) does this automatically.
133
 
134
+ ### Coverage notes
 
 
 
 
135
 
 
 
 
136
  - Coverage is broad but not universal. For example, Mandarin Chinese and Japanese have no
137
  MMS-TTS checkpoint.
138
+ - Quality varies by language with the amount of training data. Evaluate a language on your
139
+ own content before relying on it.
140
 
141
  ## Quick Start
142
 
 
146
  pip install torch transformers soundfile
147
  ```
148
 
149
+ **A bundled language** (English, Hindi or Marathi):
150
+
151
  ```python
152
  import torch
153
  import soundfile as sf
154
  from transformers import AutoTokenizer, VitsModel
155
 
156
+ repo, lang = "SDLC-Corp/TTS", "hin" # "eng", "hin" or "mar"
157
 
158
  tokenizer = AutoTokenizer.from_pretrained(repo, subfolder=lang)
159
  model = VitsModel.from_pretrained(repo, subfolder=lang).eval()
 
167
  sf.write("output.wav", waveform, model.config.sampling_rate) # 16 kHz WAV
168
  ```
169
 
170
+ **Any other language.** Use Meta's model ID and drop `subfolder`:
 
 
171
 
172
  ```python
173
+ model_id = "facebook/mms-tts-tam" # Tamil
 
174
 
175
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
176
+ model = VitsModel.from_pretrained(model_id).eval()
 
 
 
 
177
 
178
+ inputs = tokenizer("வணக்கம், எப்படி இருக்கிறீர்கள்?", return_tensors="pt")
179
+ torch.manual_seed(0)
180
+ with torch.inference_mode():
181
+ waveform = model(**inputs).waveform[0].numpy()
182
+
183
+ sf.write("tamil.wav", waveform, model.config.sampling_rate)
184
  ```
185
 
186
+ ## Usage
187
 
188
+ ### One interface for every language
189
+
190
+ `MultilingualTTS` takes a language name or code. It loads bundled languages from this
191
+ repository and all others from Meta, romanizes input where required, caches loaded models,
192
+ and uses a GPU when one is available.
193
 
194
  ```python
195
  import torch
 
198
 
199
  class MultilingualTTS:
200
  REPO = "SDLC-Corp/TTS"
201
+ BUNDLED = {"eng", "hin", "mar"}
202
+ ALIASES = {
203
+ "english": "eng", "hindi": "hin", "marathi": "mar",
204
+ "bengali": "ben", "tamil": "tam", "telugu": "tel", "gujarati": "guj",
205
+ "kannada": "kan", "malayalam": "mal", "punjabi": "pan", "odia": "ory",
206
+ "spanish": "spa", "french": "fra", "german": "deu", "arabic": "ara",
207
+ }
208
 
209
  def __init__(self, device: str | None = None):
210
  self.device = device or ("cuda" if torch.cuda.is_available() else "cpu")
 
212
 
213
  def _load(self, code: str):
214
  if code not in self._models:
215
+ if code in self.BUNDLED:
216
+ repo, kwargs = self.REPO, {"subfolder": code}
217
+ else:
218
+ repo, kwargs = f"facebook/mms-tts-{code}", {}
219
+ tokenizer = AutoTokenizer.from_pretrained(repo, **kwargs)
220
+ model = VitsModel.from_pretrained(repo, **kwargs).to(self.device).eval()
221
+ self._models[code] = (tokenizer, model)
222
  return self._models[code]
223
 
224
  @torch.inference_mode()
225
  def synthesize(self, text: str, language: str, seed: int = 0):
226
  """Return (waveform as float32 numpy array, sample_rate)."""
227
+ code = self.ALIASES.get(language.lower(), language)
228
  tokenizer, model = self._load(code)
229
+ if getattr(tokenizer, "is_uroman", False):
230
+ import uroman # pip install uroman
231
+ text = uroman.Uroman().romanize_string(text)
232
  inputs = tokenizer(text, return_tensors="pt").to(self.device)
233
  if inputs["input_ids"].shape[-1] == 0:
234
  raise ValueError(f"Text contains no characters supported by the '{code}' model.")
 
238
 
239
 
240
  tts = MultilingualTTS()
241
+ audio, sr = tts.synthesize("नमस्कार, आपले स्वागत आहे.", "marathi") # bundled
242
+ audio, sr = tts.synthesize("নমস্কার, আপনি কেমন আছেন?", "bengali") # extended
243
+ audio, sr = tts.synthesize("Hola, ¿cómo estás?", "spa") # any ISO 639-3 code
244
+ ```
245
+
246
+ ### With the `text-to-speech` pipeline
247
+
248
+ ```python
249
+ import soundfile as sf
250
+ from transformers import AutoTokenizer, VitsModel, pipeline
251
+
252
+ repo, lang = "SDLC-Corp/TTS", "eng"
253
+ tts_pipe = pipeline(
254
+ "text-to-speech",
255
+ model=VitsModel.from_pretrained(repo, subfolder=lang),
256
+ tokenizer=AutoTokenizer.from_pretrained(repo, subfolder=lang),
257
+ )
258
+
259
+ result = tts_pipe("Welcome to SDLC Corp.")
260
+ sf.write("welcome.wav", result["audio"].squeeze(), result["sampling_rate"])
261
  ```
262
 
263
+ For an extended language, pass `pipeline("text-to-speech", model="facebook/mms-tts-<code>")`.
264
+
265
  ### Playback in a notebook
266
 
267
  ```python
 
271
 
272
  ## Generation Controls
273
 
274
+ These attributes can be adjusted on any loaded model before generation:
275
 
276
  | Attribute | Default | Description |
277
  |---|---|---|
 
294
  | Supported | Yes, out of the box | Yes, any CUDA-capable GPU |
295
  | Memory per loaded language | ~150 MB RAM | < 1 GB VRAM |
296
  | Typical latency (short sentence) | A few seconds on a laptop CPU | Well under a second |
297
+ | Download per language | ~145 MB, once | ~145 MB, once |
298
 
299
+ Every language uses the same architecture, so these figures apply to all of them. A free
300
+ Google Colab or Kaggle T4 GPU is more than sufficient.
301
 
302
  ## Technical Specifications
303
 
 
308
  | Waveform decoder | HiFi-GAN-style generator, upsampling ×8 · ×8 · ×2 · ×2 |
309
  | Parameters | ~36M per language |
310
  | Weights format | `safetensors`, float32 |
311
+ | Tokenizer | `VitsTokenizer`, character-level; uroman romanization for a small set of languages |
312
  | Speakers | Single speaker per language |
313
  | Output | 16 kHz · mono · float32 waveform |
314
+ | Language coverage | 3 bundled (eng, hin, mar) · 1,100+ via MMS-TTS checkpoints |
315
  | Training data | MMS read-speech recordings (predominantly religious texts), per Pratap et al. (2023) |
316
  | Original developer | Meta AI |
317
  | Packaged by | [SDLC Corp](https://huggingface.co/SDLC-Corp) |
 
320
 
321
  **Suitable for**
322
 
323
+ - Multilingual products and research, especially for Indian and low-resource languages
324
+ - Accessibility tools such as screen readers and read-aloud features
325
+ - Education, language-learning material, internal demos and proofs of concept
326
  - Lightweight on-device or CPU-only deployments
327
 
328
  **Out of scope**
329
 
330
  - Commercial products or services (prohibited by the license)
331
  - Voice cloning, speaker impersonation or expressive/emotional speech
332
+ - Languages without an MMS-TTS checkpoint (for example Mandarin Chinese and Japanese)
333
 
334
  ## Limitations
335
 
336
+ - **Script must match the model.** Each model expects its own script (for example Devanagari
337
+ for Hindi, Tamil script for Tamil). Unsupported characters are dropped by the tokenizer,
338
+ which can result in empty input. The `MultilingualTTS` class checks for this.
339
  - **No text normalization.** Digits, dates, currency and abbreviations are not expanded.
340
  Spell them out (for example "twenty-five" or "पच्चीस") for correct pronunciation.
341
+ - **One language per model.** Segment mixed-language text (for example Hinglish) and route
342
+ each segment to the matching language.
343
+ - **Single voice.** One neutral voice per language, with no speaker or style selection.
344
+ - **Uneven quality.** Naturalness varies across languages with the amount of training data.
345
  - **Domain shift.** Training data is predominantly read religious text, so conversational or
346
  technical content may sound less natural.
347
 
 
353
 
354
  ## Demo Application
355
 
356
+ A Gradio web application for the bundled languages is available on GitHub. It offers
357
+ language tabs, a character counter, an audio player, WAV download and automatic CPU/GPU
358
+ detection.
359
 
360
  ```bash
361
  git clone https://github.com/Sudhanshu619/TTS.git
 
367
 
368
  ## License
369
 
370
+ All MMS-TTS model weights, both those bundled here and Meta's extended-language checkpoints,
371
+ are developed by **Meta AI** and distributed under the
372
  **[Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)](https://creativecommons.org/licenses/by-nc/4.0/)**
373
  license.
374
 
375
  - **Non-commercial use only.** The models, and audio generated with them, may not be used
376
  for commercial purposes.
377
  - **Attribution.** Credit Meta AI and the MMS authors, and reference the license.
378
+ - **Modifications.** The English, Hindi and Marathi checkpoints are consolidated into one
379
+ repository, and only their `safetensors` weights are distributed. Model weights are
380
+ unchanged. Extended languages are loaded directly from Meta's repositories.
381
 
382
  ## Citation
383