kevinwang676 commited on
Commit
f660b4b
Β·
verified Β·
1 Parent(s): 985cac8

Update runtime/python/grpc/server.py

Browse files
Files changed (1) hide show
  1. runtime/python/grpc/server.py +7 -6
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(delete=False, suffix=ext) as f:
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
- # -- instruct‑2 (prompt‑audio) ------------------------------------------
190
- if ('prompt_audio' in ir.DESCRIPTOR.fields_by_name # <- descriptor guard
191
- and ir.HasField("prompt_audio")):
 
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'):