habib-z commited on
Commit
cae728b
·
1 Parent(s): deb512f

first commit clone persian tts

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -1
  2. README.md +6 -5
  3. app.py +115 -0
  4. packages.txt +2 -0
  5. requirements.txt +1 -0
.gitattributes CHANGED
@@ -25,7 +25,6 @@
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
  *.tflite filter=lfs diff=lfs merge=lfs -text
30
  *.tgz filter=lfs diff=lfs merge=lfs -text
31
  *.wasm filter=lfs diff=lfs merge=lfs -text
@@ -33,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
 
28
  *.tflite filter=lfs diff=lfs merge=lfs -text
29
  *.tgz filter=lfs diff=lfs merge=lfs -text
30
  *.wasm filter=lfs diff=lfs merge=lfs -text
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ best_model.pth filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
- title: Gradio Tts
3
- emoji:
4
- colorFrom: red
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 4.36.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Persian Tts CoquiTTS
3
+ emoji: 🚀
4
+ colorFrom: green
5
+ colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 3.15.0
8
  app_file: app.py
9
  pinned: false
10
+ license: openrail
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import tempfile ,os
3
+ from TTS.config import load_config
4
+ import gradio as gr
5
+
6
+ from TTS.utils.manage import ModelManager
7
+ from TTS.utils.synthesizer import Synthesizer
8
+
9
+ MODEL_NAMES=[
10
+ "vits male1 (best)",
11
+ "vits female (best)",
12
+ "vits-male",
13
+ "vits female1",
14
+ "glowtts-male",
15
+ "glowtts-female",
16
+ "female tacotron2"
17
+ ]
18
+ MAX_TXT_LEN = 800
19
+ model_path = os.getcwd() + "/best_model.pth"
20
+ config_path = os.getcwd() + "/config.json"
21
+
22
+
23
+
24
+ from TTS.utils.download import download_url
25
+ modelInfo=[
26
+ ["vits-male","best_model_65633.pth","config-0.json","https://huggingface.co/Kamtera/persian-tts-male-vits/resolve/main/"],
27
+ ["vits female (best)","checkpoint_48000.pth","config-2.json","https://huggingface.co/Kamtera/persian-tts-female-vits/resolve/main/"],
28
+ ["glowtts-male","best_model_77797.pth","config-1.json","https://huggingface.co/Kamtera/persian-tts-male-glow_tts/resolve/main/"],
29
+ ["glowtts-female","best_model.pth","config.json","https://huggingface.co/Kamtera/persian-tts-female-glow_tts/resolve/main/"],
30
+ ["vits male1 (best)","checkpoint_88000.pth","config.json","https://huggingface.co/Kamtera/persian-tts-male1-vits/resolve/main/"],
31
+ ["vits female1","checkpoint_50000.pth","config.json","https://huggingface.co/Kamtera/persian-tts-female1-vits/resolve/main/"],
32
+ ["female tacotron2","checkpoint_313000.pth","config-2.json","https://huggingface.co/Kamtera/persian-tts-female-tacotron2/resolve/main/"]
33
+ ]
34
+
35
+ for d in modelInfo:
36
+ directory=d[0]
37
+ if not os.path.exists(directory):
38
+ os.makedirs(directory)
39
+ print("|> Downloading: ",directory)
40
+ download_url(
41
+ d[3]+d[1],directory,"best_model.pth"
42
+ )
43
+ download_url(
44
+ d[3]+d[2],directory,"config.json"
45
+ )
46
+ def tts(text: str,model_name: str):
47
+ if len(text) > MAX_TXT_LEN:
48
+ text = text[:MAX_TXT_LEN]
49
+ print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
50
+ print(text)
51
+
52
+
53
+ # synthesize
54
+ synthesizer = Synthesizer(
55
+ model_name+"/best_model.pth", model_name+"/config.json"
56
+ )
57
+ if synthesizer is None:
58
+ raise NameError("model not found")
59
+ wavs = synthesizer.tts(text)
60
+ # return output
61
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
62
+ synthesizer.save_wav(wavs, fp)
63
+ return fp.name
64
+
65
+
66
+ description="""
67
+ This is a demo of persian text to speech model.
68
+
69
+ **Github : https://github.com/karim23657/Persian-tts-coqui **
70
+
71
+ Models can be found here: <br>
72
+
73
+ |Model|Dataset|
74
+ |----|------|
75
+ |[vits female (best)](https://huggingface.co/Kamtera/persian-tts-female-vits)|[persian-tts-dataset-famale](https://www.kaggle.com/datasets/magnoliasis/persian-tts-dataset-famale)|
76
+ |[vits male1 (best)](https://huggingface.co/Kamtera/persian-tts-male1-vits)|[persian-tts-dataset-male](https://www.kaggle.com/datasets/magnoliasis/persian-tts-dataset-male)|
77
+ |[vits female1](https://huggingface.co/Kamtera/persian-tts-female1-vits)|[ParsiGoo](https://github.com/karim23657/ParsiGoo)|
78
+ |[vits male](https://huggingface.co/Kamtera/persian-tts-male-vits)|[persian-tts-dataset](https://www.kaggle.com/datasets/magnoliasis/persian-tts-dataset)|
79
+ |[glowtts female](https://huggingface.co/Kamtera/persian-tts-female-glow_tts)|[persian-tts-dataset-famale](https://www.kaggle.com/datasets/magnoliasis/persian-tts-dataset-famale)|
80
+ |[glowtts male](https://huggingface.co/Kamtera/persian-tts-male-glow_tts)|[persian-tts-dataset](https://www.kaggle.com/datasets/magnoliasis/persian-tts-dataset)|
81
+ |[tacotron2 female](https://huggingface.co/Kamtera/persian-tts-female-tacotron2)|[persian-tts-dataset-famale](https://www.kaggle.com/datasets/magnoliasis/persian-tts-dataset-famale)|
82
+
83
+
84
+ """
85
+ article= ""
86
+ examples=[
87
+ ["و خداوند شما را با ارسال روح در جسم زندگانی و حیات بخشید","vits-male"],
88
+ ["تاجر تو چه تجارت می کنی ، تو را چه که چه تجارت می کنم؟","vits female (best)"],
89
+ ["شیش سیخ جیگر سیخی شیش هزار","vits female (best)"],
90
+ ["سه شیشه شیر ، سه سیر سرشیر","vits female (best)"],
91
+ ["دزدی دزدید ز بز دزدی بزی ، عجب دزدی که دزدید ز بز دزدی بزی","vits male1 (best)"],
92
+ ["مثنوی یکی از قالب های شعری است ک هر بیت قافیه ی جداگانه دارد","vits female1"],
93
+ ["در گلو ماند خس او سالها، چیست آن خس مهر جاه و مالها","vits male1 (best)"],
94
+ ]
95
+ iface = gr.Interface(
96
+ fn=tts,
97
+ inputs=[
98
+ gr.Textbox(
99
+ label="Text",
100
+ value="زندگی فقط یک بار است؛ از آن به خوبی استفاده کن",
101
+ ),
102
+ gr.Radio(
103
+ label="Pick a TTS Model ",
104
+ choices=MODEL_NAMES,
105
+ value="vits-female",
106
+ ),
107
+ ],
108
+ outputs=gr.Audio(label="Output",type='filepath'),
109
+ examples=examples,
110
+ title="🗣️ Persian tts 🗣️",
111
+ description=description,
112
+ article=article,
113
+ live=False
114
+ )
115
+ iface.launch(share=False)
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ libsndfile1
2
+ espeak-ng
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ git+https://github.com/coqui-ai/TTS@dev#egg=TTS