Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,20 @@ enhanced_accessibility = False #@param {type:"boolean"}
|
|
| 12 |
#@markdown ---
|
| 13 |
lang = "en"
|
| 14 |
use_gpu = False #@param {type:"boolean"}
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
import json
|
| 17 |
import logging
|
| 18 |
import math
|
|
@@ -27,7 +40,7 @@ import glob
|
|
| 27 |
import ipywidgets as widgets
|
| 28 |
from IPython.display import display, Audio, Markdown, clear_output
|
| 29 |
from piper_phonemize import phonemize_codepoints, phonemize_espeak, tashkeel_run
|
| 30 |
-
|
| 31 |
_LOGGER = logging.getLogger("piper_train.infer_onnx")
|
| 32 |
import os
|
| 33 |
#if not os.path.exists("./content/piper/src/python/lng"):
|
|
@@ -75,8 +88,8 @@ def detect_onnx_models(path):
|
|
| 75 |
else:
|
| 76 |
return None
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
"""Main entry point"""
|
| 81 |
sys.path.append('./content/piper/src/python')
|
| 82 |
models_path = "./content/piper/src/python"
|
|
@@ -413,7 +426,16 @@ def transform(input_data):
|
|
| 413 |
|
| 414 |
return magnitude, phase
|
| 415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
if __name__ == "__main__":
|
|
|
|
| 417 |
import uvicorn
|
| 418 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 419 |
# main()
|
|
|
|
| 12 |
#@markdown ---
|
| 13 |
lang = "en"
|
| 14 |
use_gpu = False #@param {type:"boolean"}
|
| 15 |
+
|
| 16 |
+
from fastapi import FastAPI, HTTPException
|
| 17 |
+
from fastapi.responses import HTMLResponse
|
| 18 |
+
from starlette.requests import Request
|
| 19 |
+
from starlette.templating import Jinja2Templates
|
| 20 |
+
|
| 21 |
+
app = FastAPI()
|
| 22 |
+
templates = Jinja2Templates(directory="templates")
|
| 23 |
+
|
| 24 |
+
# Mock data for your interface
|
| 25 |
+
data = {
|
| 26 |
+
"speaker_options": ["Speaker 1", "Speaker 2", "Speaker 3"],
|
| 27 |
+
"default_speaker": "Speaker 1",
|
| 28 |
+
}
|
| 29 |
import json
|
| 30 |
import logging
|
| 31 |
import math
|
|
|
|
| 40 |
import ipywidgets as widgets
|
| 41 |
from IPython.display import display, Audio, Markdown, clear_output
|
| 42 |
from piper_phonemize import phonemize_codepoints, phonemize_espeak, tashkeel_run
|
| 43 |
+
|
| 44 |
_LOGGER = logging.getLogger("piper_train.infer_onnx")
|
| 45 |
import os
|
| 46 |
#if not os.path.exists("./content/piper/src/python/lng"):
|
|
|
|
| 88 |
else:
|
| 89 |
return None
|
| 90 |
|
| 91 |
+
|
| 92 |
+
def main():
|
| 93 |
"""Main entry point"""
|
| 94 |
sys.path.append('./content/piper/src/python')
|
| 95 |
models_path = "./content/piper/src/python"
|
|
|
|
| 426 |
|
| 427 |
return magnitude, phase
|
| 428 |
|
| 429 |
+
@app.get("/", response_class=HTMLResponse)
|
| 430 |
+
async def read_root(request: Request):
|
| 431 |
+
return templates.TemplateResponse(
|
| 432 |
+
"interface.html",
|
| 433 |
+
{"request": request, "data": data},
|
| 434 |
+
)
|
| 435 |
+
|
| 436 |
+
|
| 437 |
if __name__ == "__main__":
|
| 438 |
+
main()
|
| 439 |
import uvicorn
|
| 440 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 441 |
# main()
|