Spaces:
Sleeping
Sleeping
File size: 966 Bytes
810b795 4d1dde6 810b795 d059ccf 810b795 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
from transformers import pipeline
from datasets import load_dataset
import soundfile as sf
import torch
import os
os.environ['TRANSFORMERS_CACHE'] = '.cache'
print ("----- setting up pipeline -----")
synthesiser = pipeline("text-to-speech", "microsoft/speecht5_tts")
print ("----- setting up dataset -----")
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
speaker_embedding = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0)
# You can replace this embedding with your own as well.
print ("----- synthetizing audio -----")
speech = synthesiser("Hello, my dog is cooler than you!", forward_params={"speaker_embeddings": speaker_embedding})
sf.write("speech.wav", speech["audio"], samplerate=speech["sampling_rate"])
def greet(name):
return "Hello " + name + "!!"
demo = gr.Interface(fn=greet, inputs="text", outputs="text", description="----- TTS Testing -----")
demo.launch()
|