lpw commited on
Commit
8ec7b71
1 Parent(s): e2f8325

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +102 -3
README.md CHANGED
@@ -1,7 +1,106 @@
1
- model: /checkpoint/yilinyang/s2st/en2hok_fbank/v1.rdrop_0.ls_0.1.maxtok_3.0k.uf_2.lr_0.0005.wu_2k.seed_1234.arch_xm_transformer_t2.frz_5000.dr_0.1.ld_0.1.mcl_10.al_1.dld0.1.ca.mtl_config_t2_tug65k8.0_rdrop10.0.tdec_12L.synenc_2L.syndec_2L.ngpu160/checkpoint_last.pt
 
 
 
 
 
 
 
2
 
3
- python ust_common/scripts/generation/st/run_asr_bleu_pipeline.py data=/large_experiments/ust/yilinyang/data/s2st/en2hok gen_subset=dev_mustc_h1 --config-name=s2u_hok config_yaml=config_t2_fbank.yaml unit_generation_args.max_tokens=6000 +unit_generation_args.multitask_config_yaml=mtl_config_t2_tug65k8.0_rdrop10.0.yaml +unit_generation_args.beam_mt=10 unit_generation_args.beam=10 unit_generation_args.max_len_a=2 +unit_generation_args.max_len_b=200 +unit_generation_args.max_len_a_mt=2 +unit_generation_args.max_len_b_mt=200 checkpoint_filename=checkpoint_last.pt experiment_dirpath=/checkpoint/yilinyang/s2st/en2hok_fbank/v1.rdrop_0.ls_0.1.maxtok_3.0k.uf_2.lr_0.0005.wu_2k.seed_1234.arch_xm_transformer_t2.frz_5000.dr_0.1.ld_0.1.mcl_10.al_1.dld0.1.ca.mtl_config_t2_tug65k8.0_rdrop10.0.tdec_12L.synenc_2L.syndec_2L.ngpu160/
 
 
 
 
 
 
 
 
 
4
 
5
- w2v2: /checkpoint/andyyuan/ckpt_from_rsc/w2v2_fbank_rope_LL_1000k.pt
 
 
 
6
 
 
 
 
 
 
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: fairseq
3
+ task: audio-to-audio
4
+ tags:
5
+ - fairseq
6
+ - audio
7
+ - audio-to-audio
8
+ - speech-to-speech-translation
9
 
10
+ datasets:
11
+ - mtedx
12
+ - covost2
13
+ - europarl_st
14
+ - voxpopuli
15
+ widget:
16
+ - example_title: Common Voice sample 1
17
+ src: https://huggingface.co/facebook/xm_transformer_600m-es_en-multi_domain/resolve/main/common_voice_es_19966634.flac
18
+ ---
19
+ ## xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022
20
 
21
+ Speech-to-speech translation model from fairseq S2UT ([paper](https://arxiv.org/abs/2204.02967)/[code](https://github.com/facebookresearch/fairseq/blob/main/examples/speech_to_speech/docs/enhanced_direct_s2st_discrete_units.md)):
22
+ - Spanish-English
23
+ - Trained on mTEDx, CoVoST 2, Europarl-ST and VoxPopuli
24
+ - 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)
25
 
26
+ ## Usage
27
+ ```python
28
+ import json
29
+ import os
30
+ from pathlib import Path
31
 
32
+ import IPython.display as ipd
33
+ from fairseq import hub_utils
34
+ from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
35
+ from fairseq.models.speech_to_text.hub_interface import S2THubInterface
36
+ from fairseq.models.text_to_speech import CodeHiFiGANVocoder
37
+ from fairseq.models.text_to_speech.hub_interface import VocoderHubInterface
38
+
39
+ from huggingface_hub import snapshot_download
40
+ import torchaudio
41
+
42
+ cache_dir = os.getenv("HUGGINGFACE_HUB_CACHE")
43
+
44
+ models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
45
+ "facebook/xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022",
46
+ arg_overrides={"config_yaml": "config.yaml", "task": "speech_to_text"},
47
+ cache_dir=cache_dir,
48
+ )
49
+ #model = models[0].cpu()
50
+ #cfg["task"].cpu = True
51
+ generator = task.build_generator([model], cfg)
52
+
53
+
54
+ # requires 16000Hz mono channel audio
55
+ audio, _ = torchaudio.load("/path/to/an/audio/file")
56
+
57
+ sample = S2THubInterface.get_model_input(task, audio)
58
+ unit = S2THubInterface.get_prediction(task, model, generator, sample)
59
+
60
+ # speech synthesis
61
+ library_name = "fairseq"
62
+ cache_dir = (
63
+ cache_dir or (Path.home() / ".cache" / library_name).as_posix()
64
+ )
65
+ cache_dir = snapshot_download(
66
+ f"facebook/unit_hifigan_mhubert_vp_en_es_fr_it3_400k_layer11_km1000_lj_dur", cache_dir=cache_dir, library_name=library_name
67
+ )
68
+
69
+ x = hub_utils.from_pretrained(
70
+ cache_dir,
71
+ "model.pt",
72
+ ".",
73
+ archive_map=CodeHiFiGANVocoder.hub_models(),
74
+ config_yaml="config.json",
75
+ fp16=False,
76
+ is_vocoder=True,
77
+ )
78
+
79
+ with open(f"{x['args']['data']}/config.json") as f:
80
+ vocoder_cfg = json.load(f)
81
+ assert (
82
+ len(x["args"]["model_path"]) == 1
83
+ ), "Too many vocoder models in the input"
84
+
85
+ vocoder = CodeHiFiGANVocoder(x["args"]["model_path"][0], vocoder_cfg)
86
+ tts_model = VocoderHubInterface(vocoder_cfg, vocoder)
87
+
88
+ tts_sample = tts_model.get_model_input(unit)
89
+ wav, sr = tts_model.get_prediction(tts_sample)
90
+
91
+ ipd.Audio(wav, rate=sr)
92
+ ```
93
+
94
+ ## Citation
95
+ ```bibtex
96
+ @misc{https://doi.org/10.48550/arxiv.2204.02967,
97
+ doi = {10.48550/ARXIV.2204.02967},
98
+ url = {https://arxiv.org/abs/2204.02967},
99
+ author = {Popuri, Sravya and Chen, Peng-Jen and Wang, Changhan and Pino, Juan and Adi, Yossi and Gu, Jiatao and Hsu, Wei-Ning and Lee, Ann},
100
+ keywords = {Computation and Language (cs.CL), Sound (cs.SD), Audio and Speech Processing (eess.AS), FOS: Computer and information sciences, FOS: Computer and information sciences, FOS: Electrical engineering, electronic engineering, information engineering, FOS: Electrical engineering, electronic engineering, information engineering},
101
+ title = {Enhanced Direct Speech-to-Speech Translation Using Self-supervised Pre-training and Data Augmentation},
102
+ publisher = {arXiv},
103
+ year = {2022},
104
+ copyright = {arXiv.org perpetual, non-exclusive license}
105
+ }
106
+ ```