Update README.md
Browse files
README.md
CHANGED
@@ -23,6 +23,49 @@ It achieves the following results on the evaluation set:
|
|
23 |
- epoch: 13.2653
|
24 |
- step: 6500
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
## Model description
|
27 |
|
28 |
More information needed
|
|
|
23 |
- epoch: 13.2653
|
24 |
- step: 6500
|
25 |
|
26 |
+
## How to use
|
27 |
+
|
28 |
+
```
|
29 |
+
|
30 |
+
from transformers import SpeechT5ForTextToSpeech, SpeechT5ForSpeechToText
|
31 |
+
from transformers import SpeechT5Processor
|
32 |
+
from transformers import AutoTokenizer
|
33 |
+
from transformers import SpeechT5HifiGan
|
34 |
+
import torch
|
35 |
+
from IPython.display import Audio as IPythonAudio
|
36 |
+
|
37 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
38 |
+
|
39 |
+
# imporing speech processor from another repo
|
40 |
+
processor = SpeechT5Processor.from_pretrained("Sana1207/Hindi_SpeechT5_finetuned")
|
41 |
+
|
42 |
+
# importing tokenizer and assigning it to the speech processor
|
43 |
+
tokenizer = AutoTokenizer.from_pretrained("fahadqazi/Sindhi-TTS")
|
44 |
+
processor.tokenizer = tokenizer
|
45 |
+
|
46 |
+
# importing the model
|
47 |
+
model = SpeechT5ForTextToSpeech.from_pretrained("fahadqazi/Sindhi-TTS")
|
48 |
+
|
49 |
+
# importing the vocoder from microsoft's repository
|
50 |
+
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").to(device)
|
51 |
+
|
52 |
+
# loading random vocodings (the voice)
|
53 |
+
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
54 |
+
speaker_embeddings = embeddings_dataset[7306]["xvector"]
|
55 |
+
speaker_embeddings = torch.tensor(speaker_embeddings).to(device).unsqueeze(0)
|
56 |
+
|
57 |
+
|
58 |
+
# Generating Speech
|
59 |
+
text = "ڪهڙا حال آهن"
|
60 |
+
inputs = processor(text=text, return_tensors="pt").to(device)
|
61 |
+
|
62 |
+
|
63 |
+
speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
|
64 |
+
|
65 |
+
IPythonAudio(speech.cpu().numpy(), rate=16000, autoplay=True)
|
66 |
+
|
67 |
+
```
|
68 |
+
|
69 |
## Model description
|
70 |
|
71 |
More information needed
|