python调用阿里emo的照片说话api让照片说话代码
代码语言:python
所属分类:其他
代码描述:python调用阿里emo的照片说话api让照片说话代码
代码标签: python 调用 阿里 emo 照片 说话 api 照片 说话 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
#!/usr/local/python3/bin/python3 # -*- coding: utf-8 -* import requests import time # 检测图片获取坐标的函数 def detect_image_get_bbox(image_url, api_key, ratio="1:1"): headers = { "Content-Type": "application/json", "Authorization": api_key } data = { "model": "emo-detect-v1", "input": { "image_url": image_url }, "parameters": { "ratio": ratio } } response = requests.post( "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/face-detect", headers=headers, json=data ) if response.status_code == 200: result = response.json() if result["output"]["check_pass"]: face_bbox = result["output"]["face_bbox"] ext_bbox = result["output"]["ext_bbox"] return face_bbox, ext_bbox else: print(f"图片检测不通过,错误信息: {result['output'].get('message', '无')}") return None, None else: print(f"图片检测请求失败,状态码: {response.status_code},错误信息: {response.text}") return None, None # 提交任务的函数 def submit_task(image_url, audio_url, face_bbox, ext_bbox, api_key, style_level="normal"): headers = { "Content-Type": "application/json", "Authorization": api_key, "X-Da.........完整代码请登录后点击上方下载按钮下载查看
网友评论0