ProjetosFSI commited on
Commit
0100c5e
·
verified ·
1 Parent(s): 0930286

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -175
app.py DELETED
@@ -1,175 +0,0 @@
1
- import tempfile
2
- from typing import Optional
3
- from TTS.config import load_config
4
- import gradio as gr
5
- import numpy as np
6
- from TTS.utils.manage import ModelManager
7
- from TTS.utils.synthesizer import Synthesizer
8
-
9
- # Classe estendida para confirmar automaticamente os termos de uso
10
- class CustomModelManager(ModelManager):
11
- def ask_tos(self, output_path):
12
- print("This sentence has been generated by a speech synthesis system. tts_models/multilingual/multi-dataset/xtts_v1.1")
13
- print(" > You must confirm the following:")
14
- print(' | > "I have purchased a commercial license from Coqui: [email protected]"')
15
- print(' | > "Otherwise, I agree to the terms of the non-commercial CPML: https://coqui.ai/cpml" - [y/n]')
16
- answer = 'y' # Automaticamente aceita os termos
17
- return answer.lower() == 'y'
18
-
19
- # Substituir o gerenciador padrão pelo personalizado
20
- manager = CustomModelManager()
21
- MODELS = {}
22
- SPEAKERS = {}
23
- MAX_TXT_LEN = 100
24
-
25
- MODEL_NAMES = manager.list_tts_models()
26
-
27
- # filter out multi-speaker models and slow wavegrad vocoders
28
- filters = ["vctk", "your_tts", "ek1"]
29
- MODEL_NAMES = [model_name for model_name in MODEL_NAMES if not any(f in model_name for f in filters)]
30
-
31
- EN = [el for el in MODEL_NAMES if "/en/" in el]
32
- OTHER = [el for el in MODEL_NAMES if "/en/" not in el]
33
- EN[0], EN[5] = EN[5], EN[0]
34
- MODEL_NAMES = EN + OTHER
35
-
36
- # reorder models
37
- print(MODEL_NAMES)
38
-
39
-
40
- def tts(text: str, model_name: str):
41
- if len(text) > MAX_TXT_LEN:
42
- text = text[:MAX_TXT_LEN]
43
- print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
44
- print(text, model_name)
45
- # download model
46
- model_path, config_path, model_item = manager.download_model(model_name)
47
- vocoder_name: Optional[str] = model_item["default_vocoder"]
48
- # download vocoder
49
- vocoder_path = None
50
- vocoder_config_path = None
51
- if vocoder_name is not None:
52
- vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name)
53
- # init synthesizer
54
- synthesizer = Synthesizer(
55
- model_path, config_path, None, None, vocoder_path, vocoder_config_path,
56
- )
57
- # synthesize
58
- if synthesizer is None:
59
- raise NameError("model not found")
60
- wavs = synthesizer.tts(text, None)
61
- # return output
62
- with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
63
- synthesizer.save_wav(wavs, fp)
64
- return fp.name
65
-
66
-
67
- title = """<h1 align="center">🐸💬 CoquiTTS Playground </h1>"""
68
-
69
- with gr.Blocks(analytics_enabled=False) as demo:
70
- with gr.Row():
71
- with gr.Column():
72
- gr.Markdown(
73
- """
74
- ## <img src="https://raw.githubusercontent.com/coqui-ai/TTS/main/images/coqui-log-green-TTS.png" height="56"/>
75
- """
76
- )
77
- gr.Markdown(
78
- """
79
- <br />
80
-
81
- ## 🐸Coqui.ai News
82
- - 📣 ⓍTTS, our production TTS model that can speak 13 languages, is released [Blog Post](https://coqui.ai/blog/tts/open_xtts), [Demo](https://huggingface.co/spaces/coqui/xtts), [Docs](https://tts.readthedocs.io/en/dev/models/xtts.html)
83
- - 📣 [🐶Bark](https://github.com/suno-ai/bark) is now available for inference with unconstrained voice cloning. [Docs](https://tts.readthedocs.io/en/dev/models/bark.html)
84
- - 📣 You can use [~1100 Fairseq models](https://github.com/facebookresearch/fairseq/tree/main/examples/mms) with 🐸TTS.
85
- - 📣 🐸TTS now supports 🐢Tortoise with faster inference. [Docs](https://tts.readthedocs.io/en/dev/models/tortoise.html)
86
- - 📣 **Coqui Studio API** is landed on 🐸TTS. - [Example](https://github.com/coqui-ai/TTS/blob/dev/README.md#-python-api)
87
- - 📣 [**Coqui Studio API**](https://docs.coqui.ai/docs) is live.
88
- - 📣 Voice generation with prompts - **Prompt to Voice** - is live on [**Coqui Studio**](https://app.coqui.ai/auth/signin)!! - [Blog Post](https://coqui.ai/blog/tts/prompt-to-voice)
89
- - 📣 Voice generation with fusion - **Voice fusion** - is live on [**Coqui Studio**](https://app.coqui.ai/auth/signin).
90
- - 📣 Voice cloning is live on [**Coqui Studio**](https://app.coqui.ai/auth/signin).
91
- <br>
92
-
93
- """
94
- )
95
- with gr.Column():
96
- gr.Markdown(
97
- """
98
- <br/>
99
-
100
- 💻 This space showcases some of the **[CoquiTTS](https://github.com/coqui-ai/TTS)** models.
101
-
102
- <br/>
103
-
104
- There are > 30 languages with single and multi speaker models, all thanks to our 👑 Contributors.
105
-
106
- <br/>
107
-
108
- Visit the links below for more.
109
-
110
- | | |
111
- | ------------------------------- | --------------------------------------- |
112
- | 🐸💬 **CoquiTTS** | [Github](https://github.com/coqui-ai/TTS) |
113
- | 💼 **Documentation** | [ReadTheDocs](https://tts.readthedocs.io/en/latest/)
114
- | 👩‍💻 **Questions** | [GitHub Discussions] |
115
- | 🗯 **Community** | [![Dicord](https://img.shields.io/discord/1037326658807533628?color=%239B59B6&label=chat%20on%20discord)](https://discord.gg/5eXr5seRrv) |
116
-
117
- [github issue tracker]: https://github.com/coqui-ai/tts/issues
118
- [github discussions]: https://github.com/coqui-ai/TTS/discussions
119
- [discord]: https://discord.gg/5eXr5seRrv
120
-
121
-
122
- """
123
- )
124
-
125
- with gr.Row():
126
- gr.Markdown(
127
- """
128
- <details>
129
- <summary>👑 Model contributors</summary>
130
-
131
- - <a href="https://github.com/nmstoker/" target="_blank">@nmstoker</a>
132
- - <a href="https://github.com/kaiidams/" target="_blank">@kaiidams</a>
133
- - <a href="https://github.com/WeberJulian/" target="_blank">@WeberJulian,</a>
134
- - <a href="https://github.com/Edresson/" target="_blank">@Edresson</a>
135
- - <a href="https://github.com/thorstenMueller/" target="_blank">@thorstenMueller</a>
136
- - <a href="https://github.com/r-dh/" target="_blank">@r-dh</a>
137
- - <a href="https://github.com/kirianguiller/" target="_blank">@kirianguiller</a>
138
- - <a href="https://github.com/robinhad/" target="_blank">@robinhad</a>
139
- - <a href="https://github.com/fkarabiber/" target="_blank">@fkarabiber</a>
140
- - <a href="https://github.com/nicolalandro/" target="_blank">@nicolalandro</a>
141
- - <a href="https://github.com/a-froghyar" target="_blank">@a-froghyar</a>
142
- - <a href="https://github.com/manmay-nakhashi" target="_blank">@manmay-nakhashi</a>
143
- - <a href="https://github.com/noml4u" target="_blank">@noml4u</a>
144
- </details>
145
-
146
- <br/>
147
- """
148
- )
149
-
150
- with gr.Row():
151
- with gr.Column():
152
- input_text = gr.inputs.Textbox(
153
- label="Input Text",
154
- default="This sentence has been generated by a speech synthesis system.",
155
- )
156
- model_select = gr.inputs.Dropdown(
157
- label="Pick Model: tts_models/<language>/<dataset>/<model_name>",
158
- choices=MODEL_NAMES,
159
- default="tts_models/en/jenny/jenny"
160
- )
161
- tts_button = gr.Button("Send", elem_id="send-btn", visible=True)
162
-
163
- with gr.Column():
164
- output_audio = gr.outputs.Audio(label="Output", type="filepath")
165
-
166
- tts_button.click(
167
- tts,
168
- inputs=[
169
- input_text,
170
- model_select,
171
- ],
172
- outputs=[output_audio],
173
- )
174
-
175
- demo.queue(concurrency_count=16).launch(debug=True)