Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from typing import Optional
|
|
| 9 |
|
| 10 |
torch.set_num_threads(int(os.environ.get("TORCH_THREADS", "2")))
|
| 11 |
|
| 12 |
-
SECRET = os.environ.get("TTS_SECRET_KEY", "") #
|
| 13 |
DEFAULT_VOICE = os.environ.get("VOICE", "hf_alpha") # hf_alpha, hf_beta (female) | hm_omega, hm_psi (male)
|
| 14 |
ALLOWED_VOICES = {"hf_alpha", "hf_beta", "hm_omega", "hm_psi"}
|
| 15 |
DEFAULT_SPEED = float(os.environ.get("SPEED", "1.0"))
|
|
@@ -53,7 +53,7 @@ app.add_middleware(
|
|
| 53 |
|
| 54 |
def authorized(request: Request) -> bool:
|
| 55 |
if not SECRET:
|
| 56 |
-
return
|
| 57 |
cands = [
|
| 58 |
request.headers.get("x-secret-key", ""),
|
| 59 |
request.query_params.get("key", ""),
|
|
@@ -65,7 +65,7 @@ def authorized(request: Request) -> bool:
|
|
| 65 |
|
| 66 |
|
| 67 |
def split_clean(text: str):
|
| 68 |
-
"""Text saaf karo, vakyon me todo, phir ~200 chars ke tukdon me jodo
|
| 69 |
text = re.sub(r"[\*#_`~>\[\]\{\}\(\)<>|\\/]", " ", text)
|
| 70 |
text = text.replace("\u0964", ".").replace("\u0965", ".").replace("\r", "\n")
|
| 71 |
pieces = re.split(r"(?<=[\.\?\!])\s+|\n+", text)
|
|
|
|
| 9 |
|
| 10 |
torch.set_num_threads(int(os.environ.get("TORCH_THREADS", "2")))
|
| 11 |
|
| 12 |
+
SECRET = os.environ.get("TTS_SECRET_KEY", "") # khali he to koi key nahi lagegi
|
| 13 |
DEFAULT_VOICE = os.environ.get("VOICE", "hf_alpha") # hf_alpha, hf_beta (female) | hm_omega, hm_psi (male)
|
| 14 |
ALLOWED_VOICES = {"hf_alpha", "hf_beta", "hm_omega", "hm_psi"}
|
| 15 |
DEFAULT_SPEED = float(os.environ.get("SPEED", "1.0"))
|
|
|
|
| 53 |
|
| 54 |
def authorized(request: Request) -> bool:
|
| 55 |
if not SECRET:
|
| 56 |
+
return True # koi secret set nahi he -> sab ko allow
|
| 57 |
cands = [
|
| 58 |
request.headers.get("x-secret-key", ""),
|
| 59 |
request.query_params.get("key", ""),
|
|
|
|
| 65 |
|
| 66 |
|
| 67 |
def split_clean(text: str):
|
| 68 |
+
"""Text saaf karo, vakyon me todo, phir ~200 chars ke tukdon me jodo."""
|
| 69 |
text = re.sub(r"[\*#_`~>\[\]\{\}\(\)<>|\\/]", " ", text)
|
| 70 |
text = text.replace("\u0964", ".").replace("\u0965", ".").replace("\r", "\n")
|
| 71 |
pieces = re.split(r"(?<=[\.\?\!])\s+|\n+", text)
|