forked from fishaudio/Bert-VITS2
-
Notifications
You must be signed in to change notification settings - Fork 137
Closed
Description
概要
件名の通りです。アップデート後に422エラーが出るようになったので原因を調査したところ、文字数制限があることがわかりました。
{"detail":[{"type":"string_too_long","loc":["query","text"],"msg":"String should have at most 100 characters","input":"\\n\xe4\xbf\xae\xe4\xba\x86\xe3\x80\x81\xe3\x81\x9d\xe3\x82\x8c\xe3\x81\xaf\xe4\xbd\x95\xe3\x81\x8b\xe3\x82\x92\xe7\xb5\x82\xe3\x81\x88\xe3\x82\x8b\xe3\x81\xa8\xe3\x81\x84\xe3\x81\x86\xe6\x84\x8f\xe5\x91\xb3\xe3\x82\x88\xe3\x81\xad\xe3\x80\x82\xe3\x81\x9d\xe3\x82\x8c\xe3\x81\x8c\xe6\x95\x99\xe8\x82\xb2\xe3\x82\x84\xe7\xa0\x94\xe7\xa9\xb6\xe3\x81\xa7\xe3\x81\x82\xe3\x82\x8c\xe3\x81\xb0\xe3\x80\x81\xe5\xa4\x9a\xe3\x81\x8f\xe3\x81\xae\xe7\x9f\xa5\xe8\xad\x98\xe3\x81\xa8\xe7\xb5\x8c\xe9\xa8\x93\xe3\x82\x92\xe5\xbe\x97\xe3\x82\x89\xe3\x82\x8c\xe3\x82\x8b\xe6\x9c\x9f\xe9\x96\x93\xe3\x82\x92\xe7\xb5\x82\xe3\x81\x88\xe3\x81\x9f\xe3\x81\x93\xe3\x81\xa8\xe3\x81\xab\xe3\x81\xaa\xe3\x82\x8b\xe3\x82\x8f\xe3\x80\x82\xe3\x81\x9d\xe3\x81\xae\xe7\xb5\x90\xe6\x9e\x9c\xe3\x81\x8c\xe3\x81\xa9\xe3\x81\x86\xe8\xa1\xa8\xe3\x82\x8c\xe3\x82\x8b\xe3\x81\x8b\xe3\x81\xaf\xe3\x80\x81\xe5\x80\x8b\xe3\x80\x85\xe3\x81\xae\xe5\x8a\xaa\xe5\x8a\x9b\xe3\x81\xa8\xe3\x81\x9d\xe3\x81\xae\xe9\x81\x8e\xe7\xa8\x8b\xe3\x81\xab\xe3\x82\x88\xe3\x82\x8b\xe3\x81\xa8\xe3\x81\x93\xe3\x82\x8d\xe3\x81\x8c\xe5\xa4\xa7\xe3\x81\x8d\xe3\x81\x84\xe3\x82\x8f\xe3\x80\x82\xe5\xa4\xa7\xe5\x88\x87\xe3\x81\xaa\xe3\x81\xae\xe3\x81\xaf\xe3\x80\x81\xe4\xbf\xae\xe4\xba\x86\xe3\x81\xa8\xe3\x81\x84\xe3\x81\x86\xe7\xaf\x80\xe7\x9b\xae\xe3\x81\x8c\xe3\x81\x8d\xe3\x81\x9f\xe3\x81\x8b\xe3\x82\x89\xe3\x81\xa8\xe3\x81\x84\xe3\x81\xa3\xe3\x81\xa6\xe5\xad\xa6\xe3\x81\xb3\xe3\x82\x92\xe7\xb5\x82\xe3\x81\x88\xe3\x82\x8b\xe3\x81\xae\xe3\x81\xa7\xe3\x81\xaf\xe3\x81\xaa\xe3\x81\x8f\xe3\x80\x81\xe5\xb8\xb8\xe3\x81\xab\xe5\xad\xa6\xe3\x81\xb3\xe7\xb6\x9a\xe3\x81\x91\xe3\x82\x8b\xe5\xa7\xbf\xe5\x8b\xa2\xe3\x82\x92\xe5\xbf\x98\xe3\x82\x8c\xe3\x81\xaa\xe3\x81\x84\xe3\x81\x93\xe3\x81\xa8\xe3\x82\x88\xe3\x80\x82\xe7\x9f\xa5\xe8\xad\x98\xe3\x81\xaf\xe7\x84\xa1\xe9\x99\x90\xe3\x81\xa7\xe3\x80\x81\xe7\xa7\x81\xe3\x81\x9f\xe3\x81\xa1\xe3\x81\xaf\xe5\xb8\xb8\xe3\x81\xab\xe6\x96\xb0\xe3\x81\x97\xe3\x81\x84\xe3\x81\x93\xe3\x81\xa8\xe3\x82\x92\xe5\xad\xa6\xe3\x81\xb3\xe3\x80\x81\xe7\x90\x86\xe8\xa7\xa3\xe3\x81\x97\xe3\x80\x81\xe6\x88\x90\xe9\x95\xb7\xe3\x81\x97\xe3\x81\xa6\xe3\x81\x84\xe3\x81\x91\xe3\x82\x8b\xe3\x81\xae\xe3\x81\xa0\xe3\x81\x8b\xe3\x82\x89\xe3\x80\x82\\n","ctx":{"max_length":100}}]}'
FastAPIのシステム的なエラーと考えて、config.ymlにあたりをつけて以下のように修正したところ、うまく動くようになりました。
# server_fastapi's config
server:
port: 5000
device: "cuda"
language: "JP"
- limit: 100
+ limit: 2000
origins:
- "*"
修正提案
- server_fastapi.pyで以下のようにLIMITをオーバーライドできないか?
- できない場合、操作方法としてマニュアルでconfig.ymlのlimitを修正するように指示できないか?
** ちょっとハマったので、CORSと同じようにlimitの修正をチェックするように指示できないか?
@app.api_route("/voice", methods=["GET", "POST"], response_class=AudioResponse)
async def voice(
request: Request,
text: str = Query(..., min_length=1, max_length=limit, description="セリフ"),
encoding: str = Query(None, description="textをURLデコードする(ex, `utf-8`)"),
(中略)
+ limit: Optional[int] = Query(DEFAULT_STRING_LIMIT, description="文字数制限"),
オーバーライドする方法はdirtyな気がするので、マニュアルの要チェック項目にしたほうがいいかもしれないです。ただ、何文字飛んでくるのか予想できないシステムを組んでいるため、とてつもながいテキストが投げられることを考えると、limitをオーバーライドできると便利な気はします。request.content["detail"][0]["type"]でエラーハンドリングするのが大変なので、適切なエラー型をthrowしてくれるとかなり助かります。
git-longcat
Metadata
Metadata
Assignees
Labels
No labels