Spaces:
Sleeping
Sleeping
Manu
commited on
Commit
·
4d1dde6
1
Parent(s):
810b795
testing tts
Browse files- .gitignore +1 -0
- app.py +27 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
*.wav
|
app.py
CHANGED
@@ -1,5 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
def greet(name):
|
4 |
return "Hello " + name + "!!"
|
5 |
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
|
4 |
+
from transformers import pipeline
|
5 |
+
|
6 |
+
from datasets import load_dataset
|
7 |
+
import soundfile as sf
|
8 |
+
import torch
|
9 |
+
import os
|
10 |
+
os.environ['TRANSFORMERS_CACHE'] = '.cache'
|
11 |
+
|
12 |
+
print ("----- setting up pipeline -----")
|
13 |
+
|
14 |
+
|
15 |
+
synthesiser = pipeline("text-to-speech", "microsoft/speecht5_tts")
|
16 |
+
|
17 |
+
print ("----- setting up dataset -----")
|
18 |
+
|
19 |
+
|
20 |
+
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
21 |
+
speaker_embedding = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
|
22 |
+
# You can replace this embedding with your own as well.
|
23 |
+
|
24 |
+
print ("----- synthetizing audio -----")
|
25 |
+
|
26 |
+
speech = synthesiser("Hello, my dog is cooler than you!", forward_params={"speaker_embeddings": speaker_embedding})
|
27 |
+
|
28 |
+
sf.write("speech.wav", speech["audio"], samplerate=speech["sampling_rate"])
|
29 |
+
|
30 |
def greet(name):
|
31 |
return "Hello " + name + "!!"
|
32 |
|