@Test public void testTranslate() throws WxErrorException { final String result = this.wxService.getAiOpenService().translate(AiLangType.zh_CN, AiLangType.en_US, "微信文档很坑爹"); assertThat(result).isNotEmpty(); }
@Override public String translate(AiLangType langFrom, AiLangType langTo, String content) throws WxErrorException { String response = this.wxMpService.post(String.format(TRANSLATE_URL, langFrom.getCode(), langTo.getCode()), content); WxError error = WxError.fromJson(response, WxType.MP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(response).getAsJsonObject().get("to_content").getAsString(); }
WxMpAiOpenServiceImpl implements WxMpAiOpenService { @Override public String translate(AiLangType langFrom, AiLangType langTo, String content) throws WxErrorException { String response = this.wxMpService.post(String.format(TRANSLATE_URL, langFrom.getCode(), langTo.getCode()), content); WxError error = WxError.fromJson(response, WxType.MP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(response).getAsJsonObject().get("to_content").getAsString(); } }
WxMpAiOpenServiceImpl implements WxMpAiOpenService { @Override public String translate(AiLangType langFrom, AiLangType langTo, String content) throws WxErrorException { String response = this.wxMpService.post(String.format(TRANSLATE_URL, langFrom.getCode(), langTo.getCode()), content); WxError error = WxError.fromJson(response, WxType.MP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(response).getAsJsonObject().get("to_content").getAsString(); } WxMpAiOpenServiceImpl(WxMpService wxMpService); }
WxMpAiOpenServiceImpl implements WxMpAiOpenService { @Override public String translate(AiLangType langFrom, AiLangType langTo, String content) throws WxErrorException { String response = this.wxMpService.post(String.format(TRANSLATE_URL, langFrom.getCode(), langTo.getCode()), content); WxError error = WxError.fromJson(response, WxType.MP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(response).getAsJsonObject().get("to_content").getAsString(); } WxMpAiOpenServiceImpl(WxMpService wxMpService); @Override void uploadVoice(String voiceId, AiLangType lang, File voiceFile); @Override String recogniseVoice(String voiceId, AiLangType lang, File voiceFile); @Override String translate(AiLangType langFrom, AiLangType langTo, String content); @Override String queryRecognitionResult(String voiceId, AiLangType lang); }
WxMpAiOpenServiceImpl implements WxMpAiOpenService { @Override public String translate(AiLangType langFrom, AiLangType langTo, String content) throws WxErrorException { String response = this.wxMpService.post(String.format(TRANSLATE_URL, langFrom.getCode(), langTo.getCode()), content); WxError error = WxError.fromJson(response, WxType.MP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } return JSON_PARSER.parse(response).getAsJsonObject().get("to_content").getAsString(); } WxMpAiOpenServiceImpl(WxMpService wxMpService); @Override void uploadVoice(String voiceId, AiLangType lang, File voiceFile); @Override String recogniseVoice(String voiceId, AiLangType lang, File voiceFile); @Override String translate(AiLangType langFrom, AiLangType langTo, String content); @Override String queryRecognitionResult(String voiceId, AiLangType lang);  }