Fine-tuning microsoft/speecht5_tts for a Devanagari-script language, starting from a metadata
file that pairs example sentences with audio filenames.
- Python 3.11 (
.venvin this folder) — chosen over 3.12+ because some audio-stack dependencies (numba/librosa via speechbrain) have historically lagged on Windows wheel support for newer Python releases, and over 3.9 because it's approaching end-of-life for current transformers releases. - GPU: NVIDIA RTX 4060 Laptop (8GB VRAM), CUDA 13.0 driver.
torch/torchaudioinstalled fromhttps://download.pytorch.org/whl/cu130(seerequirements.txt).
To activate:
.\.venv\Scripts\Activate.ps1- speechbrain model caching uses symlinks by default and this actually fails (not just
falls back) on Windows without Developer Mode / elevated privileges — confirmed while
building this project (
OSError: [WinError 1314] A required privilege is not held...).HF_HUB_DISABLE_SYMLINKSdoes not control this — speechbrain'sfetch()has its ownlocal_strategyargument, separate from the HF Hub cache. Fix: passlocal_strategy=speechbrain.utils.fetching.LocalStrategy.COPYtoEncoderClassifier.from_hparams(...)(seesrc/prepare_dataset.py). Alternatively enable Developer Mode (Settings > Privacy & Security > For Developers) and the default symlink strategy works fine. torchaudio'ssox_iobackend does not exist on Windows (no sox wheels). Force thesoundfilebackend explicitly in code rather than relying on autodetection.- DataLoader workers: Windows uses the
spawnmultiprocessing start method (notfork), so any script usingnum_workers > 0in aDataLoadermust guard the entry point withif __name__ == "__main__":, or worker processes will fail to start / re-import the whole script. - Long paths: Hugging Face Hub cache paths can get deep. If you hit
FileNotFoundError/ path-too-long errors, enable Windows long path support (git config --system core.longpaths trueand theLongPathsEnabledregistry key), or setHF_HOMEto a short path likeC:\hf. datasets.Dataset.map(num_proc=N)crashes at the very end on Windows, even atnum_proc=1— it still routes through amultiprocessing.Pool, and Windows named pipes fail (OSError: [WinError 87] The parameter is incorrect) sending the large accumulated result back to the main process once the (otherwise fully successful) work is done. This cost a full 32-minute GPU pass while building this project. Fix: don't passnum_procat all for GPU-bound.map()calls — it runs in-process with no pipe involved, and there's no parallelism to gain anyway since the GPU is the bottleneck.datasets5.x'sAudio()feature now requires thetorchcodecpackage (with its own FFmpeg dependency) to decode audio. Rather than add that dependency chain,src/prepare_dataset.pyreads/resamples audio directly withsoundfile+librosaand never usesAudio()/cast_column.- speechbrain's pinned dependency versions have drifted from what the very newest
transformers/huggingface_hub/torchaudioprovide, since we installed current bleeding-edge versions of everything:speechbrain==1.1.0'sXvectormodel does a lazy import of an unrelatedk2FSA integration that crashes on import (nok2Windows wheels exist) — pinspeechbrain==1.0.3instead. That older speechbrain in turn expects an oldertorchaudio(list_audio_backends(), removed upstream) and an olderhuggingface_hub(use_auth_tokenkwarg, removed; and it expects a 404 to raiserequests.exceptions.HTTPError, but currenthuggingface_hubuseshttpxand raisesHfHubHTTPErrorinstead, which speechbrain'sexceptclause doesn't catch). All three are patched narrowly insrc/prepare_dataset.py(only inside speechbrain's own module namespace, sotransformers' unrelated use of the samehuggingface_hubfunctions isn't affected).
data/
metadata/ # your sentence <-> audio-filename mapping file(s) go here
audio/ # raw audio clips referenced by the metadata file
notebooks/ # exploratory notebooks
src/ # data prep / training scripts
requirements.txt
- Python 3.11 venv created, CUDA-enabled torch verified working with the RTX 4060.
- Metadata file format confirmed and a loader script written.
- Dataset prep (resampling to 16kHz, speaker embeddings via speechbrain x-vector).
- Fine-tuning script (Seq2SeqTrainer).
- Inference / listening test.
..venv\Scripts\python.exe src\infer.py --list-characters
..venv\Scripts\python.exe src\infer.py --text "“ध़रत्तिआ पर तह़रा-तह़रा देआं बीआं बाल़िआं सब्जिआं कने हरे-भ़रे बूट्टे, कने बीआं बाल़े फल़दार रुक्ख भ़ी अपणिआं-अपणिआं किस्मा दे मताबक लगी जाह़ण।”" --character "God"
A/B test: synthesize N held-out validation lines + copy the real recording alongside, so you can compare directly
..venv\Scripts\python.exe src\infer.py --compare 5 --character "Jesus"