Views
No views yet
| File | Purpose |
|---|---|
feature_prediction.ckpt | Trained FastSpeech2 feature-prediction weights. |
vocoder.ckpt | HiFi-GAN vocoder checkpoint (optional — can be replaced with a universal vocoder). |
config/ | EveryVoice YAML config files (shared data, text, feature-prediction, spec-to-wav). |
filelist.psv | Pipe-separated training filelist (`basename |
pip install everyvoice1import torch
2from pathlib import Path
3from huggingface_hub import snapshot_download
4
5from everyvoice.config.type_definitions import DatasetTextRepresentation
6from everyvoice.model.feature_prediction.FastSpeech2_lightning.fs2.cli.synthesize import (
7 get_global_step,
8 synthesize_helper,
9)
10from everyvoice.model.feature_prediction.FastSpeech2_lightning.fs2.model import FastSpeech2
11from everyvoice.model.feature_prediction.FastSpeech2_lightning.fs2.type_definitions import (
12 SynthesizeOutputFormats,
13)
14from everyvoice.model.vocoder.HiFiGAN_iSTFT_lightning.hfgl.utils import (
15 load_hifigan_from_checkpoint,
16)
17from everyvoice.utils.heavy import get_device_from_accelerator
18
19repo_id = "multilingual-tts/EveryVoice-OpenBible-Haitian-Creole"
20local = Path(snapshot_download(repo_id))
21
22ckpt_path = local / "feature_prediction.ckpt"
23vocoder_path = local / "vocoder.ckpt"
24
25accelerator = "gpu" if torch.cuda.is_available() else "cpu"
26device = get_device_from_accelerator(accelerator)
27
28model = FastSpeech2.load_from_checkpoint(str(ckpt_path)).to(device)
29model.eval()
30global_step = get_global_step(ckpt_path)
31
32vocoder_ckpt = torch.load(str(vocoder_path), map_location=device, weights_only=True)
33vocoder_model, vocoder_config = load_hifigan_from_checkpoint(vocoder_ckpt, device)
34vocoder_global_step = get_global_step(vocoder_path)
35
36# Pick any speaker from the model
37speaker = next(iter(model.speaker2id.keys()))
38language = next(iter(model.lang2id.keys()))
39print(f"Available speakers: {list(model.speaker2id.keys())}")
40
41filelist_data = [
42 {
43 "basename": "sample-0",
44 "characters": "...", # text to synthesise in Haitian Creole
45 "language": language,
46 "speaker": speaker,
47 "duration_control": 1.0,
48 }
49]
50
51output_dir = Path("everyvoice_output")
52output_dir.mkdir(exist_ok=True)
53
54synthesize_helper(
55 model=model,
56 texts=None,
57 style_reference=None,
58 language=None,
59 speaker=None,
60 duration_control=1.0,
61 global_step=global_step,
62 output_type=[SynthesizeOutputFormats.wav],
63 text_representation=DatasetTextRepresentation.characters,
64 accelerator=accelerator,
65 devices="auto",
66 device=device,
67 batch_size=1,
68 num_workers=1,
69 filelist=None,
70 filelist_data=filelist_data,
71 output_dir=output_dir,
72 teacher_forcing_directory=None,
73 vocoder_model=vocoder_model,
74 vocoder_config=vocoder_config,
75 vocoder_global_step=vocoder_global_step,
76)
77# Generated WAVs land in output_dir/wav/davidguzmanr/open-bible-resources, config Haitian Creole