Update README.md
Browse files
README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
---
|
2 |
-
license: cc-by-nc-4.0
|
3 |
library_name: fairseq
|
4 |
task: audio-to-audio
|
5 |
tags:
|
@@ -16,71 +15,7 @@ widget:
|
|
16 |
- Speech synthesis with [facebook/unit_hifigan_mhubert_vp_en_es_fr_it3_400k_layer11_km1000_lj_dur](https://huggingface.co/facebook/unit_hifigan_mhubert_vp_en_es_fr_it3_400k_layer11_km1000_lj_dur)
|
17 |
|
18 |
## Usage
|
19 |
-
|
20 |
-
import json
|
21 |
-
import os
|
22 |
-
from pathlib import Path
|
23 |
-
|
24 |
-
import IPython.display as ipd
|
25 |
-
from fairseq import hub_utils
|
26 |
-
from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
|
27 |
-
from fairseq.models.speech_to_text.hub_interface import S2THubInterface
|
28 |
-
from fairseq.models.text_to_speech import CodeHiFiGANVocoder
|
29 |
-
from fairseq.models.text_to_speech.hub_interface import VocoderHubInterface
|
30 |
-
|
31 |
-
from huggingface_hub import snapshot_download
|
32 |
-
import torchaudio
|
33 |
-
|
34 |
-
cache_dir = os.getenv("HUGGINGFACE_HUB_CACHE")
|
35 |
-
|
36 |
-
models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
|
37 |
-
"facebook/xm_transformer_sm_all-en",
|
38 |
-
arg_overrides={"config_yaml": "config.yaml", "task": "speech_to_text"},
|
39 |
-
cache_dir=cache_dir,
|
40 |
-
)
|
41 |
-
#model = models[0].cpu()
|
42 |
-
#cfg["task"].cpu = True
|
43 |
-
generator = task.build_generator([model], cfg)
|
44 |
-
|
45 |
-
|
46 |
-
# requires 16000Hz mono channel audio
|
47 |
-
audio, _ = torchaudio.load("/path/to/an/audio/file")
|
48 |
-
|
49 |
-
sample = S2THubInterface.get_model_input(task, audio)
|
50 |
-
unit = S2THubInterface.get_prediction(task, model, generator, sample)
|
51 |
-
|
52 |
-
# speech synthesis
|
53 |
-
library_name = "fairseq"
|
54 |
-
cache_dir = (
|
55 |
-
cache_dir or (Path.home() / ".cache" / library_name).as_posix()
|
56 |
-
)
|
57 |
-
cache_dir = snapshot_download(
|
58 |
-
f"facebook/unit_hifigan_mhubert_vp_en_es_fr_it3_400k_layer11_km1000_lj_dur", cache_dir=cache_dir, library_name=library_name
|
59 |
-
)
|
60 |
-
|
61 |
-
x = hub_utils.from_pretrained(
|
62 |
-
cache_dir,
|
63 |
-
"model.pt",
|
64 |
-
".",
|
65 |
-
archive_map=CodeHiFiGANVocoder.hub_models(),
|
66 |
-
config_yaml="config.json",
|
67 |
-
fp16=False,
|
68 |
-
is_vocoder=True,
|
69 |
-
)
|
70 |
-
|
71 |
-
with open(f"{x['args']['data']}/config.json") as f:
|
72 |
-
vocoder_cfg = json.load(f)
|
73 |
-
assert (
|
74 |
-
len(x["args"]["model_path"]) == 1
|
75 |
-
), "Too many vocoder models in the input"
|
76 |
-
|
77 |
-
vocoder = CodeHiFiGANVocoder(x["args"]["model_path"][0], vocoder_cfg)
|
78 |
-
tts_model = VocoderHubInterface(vocoder_cfg, vocoder)
|
79 |
-
|
80 |
-
tts_sample = tts_model.get_model_input(unit)
|
81 |
-
wav, sr = tts_model.get_prediction(tts_sample)
|
82 |
-
|
83 |
-
ipd.Audio(wav, rate=sr)
|
84 |
```
|
85 |
|
86 |
## Citation
|
|
|
1 |
---
|
|
|
2 |
library_name: fairseq
|
3 |
task: audio-to-audio
|
4 |
tags:
|
|
|
15 |
- Speech synthesis with [facebook/unit_hifigan_mhubert_vp_en_es_fr_it3_400k_layer11_km1000_lj_dur](https://huggingface.co/facebook/unit_hifigan_mhubert_vp_en_es_fr_it3_400k_layer11_km1000_lj_dur)
|
16 |
|
17 |
## Usage
|
18 |
+
TODO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
```
|
20 |
|
21 |
## Citation
|