feat: base 修改部分模块导入方式
This commit is contained in:
parent
c8a6ced7a0
commit
66d24d51af
|
|
@ -1,4 +1,3 @@
|
||||||
from aip import AipSpeech
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
|
|
@ -17,6 +16,7 @@ def generate_voice(msg: str, per: int = 0):
|
||||||
str: 地址
|
str: 地址
|
||||||
dict: result
|
dict: result
|
||||||
"""
|
"""
|
||||||
|
from aip import AipSpeech
|
||||||
client = AipSpeech(settings.BD_SP_ID, settings.BD_SP_KEY, settings.BD_SP_SECRET)
|
client = AipSpeech(settings.BD_SP_ID, settings.BD_SP_KEY, settings.BD_SP_SECRET)
|
||||||
result = client.synthesis(msg, 'zh', 1, {'vol': 5, 'spd': 5, 'per': per})
|
result = client.synthesis(msg, 'zh', 1, {'vol': 5, 'spd': 5, 'per': per})
|
||||||
# 识别正确返回语音二进制 错误则返回dict 参照下面错误码
|
# 识别正确返回语音二进制 错误则返回dict 参照下面错误码
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import cv2
|
|
||||||
from django.http import HttpResponse
|
|
||||||
from apps.utils.errors import SIGN_MAKE_FAIL
|
from apps.utils.errors import SIGN_MAKE_FAIL
|
||||||
from server.settings import BASE_DIR
|
from server.settings import BASE_DIR
|
||||||
import numpy as np
|
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
from apps.utils.viewsets import CustomGenericViewSet
|
from apps.utils.viewsets import CustomGenericViewSet
|
||||||
from apps.utils.mixins import CustomCreateModelMixin
|
from apps.utils.mixins import CustomCreateModelMixin
|
||||||
from apps.utils.serializers import GenSignatureSerializer
|
from apps.utils.serializers import GenSignatureSerializer
|
||||||
from rest_framework.views import APIView
|
|
||||||
from rest_framework.decorators import action
|
|
||||||
from rest_framework.serializers import Serializer
|
|
||||||
from django.core.cache import cache
|
|
||||||
import json
|
|
||||||
import requests
|
|
||||||
|
|
||||||
|
|
||||||
class SignatureViewSet(CustomCreateModelMixin, CustomGenericViewSet):
|
class SignatureViewSet(CustomCreateModelMixin, CustomGenericViewSet):
|
||||||
|
|
@ -29,6 +20,8 @@ class SignatureViewSet(CustomCreateModelMixin, CustomGenericViewSet):
|
||||||
|
|
||||||
照片生成透明签名图片
|
照片生成透明签名图片
|
||||||
"""
|
"""
|
||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
path = (BASE_DIR + request.data['path']).replace('\\', '/')
|
path = (BASE_DIR + request.data['path']).replace('\\', '/')
|
||||||
try:
|
try:
|
||||||
image = cv2.imread(path, cv2.IMREAD_UNCHANGED)
|
image = cv2.imread(path, cv2.IMREAD_UNCHANGED)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue