Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,7 @@ from vinorm import TTSnorm
|
|
| 17 |
# Initialize Hugging Face API
|
| 18 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 19 |
api = HfApi(token=HF_TOKEN)
|
|
|
|
| 20 |
|
| 21 |
# Download model files if not already downloaded
|
| 22 |
print("Downloading viXTTS model files if not already present...")
|
|
@@ -51,6 +52,13 @@ MODEL.load_checkpoint(
|
|
| 51 |
if torch.cuda.is_available():
|
| 52 |
MODEL.cuda()
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
# Supported languages
|
| 55 |
supported_languages = config.languages
|
| 56 |
if "vi" not in supported_languages:
|
|
@@ -194,5 +202,20 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
| 194 |
api_name="predict",
|
| 195 |
)
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
demo.queue()
|
| 198 |
demo.launch(debug=True, show_api=True)
|
|
|
|
| 17 |
# Initialize Hugging Face API
|
| 18 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 19 |
api = HfApi(token=HF_TOKEN)
|
| 20 |
+
PASSWORD = os.environ.get("KEY")
|
| 21 |
|
| 22 |
# Download model files if not already downloaded
|
| 23 |
print("Downloading viXTTS model files if not already present...")
|
|
|
|
| 52 |
if torch.cuda.is_available():
|
| 53 |
MODEL.cuda()
|
| 54 |
|
| 55 |
+
def authenticate(password):
|
| 56 |
+
if password == PASSWORD:
|
| 57 |
+
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)
|
| 58 |
+
else:
|
| 59 |
+
return gr.update(visible=False), gr.update(visible=True, value="Invalid password"), gr.update(visible=True)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
# Supported languages
|
| 63 |
supported_languages = config.languages
|
| 64 |
if "vi" not in supported_languages:
|
|
|
|
| 202 |
api_name="predict",
|
| 203 |
)
|
| 204 |
|
| 205 |
+
login_btn.click(
|
| 206 |
+
fn=authenticate,
|
| 207 |
+
inputs=password_input,
|
| 208 |
+
outputs=[main_column, error_message, login_column]
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
submit_btn.click(
|
| 212 |
+
fn=pipe,
|
| 213 |
+
inputs=[text, voice, image_in],
|
| 214 |
+
outputs=[video_o],
|
| 215 |
+
concurrency_limit=3
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
demo.queue(max_size=10).launch(show_error=True, show_api=False)
|
| 219 |
+
|
| 220 |
demo.queue()
|
| 221 |
demo.launch(debug=True, show_api=True)
|