Spaces:
Runtime error
Runtime error
Commit ·
6315bf2
1
Parent(s): c929dec
Upload folder using huggingface_hub
Browse files- README.md +3 -9
- app.py +26 -0
- requirements.txt +4 -0
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: 🐢
|
| 4 |
-
colorFrom: gray
|
| 5 |
-
colorTo: green
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 3.36.1
|
| 8 |
app_file: app.py
|
| 9 |
-
|
|
|
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: text-to-speech-italian
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
app_file: app.py
|
| 4 |
+
sdk: gradio
|
| 5 |
+
sdk_version: 3.36.0
|
| 6 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from datasets import load_dataset
|
| 4 |
+
from transformers import pipeline, SpeechT5HifiGan, SpeechT5ForTextToSpeech
|
| 5 |
+
|
| 6 |
+
model_id = "Sandiago21/speecht5_finetuned_voxpopuli_it" # update with your model id
|
| 7 |
+
# pipe = pipeline("automatic-speech-recognition", model=model_id)
|
| 8 |
+
model = SpeechT5ForTextToSpeech.from_pretrained(model_id)
|
| 9 |
+
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan").cuda()
|
| 10 |
+
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
| 11 |
+
speaker_embeddings = torch.tensor(embeddings_dataset[7440]["xvector"]).unsqueeze(0)
|
| 12 |
+
|
| 13 |
+
def synthesize_speech(text):
|
| 14 |
+
inputs = processor(text=text, return_tensors="pt")
|
| 15 |
+
|
| 16 |
+
speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
|
| 17 |
+
|
| 18 |
+
return gr.Audio.update(value=(16000, speech.cpu().numpy()))
|
| 19 |
+
|
| 20 |
+
syntesize_speech_gradio = gr.Interface(
|
| 21 |
+
synthesize_speech,
|
| 22 |
+
inputs = gr.Textbox(label="Text", placeholder="Type something here..."),
|
| 23 |
+
outputs=gr.Audio(),
|
| 24 |
+
# title="Hot Dog? Or Not?",
|
| 25 |
+
).launch()
|
| 26 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|
| 3 |
+
datasets
|
| 4 |
+
|