Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解决接口报错412 Client Error #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions bcut_asr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
INFILE_FMT = ["flac", "aac", "m4a", "mp3", "wav"]
OUTFILE_FMT = ["srt", "json", "lrc", "txt"]

headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
"Cache-Control": "no-cache"
}


def ffmpeg_render(media_file: str) -> bytes:
"提取视频伴音并转码为aac格式"
Expand Down Expand Up @@ -223,6 +228,7 @@ def upload(self) -> None:
"resource_file_type": self.sound_fmt,
"model_id": 7,
},
headers=headers,
)
resp.raise_for_status()
resp = resp.json()
Expand Down Expand Up @@ -251,6 +257,7 @@ def __upload_part(self) -> None:
resp = self.session.put(
self.__upload_urls[clip],
data=self.sound_bin[start_range:end_range],
headers=headers,
)
resp.raise_for_status()
etag = resp.headers.get("Etag")
Expand All @@ -268,6 +275,7 @@ def __commit_upload(self) -> None:
"upload_id": self.__upload_id,
"model_id": 7,
},
headers=headers,
)
resp.raise_for_status()
resp = resp.json()
Expand All @@ -281,7 +289,8 @@ def __commit_upload(self) -> None:
def create_task(self) -> str:
"开始创建转换任务"
resp = self.session.post(
API_CREATE_TASK, json={"resource": self.__download_url, "model_id": "7"}
API_CREATE_TASK, json={"resource": self.__download_url, "model_id": "7"},
headers=headers,
)
resp.raise_for_status()
resp = resp.json()
Expand All @@ -296,7 +305,7 @@ def create_task(self) -> str:
def result(self, task_id: Optional[str] = None) -> ResultRspSchema:
"查询转换结果"
resp = self.session.get(
API_QUERY_RESULT, params={"model_id": 7, "task_id": task_id or self.task_id}
API_QUERY_RESULT, params={"model_id": 7, "task_id": task_id or self.task_id},headers=headers,
)
resp.raise_for_status()
resp = resp.json()
Expand Down