Update runtime/python/grpc/server.py
Browse files
runtime/python/grpc/server.py
CHANGED
|
@@ -70,8 +70,8 @@ def _load_prompt_from_url(url: str, target_sr: int = 16_000) -> torch.Tensor:
|
|
| 70 |
resp.raise_for_status()
|
| 71 |
|
| 72 |
# keep the original extension so torchaudio picks the right decoder
|
| 73 |
-
ext = os.path.splitext(urllib.parse.urlparse(url).path)[1] or ".tmp"
|
| 74 |
-
with tempfile.NamedTemporaryFile(
|
| 75 |
f.write(resp.content)
|
| 76 |
tmp_path = f.name
|
| 77 |
|
|
@@ -186,11 +186,12 @@ class CosyVoiceServiceImpl(cosyvoice_pb2_grpc.CosyVoiceServicer):
|
|
| 186 |
if request.HasField("instruct_request"):
|
| 187 |
ir = request.instruct_request
|
| 188 |
|
| 189 |
-
#
|
| 190 |
-
|
| 191 |
-
|
|
|
|
| 192 |
logging.info("Received instructβ2 inference request")
|
| 193 |
-
|
| 194 |
tmp_path = None
|
| 195 |
try:
|
| 196 |
if ir.prompt_audio.startswith(b'http'):
|
|
|
|
| 70 |
resp.raise_for_status()
|
| 71 |
|
| 72 |
# keep the original extension so torchaudio picks the right decoder
|
| 73 |
+
#ext = os.path.splitext(urllib.parse.urlparse(url).path)[1] or ".tmp"
|
| 74 |
+
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f:
|
| 75 |
f.write(resp.content)
|
| 76 |
tmp_path = f.name
|
| 77 |
|
|
|
|
| 186 |
if request.HasField("instruct_request"):
|
| 187 |
ir = request.instruct_request
|
| 188 |
|
| 189 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 190 |
+
# 4βa) instructβ2 (has prompt_audio β bytes OR S3 URL)
|
| 191 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 192 |
+
if ir.HasField("prompt_audio"):
|
| 193 |
logging.info("Received instructβ2 inference request")
|
| 194 |
+
|
| 195 |
tmp_path = None
|
| 196 |
try:
|
| 197 |
if ir.prompt_audio.startswith(b'http'):
|