Spaces:
Runtime error
Runtime error
dexotify, use code however you like
#4
by
jvision
- opened
app.py
CHANGED
@@ -5,6 +5,7 @@ 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 |
|
10 |
MODELS = {}
|
@@ -33,6 +34,19 @@ def tts(text: str, model_name: str):
|
|
33 |
text = text[:MAX_TXT_LEN]
|
34 |
print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
|
35 |
print(text, model_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
# download model
|
37 |
model_path, config_path, model_item = manager.download_model(model_name)
|
38 |
vocoder_name: Optional[str] = model_item["default_vocoder"]
|
|
|
5 |
import numpy as np
|
6 |
from TTS.utils.manage import ModelManager
|
7 |
from TTS.utils.synthesizer import Synthesizer
|
8 |
+
from detoxify import Detoxify
|
9 |
|
10 |
|
11 |
MODELS = {}
|
|
|
34 |
text = text[:MAX_TXT_LEN]
|
35 |
print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
|
36 |
print(text, model_name)
|
37 |
+
# detoxify
|
38 |
+
thresholds = {
|
39 |
+
'toxicity': 0.4,
|
40 |
+
'severe_toxicity': 0.2,
|
41 |
+
'obscene': 0.3,
|
42 |
+
'threat': 0.3,
|
43 |
+
'insult': 0.3,
|
44 |
+
'identity_attack': 0.3
|
45 |
+
}
|
46 |
+
|
47 |
+
results = Detoxify('original').predict(text)
|
48 |
+
#results = Detoxify('multilingual').predict(text)
|
49 |
+
|
50 |
# download model
|
51 |
model_path, config_path, model_item = manager.download_model(model_name)
|
52 |
vocoder_name: Optional[str] = model_item["default_vocoder"]
|