|
@@ -2,6 +2,7 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
import json
|
|
|
import operator
|
|
|
+import os
|
|
|
import threading
|
|
|
import time
|
|
|
|
|
@@ -1772,18 +1773,23 @@ class DeviceManagement(View):
|
|
|
language = request_dict.get('language', None)
|
|
|
uid = request_dict.get('uid', None)
|
|
|
channel = request_dict.get('channel', 1)
|
|
|
- device_types = request_dict.get('deviceTypes', "")
|
|
|
+ device_types = request_dict.get('deviceTypes', None)
|
|
|
voice_file = request.FILES.get('voiceFile', None)
|
|
|
|
|
|
if not all([title, voice_type, classification, algorithm_type, status, language, voice_file]):
|
|
|
return response.json(444)
|
|
|
try:
|
|
|
- device_type_list = device_types.split(',')
|
|
|
- device_type_list = list(map(int, device_type_list))
|
|
|
+ if device_types:
|
|
|
+ device_type_list = device_types.split(',')
|
|
|
+ device_type_list = list(map(int, device_type_list))
|
|
|
+ else:
|
|
|
+ device_type_list = []
|
|
|
classification = int(classification)
|
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'ansjer-static-resources')
|
|
|
- filename = CommonService.createOrderID() + ".g711a"
|
|
|
+ file_name = voice_file.name
|
|
|
+ file_extension = os.path.splitext(file_name)[1]
|
|
|
+ filename = CommonService.createOrderID() + file_extension
|
|
|
voice_prompt_dict = {
|
|
|
"title": title,
|
|
|
"type": voice_type,
|