zhangyuewww 2 years ago
parent
commit
afc2d97e90

+ 2 - 0
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/tourism/IProductManagementService.java

@@ -62,6 +62,8 @@ public interface IProductManagementService{
 	@HttpMethod(description = "识别身份证",  permissionName = "生活服务信息管理")
 	@HttpMethod(description = "识别身份证",  permissionName = "生活服务信息管理")
 	public DistinguishView personShibie(@HttpParam(name = "personImageFront", type = HttpParamType.COMMON, description = "身份证正面") String personImageFront)throws ServiceException;
 	public DistinguishView personShibie(@HttpParam(name = "personImageFront", type = HttpParamType.COMMON, description = "身份证正面") String personImageFront)throws ServiceException;
 
 
+	@HttpMethod(description = "语音识别",  permissionName = "证件管理管理")
+	public DistinguishView speechRecognition(@HttpParam(name = "voiceMessage", type = HttpParamType.COMMON, description = "语音") String voiceMessage)throws ServiceException;
 
 
 	@HttpMethod(description = "导出excl表",  permissionName = "生活服务信息管理")
 	@HttpMethod(description = "导出excl表",  permissionName = "生活服务信息管理")
 	public String export(
 	public String export(

+ 41 - 3
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/tourism/impl/ProductManagementServiceImpl.java

@@ -1,10 +1,11 @@
 package com.iotechn.unimall.admin.api.tourism.impl;
 package com.iotechn.unimall.admin.api.tourism.impl;
 
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.iotechn.unimall.data.dto.DistinguishView;
 import com.iotechn.unimall.data.dto.DistinguishView;
+import com.iotechn.unimall.data.util.HttpUtils;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponse;
 import org.apache.http.NameValuePair;
 import org.apache.http.NameValuePair;
@@ -27,7 +28,6 @@ import com.iotechn.unimall.data.mapper.ProductManagementMapper;
 import com.iotechn.unimall.data.domain.ProductManagement;
 import com.iotechn.unimall.data.domain.ProductManagement;
 import com.iotechn.unimall.admin.api.tourism.IProductManagementService;
 import com.iotechn.unimall.admin.api.tourism.IProductManagementService;
 import com.iotechn.unimall.data.model.Page;
 import com.iotechn.unimall.data.model.Page;
-import java.util.Date;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
 /**
 /**
@@ -191,6 +191,44 @@ public class ProductManagementServiceImpl implements IProductManagementService{
 		return null;
 		return null;
 	}
 	}
 
 
+	@Override
+	public DistinguishView speechRecognition(String voiceMessage) throws ServiceException {
+		String host = "https://audio.market.alicloudapi.com";
+		String path = "/audioshort";
+		String method = "POST";
+		String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
+		Map<String, String> headers = new HashMap<String, String>();
+		//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
+		headers.put("Authorization", "APPCODE " + appcode);
+		//根据API的要求,定义相对应的Content-Type
+		headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+		Map<String, String> querys = new HashMap<String, String>();
+		Map<String, String> bodys = new HashMap<String, String>();
+		bodys.put("format", "m4a");
+		bodys.put("src", voiceMessage);
+		bodys.put("type", "zh-fast");
+		try {
+			HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
+			String body = EntityUtils.toString(response.getEntity());
+			System.out.println(body);
+			JSONObject jsonObject = JSONObject.parseObject(body);
+			JSONArray jsonArray = jsonObject.getJSONArray("msg");
+			DistinguishView distinguishView = new DistinguishView();
+			if(jsonArray!= null && jsonArray.size() >0){
+				String text = jsonArray.getString(0).replace("。","");
+				distinguishView.setText(text);
+				System.out.println(text);
+			}
+			else{
+				distinguishView.setText("未识别成功!");
+			}
+			return distinguishView;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
 	@Override
 	@Override
 	public String export(Long commonId,String mainBody,String shopNames,String coverImage,String province,String city,String area,String location,String detailedAddress,String serviceDescription,String nickname,String phone,String realname,String personNo,String personImageFront,String personImageBack,String businessLicense,String status,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
 	public String export(Long commonId,String mainBody,String shopNames,String coverImage,String province,String city,String area,String location,String detailedAddress,String serviceDescription,String nickname,String phone,String realname,String personNo,String personImageFront,String personImageBack,String businessLicense,String status,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
 		Wrapper<ProductManagement> wrapper = new EntityWrapper<ProductManagement>();
 		Wrapper<ProductManagement> wrapper = new EntityWrapper<ProductManagement>();

+ 3 - 1
unimall-data/src/main/java/com/iotechn/unimall/data/domain/ProductManagement.java

@@ -131,7 +131,9 @@ public class ProductManagement extends SuperDO{
     @Excel(name = "删除标识")
     @Excel(name = "删除标识")
     @TableField("delete_flag")
     @TableField("delete_flag")
     private Long deleteFlag;
     private Long deleteFlag;
-
+    /** 语音 */
+    @TableField(exist = false)
+    private String voiceMessage;
 
 
     @Override
     @Override
     public String toString() {
     public String toString() {