Spaces:
Runtime error
Runtime error
Scralius
commited on
Commit
·
3e23daa
1
Parent(s):
381bccd
Add TTS
Browse files- .gitignore +5 -0
- README.md +2 -0
- app.py +48 -5
- inference.py +1 -0
- requirements.txt +2 -1
.gitignore
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/Models/SIWIS_local
|
| 3 |
+
/__pycache__
|
| 4 |
+
*.pyc
|
| 5 |
+
/Models/SIWIS
|
README.md
CHANGED
|
@@ -8,4 +8,6 @@ sdk_version: 5.4.0
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
|
|
|
| 11 |
---
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
+
models:
|
| 12 |
+
- Scralius/StyleTTS2_SIWIS_French
|
| 13 |
---
|
app.py
CHANGED
|
@@ -1,9 +1,52 @@
|
|
| 1 |
from inference import STTS2
|
| 2 |
-
|
| 3 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
demo
|
| 9 |
-
demo.launch()
|
|
|
|
| 1 |
from inference import STTS2
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
+
from huggingface_hub import snapshot_download
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
def synthesise(text, progress=gr.Progress()):
|
| 7 |
+
if text.strip() == "":
|
| 8 |
+
raise gr.Error("Please enter some text.")
|
| 9 |
+
|
| 10 |
+
if len(text) > 300:
|
| 11 |
+
raise gr.Error("Please enter text less than 300 characters.")
|
| 12 |
+
|
| 13 |
+
audio = stts2.inference(text, ref_s, alpha=0.9, beta=0.9, diffusion_steps=16, embedding_scale=1)
|
| 14 |
|
| 15 |
+
audio = (audio * 32767).astype(np.int16)
|
| 16 |
+
|
| 17 |
+
return 24000, audio
|
| 18 |
+
|
| 19 |
+
if __name__ == '__main__':
|
| 20 |
+
snapshot_download(repo_id="Scralius/StyleTTS2_SIWIS_French", local_dir="Models/SIWIS")
|
| 21 |
+
stts2 = STTS2(config_path='Models/SIWIS_local/config.yml', model_folder='Models/SIWIS_local')
|
| 22 |
+
ref_s = stts2.compute_style('Models/SIWIS_local/reference_audio.wav')
|
| 23 |
+
|
| 24 |
+
demo = gr.Interface(
|
| 25 |
+
fn=synthesise,
|
| 26 |
+
inputs=[
|
| 27 |
+
gr.Textbox(label='Enter Text:', lines=5, max_lines=10, placeholder="Type your text here..."),
|
| 28 |
+
],
|
| 29 |
+
outputs=[
|
| 30 |
+
gr.Audio(
|
| 31 |
+
label="Generated Audio:",
|
| 32 |
+
autoplay=False,
|
| 33 |
+
streaming=False,
|
| 34 |
+
type="numpy",
|
| 35 |
+
),
|
| 36 |
+
],
|
| 37 |
+
allow_flagging='never',
|
| 38 |
+
title="French StyleTTS2 demo",
|
| 39 |
+
description=(
|
| 40 |
+
"This application uses a Text-to-Speech (TTS) model trained from scratch using StyleTTS2 on the SIWIS dataset. "
|
| 41 |
+
"Enter some text in the input box below and let the model read it out loud with a natural and expressive voice. "
|
| 42 |
+
"The model is capable of generating high-quality speech."
|
| 43 |
+
),
|
| 44 |
+
theme="origin",
|
| 45 |
+
examples=[
|
| 46 |
+
["Voici une démonstration de synthèse vocale. Ce modèle est capable de lire du texte avec une voix naturelle. Essayez d'entrer votre propre texte pour voir comment cela fonctionne."],
|
| 47 |
+
["La technologie de synthèse vocale a beaucoup évolué ces dernières années. Elle est maintenant utilisée dans de nombreux domaines, y compris les assistants virtuels, les livres audio et les systèmes de navigation."],
|
| 48 |
+
["Le modèle que nous utilisons ici a été entraîné sur le dataset SIWIS, qui contient des enregistrements de voix en français. Cela permet au modèle de générer une prononciation précise et naturelle."]
|
| 49 |
+
]
|
| 50 |
+
)
|
| 51 |
|
| 52 |
+
demo.launch()
|
|
|
inference.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import nltk
|
| 2 |
nltk.download('punkt')
|
|
|
|
| 3 |
import torch
|
| 4 |
torch.manual_seed(0)
|
| 5 |
torch.backends.cudnn.benchmark = False
|
|
|
|
| 1 |
import nltk
|
| 2 |
nltk.download('punkt')
|
| 3 |
+
nltk.download('punkt_tab')
|
| 4 |
import torch
|
| 5 |
torch.manual_seed(0)
|
| 6 |
torch.backends.cudnn.benchmark = False
|
requirements.txt
CHANGED
|
@@ -15,4 +15,5 @@ tqdm
|
|
| 15 |
typing
|
| 16 |
typing-extensions
|
| 17 |
git+https://github.com/resemble-ai/monotonic_align.git
|
| 18 |
-
phonemizer
|
|
|
|
|
|
| 15 |
typing
|
| 16 |
typing-extensions
|
| 17 |
git+https://github.com/resemble-ai/monotonic_align.git
|
| 18 |
+
phonemizer
|
| 19 |
+
cached-path
|