Spaces:
Sleeping
Sleeping
AlimOmar commited on
Commit ·
8e06e99
1
Parent(s): 6e6ae6c
added russian
Browse files
app.py
CHANGED
|
@@ -91,8 +91,11 @@ def fix_string(batch):
|
|
| 91 |
# tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-uig-script_arabic")
|
| 92 |
# model = VitsModel.from_pretrained("piyazon/AliKurban")
|
| 93 |
# tokenizer = AutoTokenizer.from_pretrained("piyazon/AliKurban")
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
# Pydantic model for request body
|
| 98 |
class TextInput(BaseModel):
|
|
@@ -101,14 +104,21 @@ class TextInput(BaseModel):
|
|
| 101 |
"""
|
| 102 |
curl -X POST https://piyazon-tts-piyazon.hf.space/generate-tts \
|
| 103 |
-H "Content-Type: application/json" \
|
| 104 |
-
-d '{"text": "Hello, world!"}' \
|
| 105 |
--output output.wav
|
| 106 |
"""
|
| 107 |
@app.post("/generate-tts")
|
| 108 |
async def generate_tts(input: TextInput):
|
| 109 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
# Tokenize input text
|
| 111 |
-
inputs = tokenizer(fix_string(input.text), return_tensors="pt")
|
| 112 |
|
| 113 |
# Generate waveform
|
| 114 |
with torch.no_grad():
|
|
|
|
| 91 |
# tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-uig-script_arabic")
|
| 92 |
# model = VitsModel.from_pretrained("piyazon/AliKurban")
|
| 93 |
# tokenizer = AutoTokenizer.from_pretrained("piyazon/AliKurban")
|
| 94 |
+
model_ug = VitsModel.from_pretrained("piyazon/qutadgu_bilik")
|
| 95 |
+
tokenizer_ug = AutoTokenizer.from_pretrained("piyazon/qutadgu_bilik")
|
| 96 |
+
|
| 97 |
+
model_ru = VitsModel.from_pretrained("facebook/mms-tts-rus")
|
| 98 |
+
tokenizer_ru = AutoTokenizer.from_pretrained("facebook/mms-tts-rus")
|
| 99 |
|
| 100 |
# Pydantic model for request body
|
| 101 |
class TextInput(BaseModel):
|
|
|
|
| 104 |
"""
|
| 105 |
curl -X POST https://piyazon-tts-piyazon.hf.space/generate-tts \
|
| 106 |
-H "Content-Type: application/json" \
|
| 107 |
+
-d '{"text": "Hello, world!", "lang":"ug"}' \
|
| 108 |
--output output.wav
|
| 109 |
"""
|
| 110 |
@app.post("/generate-tts")
|
| 111 |
async def generate_tts(input: TextInput):
|
| 112 |
try:
|
| 113 |
+
if input.lang=="ug":
|
| 114 |
+
model = model_ug
|
| 115 |
+
tokenizer = tokenizer_ug
|
| 116 |
+
inputs = tokenizer(fix_string(input.text), return_tensors="pt")
|
| 117 |
+
else:
|
| 118 |
+
model = model_ru
|
| 119 |
+
tokenizer = tokenizer_ru
|
| 120 |
+
inputs = tokenizer(input.text, return_tensors="pt")
|
| 121 |
# Tokenize input text
|
|
|
|
| 122 |
|
| 123 |
# Generate waveform
|
| 124 |
with torch.no_grad():
|