Spaces:
Configuration error
Configuration error
add fastapi usage
Browse files
README.md
CHANGED
|
@@ -135,6 +135,8 @@ docker build -t cosyvoice:v1.0 .
|
|
| 135 |
docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/grpc && python3 server.py --port 50000 --max_conc 4 --model_dir iic/CosyVoice-300M && sleep infinity"
|
| 136 |
python3 grpc/client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
|
| 137 |
# for fastapi usage
|
|
|
|
|
|
|
| 138 |
```
|
| 139 |
|
| 140 |
## Discussion & Communication
|
|
|
|
| 135 |
docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/grpc && python3 server.py --port 50000 --max_conc 4 --model_dir iic/CosyVoice-300M && sleep infinity"
|
| 136 |
python3 grpc/client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
|
| 137 |
# for fastapi usage
|
| 138 |
+
docker run -d --runtime=nvidia -p 50000:50000 cosyvoice:v1.0 /bin/bash -c "cd /opt/CosyVoice/CosyVoice/runtime/python/fastapi && MODEL_DIR=iic/CosyVoice-300M fastapi dev --port 50000 server.py && sleep infinity"
|
| 139 |
+
python3 fastapi/client.py --port 50000 --mode <sft|zero_shot|cross_lingual|instruct>
|
| 140 |
```
|
| 141 |
|
| 142 |
## Discussion & Communication
|
runtime/python/fastapi/{fastapi_client.py → client.py}
RENAMED
|
@@ -66,7 +66,7 @@ if __name__ == "__main__":
|
|
| 66 |
default='希望你以后能够做的比我还好呦。')
|
| 67 |
parser.add_argument('--prompt_wav',
|
| 68 |
type=str,
|
| 69 |
-
default='
|
| 70 |
parser.add_argument('--instruct_text',
|
| 71 |
type=str,
|
| 72 |
default='Theo \'Crimson\', is a fiery, passionate rebel leader. Fights with fervor for justice, but struggles with impulsiveness.')
|
|
|
|
| 66 |
default='希望你以后能够做的比我还好呦。')
|
| 67 |
parser.add_argument('--prompt_wav',
|
| 68 |
type=str,
|
| 69 |
+
default='../../../zero_shot_prompt.wav')
|
| 70 |
parser.add_argument('--instruct_text',
|
| 71 |
type=str,
|
| 72 |
default='Theo \'Crimson\', is a fiery, passionate rebel leader. Fights with fervor for justice, but struggles with impulsiveness.')
|
runtime/python/fastapi/{fastapi_server.py → server.py}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
# Set inference model
|
| 2 |
# export MODEL_DIR=pretrained_models/CosyVoice-300M-Instruct
|
| 3 |
# For development
|
| 4 |
-
# fastapi dev --port 6006 fastapi_server.py
|
| 5 |
# For production deployment
|
| 6 |
-
# fastapi run --port 6006 fastapi_server.py
|
| 7 |
|
| 8 |
import os
|
| 9 |
import sys
|
|
@@ -12,8 +12,8 @@ from fastapi import FastAPI, Response, File, UploadFile, Form
|
|
| 12 |
from fastapi.responses import HTMLResponse
|
| 13 |
from contextlib import asynccontextmanager
|
| 14 |
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 15 |
-
sys.path.append('{}
|
| 16 |
-
sys.path.append('{}
|
| 17 |
from cosyvoice.cli.cosyvoice import CosyVoice
|
| 18 |
from cosyvoice.utils.file_utils import load_wav
|
| 19 |
import numpy as np
|
|
@@ -30,7 +30,7 @@ async def lifespan(app: FastAPI):
|
|
| 30 |
model_dir = os.getenv("MODEL_DIR", "pretrained_models/CosyVoice-300M-SFT")
|
| 31 |
if model_dir:
|
| 32 |
logging.info("MODEL_DIR is {}", model_dir)
|
| 33 |
-
app.cosyvoice = CosyVoice(
|
| 34 |
# sft usage
|
| 35 |
logging.info("Avaliable speakers {}", app.cosyvoice.list_avaliable_spks())
|
| 36 |
else:
|
|
|
|
| 1 |
# Set inference model
|
| 2 |
# export MODEL_DIR=pretrained_models/CosyVoice-300M-Instruct
|
| 3 |
# For development
|
| 4 |
+
# fastapi dev --port 6006 fastapi_server.py
|
| 5 |
# For production deployment
|
| 6 |
+
# fastapi run --port 6006 fastapi_server.py
|
| 7 |
|
| 8 |
import os
|
| 9 |
import sys
|
|
|
|
| 12 |
from fastapi.responses import HTMLResponse
|
| 13 |
from contextlib import asynccontextmanager
|
| 14 |
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 15 |
+
sys.path.append('{}/../../..'.format(ROOT_DIR))
|
| 16 |
+
sys.path.append('{}/../../../third_party/Matcha-TTS'.format(ROOT_DIR))
|
| 17 |
from cosyvoice.cli.cosyvoice import CosyVoice
|
| 18 |
from cosyvoice.utils.file_utils import load_wav
|
| 19 |
import numpy as np
|
|
|
|
| 30 |
model_dir = os.getenv("MODEL_DIR", "pretrained_models/CosyVoice-300M-SFT")
|
| 31 |
if model_dir:
|
| 32 |
logging.info("MODEL_DIR is {}", model_dir)
|
| 33 |
+
app.cosyvoice = CosyVoice(model_dir)
|
| 34 |
# sft usage
|
| 35 |
logging.info("Avaliable speakers {}", app.cosyvoice.list_avaliable_spks())
|
| 36 |
else:
|