Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,8 @@ from flask import Flask, request, jsonify, send_file
|
|
| 2 |
import tempfile
|
| 3 |
import logging
|
| 4 |
import json
|
| 5 |
-
|
|
|
|
| 6 |
from torch import no_grad, LongTensor
|
| 7 |
import soundfile as sf
|
| 8 |
import utils
|
|
@@ -62,7 +63,6 @@ def load_models():
|
|
| 62 |
load_models()
|
| 63 |
|
| 64 |
def get_text(text, hps, is_symbol):
|
| 65 |
-
from text import text_to_sequence
|
| 66 |
text_norm = text_to_sequence(text, hps.symbols, [] if is_symbol else hps.data.text_cleaners)
|
| 67 |
if hps.data.add_blank:
|
| 68 |
from commons import intersperse
|
|
@@ -100,6 +100,13 @@ def get_model_data(model):
|
|
| 100 |
def index():
|
| 101 |
return jsonify({"status": "OK" })
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
@app.route("/<model>/speakers", methods=["GET"])
|
| 104 |
def speakers(model):
|
| 105 |
global MODEL
|
|
|
|
| 2 |
import tempfile
|
| 3 |
import logging
|
| 4 |
import json
|
| 5 |
+
from text import text_to_sequence, _clean_text
|
| 6 |
+
|
| 7 |
from torch import no_grad, LongTensor
|
| 8 |
import soundfile as sf
|
| 9 |
import utils
|
|
|
|
| 63 |
load_models()
|
| 64 |
|
| 65 |
def get_text(text, hps, is_symbol):
|
|
|
|
| 66 |
text_norm = text_to_sequence(text, hps.symbols, [] if is_symbol else hps.data.text_cleaners)
|
| 67 |
if hps.data.add_blank:
|
| 68 |
from commons import intersperse
|
|
|
|
| 100 |
def index():
|
| 101 |
return jsonify({"status": "OK" })
|
| 102 |
|
| 103 |
+
@app.route("/tosymbol", methods=["GET", "POST"])
|
| 104 |
+
def to_symbol():
|
| 105 |
+
text = request.args.get("text") if request.method == "GET" else request.json.get("text")
|
| 106 |
+
if text is None:
|
| 107 |
+
return jsonify({ "error": "text is required"}), 400
|
| 108 |
+
return _clean_text(text)
|
| 109 |
+
|
| 110 |
@app.route("/<model>/speakers", methods=["GET"])
|
| 111 |
def speakers(model):
|
| 112 |
global MODEL
|