fix(melo-test): use subscript on spk2id (HParams has no .get)
`model.hps.data.spk2id` is a MeloTTS `HParams` instance, not a dict. It exposes `__contains__` and `__getitem__` but not `.get()`, so the previous lookup blew up at lifespan startup with `AttributeError: 'HParams' object has no attribute 'get'`. Switch to `spk["KR"] if "KR" in spk else next(iter(spk.values()))`.
This commit is contained in:
@@ -35,8 +35,10 @@ async def lifespan(_: FastAPI):
|
|||||||
device = os.environ.get("MELO_DEVICE", "auto")
|
device = os.environ.get("MELO_DEVICE", "auto")
|
||||||
model = TTS(language="KR", device=device)
|
model = TTS(language="KR", device=device)
|
||||||
spk = model.hps.data.spk2id
|
spk = model.hps.data.spk2id
|
||||||
# 한국어 모델은 보통 {"KR": 0}
|
# 한국어 모델은 보통 {"KR": 0}.
|
||||||
speaker_id = spk.get("KR", next(iter(spk.values())))
|
# spk2id 는 dict 가 아니라 MeloTTS 의 HParams 인스턴스라
|
||||||
|
# `.get()` 이 없고 `__contains__` / `__getitem__` 만 지원함.
|
||||||
|
speaker_id = spk["KR"] if "KR" in spk else next(iter(spk.values()))
|
||||||
state["model"] = model
|
state["model"] = model
|
||||||
state["speaker_id"] = speaker_id
|
state["speaker_id"] = speaker_id
|
||||||
log.info("모델 로딩 완료 (%.1fs). speakers=%s, 사용=%s",
|
log.info("모델 로딩 완료 (%.1fs). speakers=%s, 사용=%s",
|
||||||
|
|||||||
Reference in New Issue
Block a user