|
6 | 6 | import me.chanjar.weixin.mp.enums.AiLangType; |
7 | 7 |
|
8 | 8 | /** |
9 | | - * <pre> |
10 | | - * 微信AI开放接口(语音识别,微信翻译). |
11 | | - * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21516712282KzWVE |
12 | | - * Created by BinaryWang on 2018/6/9. |
13 | | - * </pre> |
| 9 | + * 微信AI开放接口(语音识别,微信翻译) |
| 10 | + * <p> |
| 11 | + * 提供微信AI相关的功能,包括语音识别、微信翻译等。 |
| 12 | + * 支持上传语音文件进行语音识别,以及文本翻译功能。 |
| 13 | + * </p> |
| 14 | + * <p> |
| 15 | + * 详情请见:<a href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21516712282KzWVE">微信AI开放接口</a> |
| 16 | + * </p> |
| 17 | + * Created by BinaryWang on 2018/6/9. |
14 | 18 | * |
15 | 19 | * @author <a href="https://github.com/binarywang">Binary Wang</a> |
16 | 20 | */ |
17 | 21 | public interface WxMpAiOpenService { |
18 | 22 |
|
19 | | - /** |
20 | | - * <pre> |
21 | | - * 提交语音. |
22 | | - * http请求方式: POST |
23 | | - * http://api.weixin.qq.com/cgi-bin/media/voice/addvoicetorecofortext?access_token=ACCESS_TOKEN&format=&voice_id=xxxxxx&lang=zh_CN |
24 | | - * </pre> |
25 | | - * |
26 | | - * @param voiceId 语音唯一标识 |
27 | | - * @param lang 语言,zh_CN 或 en_US,默认中文 |
28 | | - * @param voiceFile 语音文件 |
29 | | - * @throws WxErrorException the wx error exception |
30 | | - */ |
31 | | - void uploadVoice(String voiceId, AiLangType lang, File voiceFile) throws WxErrorException; |
| 23 | + /** |
| 24 | + * <pre> |
| 25 | + * 提交语音 |
| 26 | + * </pre> |
| 27 | + * |
| 28 | + * @param voiceId 语音唯一标识 |
| 29 | + * @param lang 语言,zh_CN 或 en_US,默认中文 |
| 30 | + * @param voiceFile 语音文件 |
| 31 | + * @throws WxErrorException 微信API调用异常,可能包括: |
| 32 | + * <ul> |
| 33 | + * <li>40001 - 获取access_token时AppSecret错误,或者access_token无效</li> |
| 34 | + * <li>40002 - 请确保grant_type字段值为client_credential</li> |
| 35 | + * <li>40003 - appid对应公众号请开发者使用绑定的公众号测试</li> |
| 36 | + * <li>40004 - appid不正确</li> |
| 37 | + * <li>40006 - access_token超时</li> |
| 38 | + * <li>48001 - api功能未授权</li> |
| 39 | + * <li>45009 - 调用接口的QPS超限</li> |
| 40 | + * <li>其他业务错误码</li> |
| 41 | + * </ul> |
| 42 | + * @see <a href="http://api.weixin.qq.com/cgi-bin/media/voice/addvoicetorecofortext">提交语音接口</a> |
| 43 | + */ |
| 44 | + void uploadVoice(String voiceId, AiLangType lang, File voiceFile) throws WxErrorException; |
32 | 45 |
|
33 | | - /** |
34 | | - * <pre> |
35 | | - * 获取语音识别结果. |
36 | | - * 接口调用请求说明 |
37 | | - * |
38 | | - * http://api.weixin.qq.com/cgi-bin/media/voice/queryrecoresultfortext?access_token=ACCESS_TOKEN&voice_id=xxxxxx&lang=zh_CN |
39 | | - * 请注意,添加完文件之后10s内调用这个接口 |
40 | | - * |
41 | | - * </pre> |
42 | | - * |
43 | | - * @param voiceId 语音唯一标识 |
44 | | - * @param lang 语言,zh_CN 或 en_US,默认中文 |
45 | | - * @return the string |
46 | | - * @throws WxErrorException the wx error exception |
47 | | - */ |
48 | | - String queryRecognitionResult(String voiceId, AiLangType lang) throws WxErrorException; |
| 46 | + /** |
| 47 | + * <pre> |
| 48 | + * 获取语音识别结果 |
| 49 | + * 请注意,添加完文件之后10s内调用这个接口 |
| 50 | + * </pre> |
| 51 | + * |
| 52 | + * @param voiceId 语音唯一标识 |
| 53 | + * @param lang 语言,zh_CN 或 en_US,默认中文 |
| 54 | + * @return 语音识别结果文本 |
| 55 | + * @throws WxErrorException 微信API调用异常,可能包括: |
| 56 | + * <ul> |
| 57 | + * <li>40001 - 获取access_token时AppSecret错误,或者access_token无效</li> |
| 58 | + * <li>40002 - 请确保grant_type字段值为client_credential</li> |
| 59 | + * <li>40003 - appid对应公众号请开发者使用绑定的公众号测试</li> |
| 60 | + * <li>40004 - appid不正确</li> |
| 61 | + * <li>40006 - access_token超时</li> |
| 62 | + * <li>48001 - api功能未授权</li> |
| 63 | + * <li>45009 - 调用接口的QPS超限</li> |
| 64 | + * <li>其他业务错误码</li> |
| 65 | + * </ul> |
| 66 | + * @see <a href="http://api.weixin.qq.com/cgi-bin/media/voice/queryrecoresultfortext">获取语音识别结果接口</a> |
| 67 | + */ |
| 68 | + String queryRecognitionResult(String voiceId, AiLangType lang) throws WxErrorException; |
49 | 69 |
|
50 | | - /** |
51 | | - * 识别指定语音文件内容. |
52 | | - * 此方法揉合了前两两个方法:uploadVoice 和 queryRecognitionResult |
53 | | - * |
54 | | - * @param voiceId 语音唯一标识 |
55 | | - * @param lang 语言,zh_CN 或 en_US,默认中文 |
56 | | - * @param voiceFile 语音文件 |
57 | | - * @return the string |
58 | | - * @throws WxErrorException the wx error exception |
59 | | - */ |
60 | | - String recogniseVoice(String voiceId, AiLangType lang, File voiceFile) throws WxErrorException; |
| 70 | + /** |
| 71 | + * <pre> |
| 72 | + * 识别指定语音文件内容 |
| 73 | + * 此方法揉合了前两两个方法:uploadVoice 和 queryRecognitionResult |
| 74 | + * </pre> |
| 75 | + * |
| 76 | + * @param voiceId 语音唯一标识 |
| 77 | + * @param lang 语言,zh_CN 或 en_US,默认中文 |
| 78 | + * @param voiceFile 语音文件 |
| 79 | + * @return 语音识别结果文本 |
| 80 | + * @throws WxErrorException 微信API调用异常,可能包括: |
| 81 | + * <ul> |
| 82 | + * <li>40001 - 获取access_token时AppSecret错误,或者access_token无效</li> |
| 83 | + * <li>40002 - 请确保grant_type字段值为client_credential</li> |
| 84 | + * <li>40003 - appid对应公众号请开发者使用绑定的公众号测试</li> |
| 85 | + * <li>40004 - appid不正确</li> |
| 86 | + * <li>40006 - access_token超时</li> |
| 87 | + * <li>48001 - api功能未授权</li> |
| 88 | + * <li>45009 - 调用接口的QPS超限</li> |
| 89 | + * <li>其他业务错误码</li> |
| 90 | + * </ul> |
| 91 | + */ |
| 92 | + String recogniseVoice(String voiceId, AiLangType lang, File voiceFile) throws WxErrorException; |
61 | 93 |
|
62 | | - /** |
63 | | - * <pre> |
64 | | - * 微信翻译. |
65 | | - * 接口调用请求说明 |
66 | | - * |
67 | | - * http请求方式: POST |
68 | | - * http://api.weixin.qq.com/cgi-bin/media/voice/translatecontent?access_token=ACCESS_TOKEN&lfrom=xxx<o=xxx |
69 | | - * |
70 | | - * </pre> |
71 | | - * |
72 | | - * @param langFrom 源语言,zh_CN 或 en_US |
73 | | - * @param langTo 目标语言,zh_CN 或 en_US |
74 | | - * @param content 要翻译的文本内容 |
75 | | - * @return the string |
76 | | - * @throws WxErrorException the wx error exception |
77 | | - */ |
78 | | - String translate(AiLangType langFrom, AiLangType langTo, String content) throws WxErrorException; |
| 94 | + /** |
| 95 | + * <pre> |
| 96 | + * 微信翻译 |
| 97 | + * </pre> |
| 98 | + * |
| 99 | + * @param langFrom 源语言,zh_CN 或 en_US |
| 100 | + * @param langTo 目标语言,zh_CN 或 en_US |
| 101 | + * @param content 要翻译的文本内容 |
| 102 | + * @return 翻译结果文本 |
| 103 | + * @throws WxErrorException 微信API调用异常,可能包括: |
| 104 | + * <ul> |
| 105 | + * <li>40001 - 获取access_token时AppSecret错误,或者access_token无效</li> |
| 106 | + * <li>40002 - 请确保grant_type字段值为client_credential</li> |
| 107 | + * <li>40003 - appid对应公众号请开发者使用绑定的公众号测试</li> |
| 108 | + * <li>40004 - appid不正确</li> |
| 109 | + * <li>40006 - access_token超时</li> |
| 110 | + * <li>48001 - api功能未授权</li> |
| 111 | + * <li>45009 - 调用接口的QPS超限</li> |
| 112 | + * <li>其他业务错误码</li> |
| 113 | + * </ul> |
| 114 | + * @see <a href="http://api.weixin.qq.com/cgi-bin/media/voice/translatecontent">微信翻译接口</a> |
| 115 | + */ |
| 116 | + String translate(AiLangType langFrom, AiLangType langTo, String content) throws WxErrorException; |
79 | 117 | } |
0 commit comments