Update README.md
Browse files
README.md
CHANGED
@@ -9,40 +9,4 @@ language: en
|
|
9 |
datasets:
|
10 |
- common_voice
|
11 |
---
|
12 |
-
## Example
|
13 |
-
|
14 |
-
The following should work with fairseq's most up-to-date version in a google colab:
|
15 |
-
|
16 |
-
```python
|
17 |
-
from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
|
18 |
-
import IPython.display as ipd
|
19 |
-
import torch
|
20 |
-
|
21 |
-
model_ensemble, cfg, task = load_model_ensemble_and_task_from_hf_hub(
|
22 |
-
"facebook/tts_transformer-en-multi_speaker-cv4", arg_overrides={"vocoder": "griffin_lim", "fp16": False}
|
23 |
-
)
|
24 |
-
|
25 |
-
def tokenize(text):
|
26 |
-
import g2p_en
|
27 |
-
tokenized = g2p_en.G2p()(text)
|
28 |
-
tokenized = [{",": "sp", ";": "sp"}.get(p, p) for p in tokenized]
|
29 |
-
return " ".join(p for p in tokenized if p.isalnum())
|
30 |
-
|
31 |
-
text = "Hello, this is a test run."
|
32 |
-
|
33 |
-
tokenized = tokenize(text)
|
34 |
-
sample = {
|
35 |
-
"net_input": {
|
36 |
-
"src_tokens": task.src_dict.encode_line(tokenized).view(1, -1),
|
37 |
-
"src_lengths": torch.Tensor([len(tokenized.split())]).long(),
|
38 |
-
"prev_output_tokens": None
|
39 |
-
},
|
40 |
-
"target_lengths": None,
|
41 |
-
"speaker": None,
|
42 |
-
}
|
43 |
-
generator = task.build_generator(model_ensemble, cfg)
|
44 |
-
generation = generator.generate(model_ensemble[0], sample)
|
45 |
-
waveform = generation[0]["waveform"]
|
46 |
-
|
47 |
-
ipd.Audio(waveform, rate=task.sr)
|
48 |
-
```
|
|
|
9 |
datasets:
|
10 |
- common_voice
|
11 |
---
|
12 |
+
## Example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|