├── .travis.yml
├── LICENSE
├── README.md
├── doc
├── face
│ ├── ANTI_SPOOF.md
│ ├── FACE_COMPARE.md
│ ├── FACE_DETECT.md
│ ├── FACE_STATUS.md
│ ├── FACE_VER.md
│ ├── SILENT_DETECTION.md
│ ├── TUP_API.md
│ └── WATER_MARK.md
├── nlp
│ ├── LTP.md
│ ├── SA.md
│ ├── TEXT_CHECK.md
│ ├── TRANSLATE.md
│ ├── audiocompapi.md
│ ├── imgcompapi.md
│ ├── siminterpapi.md
│ ├── textcompapi.md
│ ├── textproofreadapi.md
│ ├── textrewriteapi.md
│ ├── videocompapi.md
│ └── wordlibapi.md
├── ocr
│ ├── BANK_CARD.md
│ ├── BUSINESS_CARD.md
│ ├── FINGER_OCR.md
│ ├── GENERAL_WORDS.md
│ ├── IMAGE_REC.md
│ ├── IMAGE_WORD.md
│ ├── INTSIG_OCR.md
│ ├── ITR.md
│ ├── JD_OCR.md
│ └── PLACE.md
├── spark
│ ├── aipptv2.md
│ ├── hidreamapi.md
│ ├── imagegenapi.md
│ ├── imgunderstandapi.md
│ ├── maasapi.md
│ ├── oralapi.md
│ ├── resumegenapi.md
│ ├── sparkbatchapi.md
│ ├── sparkchat.md
│ ├── sparkcustomapi.md
│ ├── sparkiatapi.md
│ └── voiceclone.md
└── speech
│ ├── IAT.md
│ ├── IGR.md
│ ├── ISE.md
│ ├── ISE_HTTP.md
│ ├── LFASR.md
│ ├── QBH.md
│ ├── RTASR.md
│ ├── TELROBOT.md
│ └── TTS.md
├── pom.xml
├── websdk-java-core
├── pom.xml
└── src
│ └── main
│ └── java
│ └── cn
│ └── xfyun
│ ├── base
│ ├── Client.java
│ ├── http
│ │ ├── HttpBuilder.java
│ │ ├── HttpClient.java
│ │ └── platform
│ │ │ ├── PlatformBuilder.java
│ │ │ └── PlatformHttpClient.java
│ └── websocket
│ │ ├── AbstractClient.java
│ │ └── WebSocketClient.java
│ ├── config
│ ├── FaceDetectEnum.java
│ ├── LtpFunctionEnum.java
│ ├── ModeType.java
│ ├── SparkIatModelEnum.java
│ ├── TupApiEnum.java
│ ├── VoiceCloneLangEnum.java
│ └── VoiceTrainEnum.java
│ ├── exception
│ ├── BusinessException.java
│ ├── HttpException.java
│ └── LfasrException.java
│ ├── model
│ └── sign
│ │ ├── AbstractSignature.java
│ │ ├── Hmac256Signature.java
│ │ ├── LfasrSignature.java
│ │ ├── RtasrSignature.java
│ │ ├── Signature.java
│ │ ├── TextCorrectionSignature.java
│ │ ├── TranSignatrue.java
│ │ └── VoiceCloneSignature.java
│ └── util
│ ├── AuthUtil.java
│ ├── CryptTools.java
│ ├── FileUtil.java
│ ├── HttpConnector.java
│ ├── IOCloseUtil.java
│ ├── SliceIdGenerator.java
│ └── StringUtils.java
├── websdk-java-face-detector
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── cn
│ │ └── xfyun
│ │ └── api
│ │ ├── AntiSpoofClient.java
│ │ ├── FaceCompareClient.java
│ │ ├── FaceDetectClient.java
│ │ ├── FaceStatusClient.java
│ │ ├── FaceVerificationClient.java
│ │ ├── SilentDetectionClient.java
│ │ ├── TupApiClient.java
│ │ └── WatermarkVerificationClient.java
│ └── test
│ ├── java
│ ├── api
│ │ ├── AntiSpoofClientTest.java
│ │ ├── FaceCompareClientTest.java
│ │ ├── FaceDetectClientTest.java
│ │ ├── FaceStatusClientTest.java
│ │ ├── FaceVerificationClientTest.java
│ │ ├── SilentDetectionClientTest.java
│ │ ├── TupApiClientTest.java
│ │ └── WatermarkVerificationClientTest.java
│ └── config
│ │ └── PropertiesConfig.java
│ └── resources
│ ├── image
│ ├── 1.jpg
│ ├── 12.jpg
│ ├── 2.png
│ └── daiye2.jpg
│ └── test.properties
├── websdk-java-nlp
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── cn
│ │ └── xfyun
│ │ ├── api
│ │ ├── AudioComplianceClient.java
│ │ ├── ImageComplianceClient.java
│ │ ├── LtpClient.java
│ │ ├── SaClient.java
│ │ ├── SimInterpClient.java
│ │ ├── TextCheckClient.java
│ │ ├── TextComplianceClient.java
│ │ ├── TextProofreadClient.java
│ │ ├── TextRewriteClient.java
│ │ ├── TransClient.java
│ │ ├── VideoComplianceClient.java
│ │ └── WordLibClient.java
│ │ ├── config
│ │ ├── AudioFormat.java
│ │ ├── CategoryEnum.java
│ │ ├── VideoFormat.java
│ │ └── WordLibEnum.java
│ │ ├── model
│ │ ├── Audio.java
│ │ ├── Video.java
│ │ ├── compliance
│ │ │ └── text
│ │ │ │ └── TextCompParam.java
│ │ ├── simult
│ │ │ ├── request
│ │ │ │ └── SimInterpRequest.java
│ │ │ └── response
│ │ │ │ ├── Recognition.java
│ │ │ │ ├── SimInterpResponse.java
│ │ │ │ └── Streamtrans.java
│ │ ├── textproof
│ │ │ └── request
│ │ │ │ └── TextProofreadRequest.java
│ │ ├── textrewrite
│ │ │ └── TextReWriteRequest.java
│ │ └── translate
│ │ │ ├── TransParam.java
│ │ │ └── request
│ │ │ └── TransV2Request.java
│ │ └── service
│ │ ├── common
│ │ └── AbstractNlpTask.java
│ │ └── simult
│ │ ├── SimInterpSendTask.java
│ │ └── SimInterpWebSocketListener.java
│ └── test
│ ├── java
│ ├── api
│ │ ├── AudioComplianceClientTest.java
│ │ ├── ImageComplianceClientTest.java
│ │ ├── LtpClientTest.java
│ │ ├── SaClientTest.java
│ │ ├── SimInterpClientTest.java
│ │ ├── TextCheckClientTest.java
│ │ ├── TextComplianceClientTest.java
│ │ ├── TextProofreadClientTest.java
│ │ ├── TextReWriteClientTest.java
│ │ ├── TransClientTest.java
│ │ ├── VideoComplianceClientTest.java
│ │ └── WordLibClientTest.java
│ └── config
│ │ └── PropertiesConfig.java
│ └── resources
│ ├── audio
│ └── original.pcm
│ ├── image
│ └── political.png
│ └── test.properties
├── websdk-java-ocr
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── cn
│ │ └── xfyun
│ │ ├── api
│ │ ├── BankcardClient.java
│ │ ├── BusinessCardClient.java
│ │ ├── FingerOcrClient.java
│ │ ├── GeneralWordsClient.java
│ │ ├── ImageRecClient.java
│ │ ├── ImageWordClient.java
│ │ ├── IntsigOcrClient.java
│ │ ├── ItrClient.java
│ │ ├── JDOcrClient.java
│ │ └── PlaceRecClient.java
│ │ └── config
│ │ ├── IdcardEnum.java
│ │ ├── ImageRecEnum.java
│ │ ├── ImageWordEnum.java
│ │ ├── IntsigRecgEnum.java
│ │ ├── ItrEntEnum.java
│ │ ├── JDRecgEnum.java
│ │ ├── LanguageEnum.java
│ │ ├── LocationEnum.java
│ │ └── OcrWordsEnum.java
│ └── test
│ ├── java
│ ├── api
│ │ ├── BankcardClientTest.java
│ │ ├── BusinessCardClientTest.java
│ │ ├── FingerOcrClientTest.java
│ │ ├── GeneralWordsClientTest.java
│ │ ├── ImageRecClientTest.java
│ │ ├── ImageWordClientTest.java
│ │ ├── IntsigOcrClientTest.java
│ │ ├── ItrClientTest.java
│ │ ├── JDOcrClientTest.java
│ │ └── PlaceRecClientTest.java
│ └── config
│ │ └── PropertiesConfig.java
│ └── resources
│ ├── image
│ ├── 1.jpg
│ ├── backcard.jpg
│ ├── car.jpg
│ ├── finger.jpg
│ └── itr.jpg
│ └── test.properties
├── websdk-java-parent
└── pom.xml
├── websdk-java-spark
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── cn
│ │ └── xfyun
│ │ ├── api
│ │ ├── AIPPTV2Client.java
│ │ ├── HiDreamClient.java
│ │ ├── ImageGenClient.java
│ │ ├── ImageUnderstandClient.java
│ │ ├── MaasClient.java
│ │ ├── OralClient.java
│ │ ├── ResumeGenClient.java
│ │ ├── SparkBatchClient.java
│ │ ├── SparkChatClient.java
│ │ ├── SparkCustomClient.java
│ │ ├── SparkIatClient.java
│ │ ├── VoiceCloneClient.java
│ │ └── VoiceTrainClient.java
│ │ ├── config
│ │ ├── AIPPTEnum.java
│ │ ├── AgeGroupEnum.java
│ │ ├── Role.java
│ │ ├── SexEnum.java
│ │ ├── SparkBatchEnum.java
│ │ └── SparkModel.java
│ │ ├── model
│ │ ├── aippt
│ │ │ ├── request
│ │ │ │ ├── Outline.java
│ │ │ │ ├── PPTCreate.java
│ │ │ │ └── PPTSearch.java
│ │ │ └── response
│ │ │ │ ├── PPTCreateResponse.java
│ │ │ │ ├── PPTProgressResponse.java
│ │ │ │ └── PPTThemeResponse.java
│ │ ├── image
│ │ │ ├── HiDreamParam.java
│ │ │ ├── ImageGenParam.java
│ │ │ └── request
│ │ │ │ ├── ImageGenRequest.java
│ │ │ │ └── ImageHiDreamRequest.java
│ │ ├── maas
│ │ │ ├── MaasParam.java
│ │ │ ├── request
│ │ │ │ ├── MaasHttpRequest.java
│ │ │ │ └── MaasReqeust.java
│ │ │ └── response
│ │ │ │ └── MaasResponse.java
│ │ ├── oral
│ │ │ ├── request
│ │ │ │ └── OralRequest.java
│ │ │ └── response
│ │ │ │ └── OralResponse.java
│ │ ├── resume
│ │ │ └── ResumeRequest.java
│ │ ├── sparkiat
│ │ │ ├── request
│ │ │ │ └── SparkIatRequest.java
│ │ │ └── response
│ │ │ │ └── SparkIatResponse.java
│ │ ├── sparkmodel
│ │ │ ├── FileContent.java
│ │ │ ├── FunctionCall.java
│ │ │ ├── RoleContent.java
│ │ │ ├── SparkChatParam.java
│ │ │ ├── WebSearch.java
│ │ │ ├── batch
│ │ │ │ ├── BatchInfo.java
│ │ │ │ ├── BatchListResponse.java
│ │ │ │ ├── DeleteResponse.java
│ │ │ │ ├── FileInfo.java
│ │ │ │ └── FileListResponse.java
│ │ │ ├── request
│ │ │ │ ├── KnowledgeFileUpload.java
│ │ │ │ ├── SparkChatPostRequest.java
│ │ │ │ ├── SparkChatRequest.java
│ │ │ │ ├── SparkCustomRequest.java
│ │ │ │ └── SparkSendRequest.java
│ │ │ └── response
│ │ │ │ ├── ImageUnderstandResponse.java
│ │ │ │ └── SparkChatResponse.java
│ │ └── voiceclone
│ │ │ ├── request
│ │ │ ├── AudioAddParam.java
│ │ │ ├── CreateTaskParam.java
│ │ │ └── VoiceCloneRequest.java
│ │ │ └── response
│ │ │ └── VoiceCloneResponse.java
│ │ └── service
│ │ ├── common
│ │ └── AbstractTask.java
│ │ ├── maas
│ │ └── AbstractMaasWebSocketListener.java
│ │ ├── oral
│ │ └── AbstractOralWebSocketListener.java
│ │ ├── sparkiat
│ │ ├── AbstractSparkIatWebSocketListener.java
│ │ └── SparkIatSendTask.java
│ │ ├── sparkmodel
│ │ ├── AbstractImgUnderstandWebSocketListener.java
│ │ └── AbstractSparkModelWebSocketListener.java
│ │ └── voiceclone
│ │ └── AbstractVoiceCloneWebSocketListener.java
│ └── test
│ ├── java
│ ├── cn
│ │ └── xfyun
│ │ │ └── api
│ │ │ ├── AIPPTV2ClientTest.java
│ │ │ ├── HiDreamClientTest.java
│ │ │ ├── ImageGenClientTest.java
│ │ │ ├── ImageUnderstandClientTest.java
│ │ │ ├── MaasClientTest.java
│ │ │ ├── OralClientTest.java
│ │ │ ├── ResumeGenClientTest.java
│ │ │ ├── SparkBatchClientTest.java
│ │ │ ├── SparkChatClientTest.java
│ │ │ ├── SparkCustomClientTest.java
│ │ │ ├── SparkIatClientTest.java
│ │ │ ├── VoiceCloneClientTest.java
│ │ │ └── VoiceTrainClientTest.java
│ └── config
│ │ └── PropertiesConfig.java
│ └── resources
│ ├── audio
│ ├── 16k_10.pcm
│ └── 20210329145025829.mp3
│ ├── document
│ ├── aipptv2.pdf
│ ├── batch.jsonl
│ └── private.md
│ ├── image
│ ├── car.jpg
│ ├── hidream_1.jpg
│ └── hidream_2.jpg
│ └── test.properties
└── websdk-java-speech
├── pom.xml
└── src
├── main
└── java
│ └── cn
│ └── xfyun
│ ├── api
│ ├── IatClient.java
│ ├── IgrClient.java
│ ├── IseClient.java
│ ├── IseHttpClient.java
│ ├── LfasrClient.java
│ ├── QbhClient.java
│ ├── RtasrClient.java
│ ├── TelerobotClient.java
│ └── TtsClient.java
│ ├── common
│ ├── IgrConstant.java
│ └── IseConstant.java
│ ├── config
│ ├── IseAueEnum.java
│ ├── IseCategoryEnum.java
│ ├── IseLanguageEnum.java
│ ├── IseResultLevelEnum.java
│ ├── LfasrFailTypeEnum.java
│ └── LfasrOrderStatusEnum.java
│ ├── model
│ ├── request
│ │ ├── iat
│ │ │ ├── IatBusiness.java
│ │ │ ├── IatRequest.java
│ │ │ └── IatRequestData.java
│ │ ├── igr
│ │ │ └── IgrRequest.java
│ │ ├── ise
│ │ │ ├── IseBusiness.java
│ │ │ ├── IseRequest.java
│ │ │ └── IseRequestData.java
│ │ └── telerobot
│ │ │ ├── Callout.java
│ │ │ ├── TaskCreate.java
│ │ │ ├── TaskInsert.java
│ │ │ └── TaskQuery.java
│ └── response
│ │ ├── TtsResponse.java
│ │ ├── iat
│ │ ├── IatData.java
│ │ ├── IatResponse.java
│ │ ├── IatResult.java
│ │ └── Text.java
│ │ ├── igr
│ │ └── IgrResponseData.java
│ │ ├── ise
│ │ ├── IseResponse.java
│ │ └── IseResponseData.java
│ │ ├── lfasr
│ │ ├── LfasrOrderResult.java
│ │ ├── LfasrPredictResult.java
│ │ ├── LfasrResponse.java
│ │ └── LfasrTransResult.java
│ │ ├── rtasr
│ │ └── RtasrResponse.java
│ │ └── telerobot
│ │ ├── TelerobotCallout.java
│ │ ├── TelerobotCreate.java
│ │ ├── TelerobotQuery.java
│ │ ├── TelerobotResponse.java
│ │ ├── TelerobotTaskQuery.java
│ │ ├── TelerobotToken.java
│ │ └── vo
│ │ ├── Line.java
│ │ ├── Robot.java
│ │ ├── Task.java
│ │ ├── Url.java
│ │ └── Voice.java
│ └── service
│ ├── common
│ └── AbstractTimedTask.java
│ ├── iat
│ ├── AbstractIatWebSocketListener.java
│ └── IatSendTask.java
│ ├── igr
│ ├── AbstractIgrWebSocketListener.java
│ └── IgrSendTask.java
│ ├── ise
│ ├── AbstractIseWebSocketListener.java
│ └── IseSendTask.java
│ ├── lfasr
│ └── LfasrService.java
│ ├── rta
│ ├── AbstractRtasrWebSocketListener.java
│ └── RtasrSendTask.java
│ └── tts
│ └── AbstractTtsWebSocketListener.java
└── test
├── java
├── cn
│ └── xfyun
│ │ ├── api
│ │ ├── IatClientTest.java
│ │ ├── IgrClientTest.java
│ │ ├── IseClientTest.java
│ │ ├── IseHttpClientTest.java
│ │ ├── LfasrClientTest.java
│ │ ├── QbhClientTest.java
│ │ ├── RtasrClientTest.java
│ │ ├── TelerobotClientTest.java
│ │ └── TtsClientTest.java
│ │ └── service
│ │ └── IatSendTaskTest.java
└── config
│ └── PropertiesConfig.java
└── resources
├── audio
├── 16k_10.pcm
├── 20210329145025829.mp3
├── 20210330112033093.mp3
├── 20210330141636536.pcm
├── audio_qbh.wav
├── cn
│ ├── content_null.mp3
│ ├── luanshuo.mp3
│ ├── read_sentence_cn.mp3
│ ├── read_sentence_cn.pcm
│ ├── read_sentence_cn.txt
│ ├── read_sentence_cn.wav
│ ├── read_syllable_cn.pcm
│ ├── read_syllable_cn.txt
│ ├── read_word_cn.pcm
│ └── read_word_cn.txt
├── en
│ ├── free_reading_en.pcm
│ ├── free_reading_en.txt
│ ├── oral_translation_en.pcm
│ ├── oral_translation_en.txt
│ ├── picture_talk_en.pcm
│ ├── picture_talk_en.txt
│ ├── read_choice_en.pcm
│ ├── read_choice_en.txt
│ ├── read_sentence_en.pcm
│ ├── read_sentence_en.txt
│ ├── read_word_en.pcm
│ ├── read_word_en.txt
│ ├── retell_en.pcm
│ ├── retell_en.txt
│ ├── simple_expression_en.pcm
│ ├── simple_expression_en.txt
│ ├── topic_en.pcm
│ └── topic_en.txt
├── lfasr.wav
├── lfasr_max.wav
└── rtasr.pcm
└── test.properties
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | dist: trusty
3 |
4 | jdk:
5 | - oraclejdk8
6 |
7 | script:
8 | - mvn clean install
9 |
10 | after_success:
11 | - bash <(curl -s https://codecov.io/bash)
--------------------------------------------------------------------------------
/doc/face/ANTI_SPOOF.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 静默活体检测
4 |
5 | **示例代码**
6 | ```java
7 | AntiSpoofClient client = new AntiSpoofClient
8 | .Builder(appId, apiKey, apiSecret)
9 | .build();
10 | InputStream inputStream = new FileInputStream(new File(resourcePath + filePath));
11 | byte[] imageByteArray = IOUtils.readFully(inputStream, -1, true);
12 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
13 | System.out.println(client.faceContrast(imageBase64, "jpg"));
14 | ```
15 |
16 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/face/AntiSpoofClientApp.java)
17 |
18 | ##### 静默活体检测参数
19 | |参数名|类型|必传|描述|示例|
20 | |---|---|---|---|---|
21 | |imageBase64|string|是|图像base64编码|无|
22 |
23 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/face/xf-silent-in-vivo-detection/API.html)
--------------------------------------------------------------------------------
/doc/face/FACE_COMPARE.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 人脸比对
4 |
5 | **示例代码**
6 | ```java
7 | FaceCompareClient client = new FaceCompareClient
8 | .Builder(appId, apiKey, apiSecret)
9 | .build();
10 | InputStream inputStream = new FileInputStream(new File(resourcePath + filePath));
11 | byte[] imageByteArray = IOUtils.readFully(inputStream, -1, true);
12 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
13 | System.out.println(client.faceCompare(imageBase64, "jpg", imageBase64, "jpg"));
14 | ```
15 |
16 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/face/FaceCompareClientApp.java)
17 |
18 | ##### 人脸比对参数
19 | |参数名|类型|必传|描述|示例|
20 | |---|---|---|---|---|
21 | |imageBase641|string|是|第一张人脸图片base64编码|无|
22 | |encoding1|string|是|第一张人脸图片图片格式|无|
23 | |imageBase642|string|是|第二张人脸图片base64编码|无|
24 | |encoding2|string|是|第一张人脸图片图片格式|无|
25 | |encoding|string|否|返回值文本编码,可选值:utf8(默认值)|utf8|
26 | |compress|string|否|返回值文本压缩格式,可选值:raw(默认值)|raw|
27 | |format|string|否|返回值文本格式,可选值:json(默认值)|json|
28 |
29 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/face/xffaceComparisonRecg/API.html)
30 |
--------------------------------------------------------------------------------
/doc/face/FACE_DETECT.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 人脸检测和属性分析
4 |
5 | **示例代码**
6 | ```java
7 | FaceDetectClient client = new FaceDetectClient
8 | .Builder(appId, apiKey, apiSecret)
9 | .build();
10 | InputStream inputStream = new FileInputStream(new File(resourcePath + filePath));
11 | byte[] imageByteArray = IOUtils.readFully(inputStream, -1, true);
12 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
13 | System.out.println(client.faceContrast(imageBase64, "jpg"));
14 | ```
15 |
16 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/face/FaceDetectClientApp.java)
17 |
18 | ##### 人脸检测和属性分析参数
19 | |参数名|类型|必传|描述|示例|
20 | |---|---|---|---|---|
21 | |imageBase64|string|是|第一张人脸图片base64编码|无|
22 | |encoding|string|是|第一张人脸图片图片格式|jpg|
23 | |detectPoints|FaceDetectEnum|否|检测特征点开关
ON:开启
OFF:不开启|FaceDetectEnum.OFF|
24 | |detectProperty|FaceDetectEnum|否|检测人脸属性开关
ON:开启
OFF:不开启|FaceDetectEnum.OFF|
25 | |encoding|string|否|返回值文本编码,可选值:utf8(默认值)|utf8|
26 | |compress|string|否|返回值文本压缩格式,可选值:raw(默认值)|raw|
27 | |format|string|否|返回值文本格式,可选值:json(默认值)|json|
28 |
29 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/face/xf-face-detect/API.html)
30 |
--------------------------------------------------------------------------------
/doc/face/FACE_STATUS.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 配合式活体检测
4 |
5 | **示例代码**
6 | ```java
7 | FaceStatusClient client = new FaceStatusClient
8 | .Builder(appId, apiKey, apiSecret)
9 | .build();
10 | InputStream inputStream = new FileInputStream(new File(resourcePath + filePath));
11 | byte[] imageByteArray = IOUtils.readFully(inputStream, -1, true);
12 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
13 | System.out.println(client.faceContrast(imageBase64, "jpg"));
14 | ```
15 |
16 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/face/FaceStatusClientApp.java)
17 |
18 | ##### 配合式活体检测参数
19 | |参数名|类型|必传|描述|示例|
20 | |---|---|---|---|---|
21 | |imageBase64|string|是|人脸图片base64编码|无|
22 | |encoding|string|是|人脸图片图片格式|jpg|
23 | |encoding|string|否|返回值文本编码,可选值:utf8(默认值)|utf8|
24 | |compress|string|否|返回值文本压缩格式,可选值:raw(默认值)|raw|
25 | |format|string|否|返回值文本格式,可选值:json(默认值)|json|
26 |
27 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/face/xf-cooperation-living-body-detection/API.html)
28 |
--------------------------------------------------------------------------------
/doc/face/FACE_VER.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 人脸比对sensetime
4 |
5 | **示例代码**
6 | ```java
7 | FaceVerificationClient client = new FaceVerificationClient
8 | .Builder(appId, apiKey)
9 | .build();
10 | InputStream inputStream = new FileInputStream(new File(resourcePath + filePath));
11 | byte[] imageByteArray = IOUtils.readFully(inputStream, -1, true);
12 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
13 | System.out.println(client.compareFace(imageBase64, imageBase64));
14 | ```
15 |
16 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/face/FaceVerificationClientApp.java)
17 |
18 | ##### 人脸检测和属性分析参数
19 | |参数名|类型|必传|描述|示例|
20 | |---|---|---|---|---|
21 | |imageBase641|string|是|第一张人脸图片base64编码|无|
22 | |imageBase642|string|是|第二张人脸图片base64编码|无|
23 |
24 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/face/faceComparisonRecg/API.html)
25 |
--------------------------------------------------------------------------------
/doc/face/SILENT_DETECTION.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 活体检查sensetime
4 |
5 | **示例代码**
6 | ```java
7 | SilentDetectionClient client = new SilentDetectionClient
8 | .Builder(appId, apiKey)
9 | .build();
10 | System.out.println(client.silentDetection(audioBase64));
11 | ```
12 |
13 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/face/SilentDetectionClientApp.java)
14 |
15 | ##### 人脸检测和属性分析参数
16 | |参数名|类型|必传|描述|示例|
17 | |---|---|---|---|---|
18 | |audioBase64|string|是|视频base64编码|无|
19 |
20 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/face/silent-in-vivo-detection/API.html)
21 |
--------------------------------------------------------------------------------
/doc/face/TUP_API.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 人脸特征分析
4 |
5 | **示例代码**
6 | ```java
7 | TupApiClient client = new TupApiClient
8 | // 年龄 TupApiEnum.AGE
9 | // 性别 TupApiEnum.SEX
10 | // 表情 TupApiEnum.EXPRESSION
11 | // 颜值 TupApiEnum.FACE_SCORE
12 | .Builder(appId, apiKey, TupApiEnum.AGE)
13 | .build();
14 | InputStream inputStream = new FileInputStream(new File(resourcePath + filePath));
15 | byte[] bytes = IOUtils.readFully(inputStream, -1, true);
16 | System.out.println("请求地址:" + client.getHostUrl());
17 | System.out.println(client.recognition("测试", bytes));
18 | ```
19 |
20 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/face/AntiSpoofClientApp.java)
21 |
22 | ##### 人脸特征分析年龄参数
23 | |参数名|类型|必传|描述|示例|
24 | |---|---|---|---|---|
25 | |tupApiEnum|TupApiEnum|是|EXPRESSION:表情
SEX:性别
AGE:年龄
FACE_SCORE:颜值|TupApiEnum.AGE|
26 |
27 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/face/face-feature-analysis/ageAPI.html)
28 |
--------------------------------------------------------------------------------
/doc/face/WATER_MARK.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 人脸水印照比对
4 |
5 | **示例代码**
6 | ```java
7 | WatermarkVerificationClient client = new WatermarkVerificationClient
8 | .Builder(appId, apiKey)
9 | .build();
10 | byte[] imageByteArray1 = read(resourcePath + "/image/1.jpg");
11 | String imageBase641 = Base64.getEncoder().encodeToString(imageByteArray1);
12 | byte[] imageByteArray2 = read(resourcePath + "/image/2.png");
13 | String imageBase642 = Base64.getEncoder().encodeToString(imageByteArray2);
14 | System.out.println(client.compare(imageBase641, imageBase642));
15 | ```
16 |
17 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/face/WatermarkVerificationClientApp.java)
18 |
19 | ##### 人脸水印照比对参数
20 | |参数名|类型|必传|描述|示例|
21 | |---|---|---|---|---|
22 | |imageBase641|string|是|第一张人脸图片base64编码|无|
23 | |imageBase642|string|是|第二张人脸图片base64编码|无|
24 |
25 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/face/faceWaterPhotoComparisonRecg/API.html)
26 |
--------------------------------------------------------------------------------
/doc/nlp/LTP.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-自然语言处理
2 |
3 |
4 | ### 使用
5 | #### 自然语言处理
6 | ##### 示例代码
7 | ```java
8 | LtpClient ltpClient = new LtpClient
9 | .Builder(appId, apiKey, LtpFunctionEnum.NER)
10 | .build();
11 | String response = ltpClient.send("我来自北方");
12 | System.out.println(response);
13 | ```
14 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/nlp/LtpClientApp.java)
15 | ##### 合成参数
16 | |参数名|类型|必传|描述|示例|
17 | |---|---|---|---|---|
18 | |appId|string|是|讯飞开放平台应用ID|595f23df|
19 | |apiKey|string|是||af45b49cdeca84c839e9b683f8085ea3|
20 | |func|enum|是|能力标识 中文分词(cws);词性标注(pos);命名实体识别(ner);依存句法分析(dp);语义角色标注(srl);语义依存 (依存树) 分析(sdp);语义依存 (依存图) 分析(sdgp);关键词提取(ke)|ke|
21 | |text|string|是|待分析文本(中文简体),长度限制为30000字节|"我来自北方"|
22 |
23 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/nlp/dependencyParsing/API.html)
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/doc/nlp/SA.md:
--------------------------------------------------------------------------------
1 | ### 情感分析
2 |
3 | **示例代码**
4 |
5 |
6 | ```java
7 | SaClinet saClinet = new SaClinet
8 | .Builder(appId, apiKey)
9 | .build();
10 | System.out.println(saClinet.send("你好啊"));
11 | ```
12 |
13 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/nlp/SaClientApp.java)
14 |
15 | **情感分析参数**
16 |
17 | | 参数名 | 类型 | 必传 | 描述 | 示例 |
18 | | -------- | ------ | ---- | ------------------------------------------------------------ | ------- |
19 | | type | string | 是 | 服务类型,调用情感分析功能固定为dependent | dependent |
20 |
21 |
22 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/nlp/emotion-analysis/API.html)
--------------------------------------------------------------------------------
/doc/nlp/TEXT_CHECK.md:
--------------------------------------------------------------------------------
1 | ### 文本纠错
2 |
3 | **示例代码**
4 |
5 | ```java
6 | TextCheckClient client = new TextCheckClient
7 | .Builder(appId, apiSecret, apiKey)
8 | .build();
9 | String result = client.send("画蛇天足");
10 | System.out.println("返回结果: " + result);
11 | ```
12 |
13 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/nlp/TextCheckClientApp.java)
14 | **文本纠错参数**
15 |
16 | | 参数名 | 类型 | 必传 | 描述 | 示例 |
17 | | -------- | ------ | ---- | ------------------------------------------------------------ | ------- |
18 | | header.app_id | string| 是| 在平台申请的appid信息| app_id|
19 | | header.status | string| 是| 请求状态,取值范围为:3(一次传完)|3|
20 | | parameter.s9a87e3ec.result.encoding |string| 否| 文本编码,可选值:utf8(默认值)|utf8|
21 | | parameter.s9a87e3ec.result.compress |string| 否| 文本压缩格式,可选值:raw(默认值)|raw|
22 | | parameter.s9a87e3ec.result.format | string| 否| 文本格式,可选值:json(默认值)|json|
23 | | payload.input|object| 是| 用于上传文本数据|画蛇天足|
24 | | payload.input.encoding| string| 否| 文本编码,可选值:utf8(默认值)|utf8|
25 | | payload.input.compress| string| 否| 文本压缩格式,可选值:raw(默认值)|raw|
26 | | payload.input.encoding| string| 否| 文本格式,可选值:json(默认值)|json|
27 | | payload.input.text| string| 是| 文本数据,base64编码,最大支持7000字节,请注意中文要控制在2000个字符|5aSq6Ziz5b2T56m654Wn77yM6Iqx5YS/5a+|
28 | | payload.input.status| int|否| 上传数据状态,取值范围为:3(一次传完)|3|
29 |
30 |
31 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/nlp/textCorrection/API.html)
32 |
--------------------------------------------------------------------------------
/doc/ocr/BANK_CARD.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 银行卡识别
4 |
5 | **示例代码**
6 | ```java
7 | BankcardClient client = new BankcardClient
8 | .Builder(appId, apiKey)
9 | .build();
10 | byte[] imageByteArray = read(resourcePath + "/image/backcard.jpg");
11 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
12 | System.out.println(client.bankcard(imageBase64));
13 | ```
14 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/BankcardClientApp.java)
15 | ##### 银行卡识别参数
16 | |参数名|类型|必传|描述|示例|
17 | |---|---|---|---|---|
18 | |cardNumberImage|string|否|是否返回卡号区域截图。
0:不返回(默认值)
1:则返回base64编码的卡号区域截图|cardNumberImage="0"|
19 |
20 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/words/bankCardRecg/API.html)
--------------------------------------------------------------------------------
/doc/ocr/BUSINESS_CARD.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 名片识别
4 |
5 | **示例代码**
6 | ```java
7 | BusinessCard client = new BusinessCard
8 | .Builder(appId, apiKey)
9 | .build();
10 | byte[] imageByteArray = read(resourcePath + "/image/1.jpg");
11 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
12 | System.out.println(client.businessCard(imageBase64));
13 | ```
14 |
15 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/BusinessCardApp.java)
16 |
17 | ##### 名片识别参数
18 | |参数名|类型|必传|描述|示例|
19 | |---|---|---|---|---|
20 | |picRequired|string|否|是否返回切边增强图像。
0:不返回(默认值)
1:返回的json结果中切边增强图片数据格式详见返回值说明|picRequired="0"|
21 |
22 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/words/businessCardRecg/API.html)
--------------------------------------------------------------------------------
/doc/ocr/FINGER_OCR.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 指尖文字识别
4 |
5 | **示例代码**
6 | ```java
7 | FingerOcrClient client = new FingerOcrClient
8 | .Builder(appId, apiKey, apiSecret)
9 | .build();
10 | byte[] imageByteArray = read(resourcePath + "/image/finger.jpg");
11 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
12 | System.out.println(client.fingerOcr(imageBase64));
13 | ```
14 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/FingerOcrClientApp.java)
15 |
16 | ##### 指尖文字识别参数
17 | |参数名|类型|必传|描述|示例|
18 | |---|---|---|---|---|
19 | |cutWScale|float|否|根据指尖位置选取ROI(感兴趣区域)的宽度倍数。即设置ROI的宽度是手指宽度的几倍(宽度= cut_w_scale * 手指宽度),默认3.0,取值范围:[0,65536]|cutWScale=5f|
20 | |cutHScale|float|否|根据指尖位置选取ROI(感兴趣区域)的高度倍数。即设置ROI的高度是手指宽度的几倍(高度= cut_h_scale * 手指宽度),默认2.0,取值范围:[0,65536]|cutHScale=2f|
21 | |cutShift|float|否|根据指尖位置选取ROI(感兴趣区域)的往下平移的倍数。即设置ROI往下平移的距离是ROI宽度的几倍(平移量= cut_shift * 手指宽度),默认0.3,取值范围:[0,1]|cutShift=0.1f|
22 | |resizeW|int|否|引擎内部处理模块输入图像宽度,取值范围:[1,65536]。若应用端上传图像宽为input_w,scale为缩放系数,则resize_w=input_w*scale。若不缩放直接按原图处理,引擎耗时会变长,建议根据实际情况测试以寻求最佳值。|resizeW=1000|
23 | |resizeH|int|否|引擎内部处理模块输入图像高度,取值范围:[1,65536]。若应用端上传图像高为input_h,scale为缩放系数,则resize_h=input_h*scale。若不缩放直接按原图处理,引擎耗时会变长,建议根据实际情况测试以寻求最佳值。|resizeH=1000|
24 |
25 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/words/formula-discern/API.html)
--------------------------------------------------------------------------------
/doc/ocr/GENERAL_WORDS.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 印刷文字识别和手写文字识别
4 |
5 | **示例代码**
6 | ```java
7 | GeneralWordsClient client = new GeneralWordsClient
8 | .Builder(appId, apiKey, OcrWordsEnum.HANDWRITING)
9 | .build();
10 | InputStream inputStream = new FileInputStream(new File(resourcePath + "/image/1.jpg"));
11 | byte[] imageByteArray = IOUtils.readFully(inputStream, -1, true);
12 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
13 | System.out.println(client.generalWords(imageBase64));
14 | ```
15 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/GeneralWordsClientApp.java)
16 |
17 | ##### 识别参数
18 | |参数名|类型|必传|描述|示例|
19 | |---|---|---|---|---|
20 | |ocrTypeEnum|OcrWordsEnum|是|文字识别类别。取值PRINT(印刷文字识别)HANDWRITING(手写文字识别)|OcrWordsEnum.HANDWRITING|
21 | |language|LanguageEnum|否|识别语言。EN(英文)或者CN(中英文混合)|LanguageEnum.CN|
22 | |location|LocationEnum|否|返回文本位置信息。ON返回或者OFF不返回|LocationEnum.ON|
23 |
24 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/words/wordRecg/API.html)
25 |
--------------------------------------------------------------------------------
/doc/ocr/IMAGE_REC.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 场景识别和物体识别
4 |
5 | **示例代码**
6 | ```java
7 | ImageRecClient client = new ImageRecClient
8 | .Builder(appId, apiKey, ImageRecEnum.SCENE)
9 | .build();
10 | byte[] imageByteArray = read(resourcePath + "/image/car.jpg");
11 | System.out.println(client.send( "测试", imageByteArray));
12 | ```
13 |
14 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/ImageRecClientApp.java)
15 |
16 | ##### 图片类识别参数
17 | |参数名|类型|必传|描述|示例|
18 | |---|---|---|---|---|
19 | |imageRecEnum|ImageRecEnum|是|识别类别。
SCENE:场景识别
CURRENCY:物体识别 | ImageRecEnum.SCENE|
20 |
21 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/image/scene-recg/API.html)
22 |
--------------------------------------------------------------------------------
/doc/ocr/IMAGE_WORD.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 图片类识别(营业执照,出租车发票,火车票,增值税发票 ,身份证,印刷文字)
4 |
5 | **示例代码**
6 | ```java
7 | ImageWordClient client = new ImageWordClient
8 | .Builder(appId, apiKey, apiSecret, ImageWordEnum.IDCARD)
9 | .build();
10 | InputStream inputStream = new FileInputStream(new File(resourcePath + "/image/car.jpg"));
11 | byte[] imageByteArray = IOUtils.readFully(inputStream, -1, true);
12 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
13 | System.out.println(client.imageWord(imageBase64, "jpg"));
14 | ```
15 |
16 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/ImageWordClientApp.java)
17 |
18 | ##### 图片类识别参数
19 | |参数名|类型|必传|描述|示例|
20 | |---|---|---|---|---|
21 | |imageWordEnum|ImageWordEnum|是|识别类别。
BUSINESS_LICENSE:营业执照识别
TAXI_INVOICE:出租车发票识别
TRAIN_TICKET:火车票识别
INVOICE:增值税发票识别
IDCARD:身份证识别
PRINTED_WORD:多语种文字识别|ImageWordEnum.PRINTED_WORD|
22 |
23 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/words/id_card/API.html)
24 |
--------------------------------------------------------------------------------
/doc/ocr/INTSIG_OCR.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 身份证识别 营业执照识别 增值税发票识别 印刷文字识别(多语种)
4 |
5 | **示例代码**
6 | ```java
7 | IntsigOcrClient client = new IntsigOcrClient
8 | .Builder(appId, apiKey, IntsigRecgEnum.IDCARD)
9 | .build();
10 | InputStream inputStream = new FileInputStream(new File(resourcePath + "/image/car.jpg"));
11 | byte[] imageByteArray = IOUtils.readFully(inputStream, -1, true);
12 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
13 | System.out.println(client.intsigRecg(imageBase64));
14 | ```
15 |
16 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/IntsigOcrClientApp.java)
17 |
18 | ##### 识别参数
19 | |参数名|类型|必传|描述|示例|
20 | |---|---|---|---|---|
21 | |intsigRecgEnum|IntsigRecgEnum|是|识别类型。
IDCARD:身份证识别
BUSINESS_LICENSE:营业执照识别
INVOICE:增值税发票识别
RECOGNIZE_DOCUMENT:印刷文字识别(多语种)|IntsigRecgEnum.IDCARD|
22 |
23 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/words/printed-word-recognition/API.html)
24 |
--------------------------------------------------------------------------------
/doc/ocr/ITR.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 拍照速算识别 公式识别
4 |
5 | **示例代码**
6 | ```java
7 | ItrClient client = new ItrClient
8 | .Builder(appId, apiKey, apiSecret, ItrEntEnum.MATH_ARITH)
9 | .build();
10 | byte[] imageByteArray = read(resourcePath + "/image/itr.jpg");
11 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
12 | System.out.println(client.itr(imageBase64));
13 | ```
14 |
15 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/ItrClientApp.java)
16 |
17 | ##### 识别参数
18 | |参数名|类型|必传|描述|示例|
19 | |---|---|---|---|---|
20 | |itrEntEnum|ItrEntEnum|是|识别类型。
MATH_ARITH:拍照速算识别
TEACH_PHOTO_PRINT:公式识别|ItrEntEnum.TEACH_PHOTO_PRINT|
21 |
22 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/words/photo-calculate-recg/API.html)
--------------------------------------------------------------------------------
/doc/ocr/JD_OCR.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 行驶证识别 驾驶证识别 车牌识别
4 |
5 | **示例代码**
6 | ```java
7 | JDOcrClient client = new JDOcrClient
8 | .Builder(appId, apiKey, apiSecret, JDRecgEnum.JD_OCR_CAR)
9 | .build();
10 | byte[] imageByteArray = read(resourcePath + "/image/car.jpg");
11 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
12 | System.out.println(client.handle(imageBase64, "jpg"));
13 | ```
14 |
15 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/JDOcrClientApp.java)
16 |
17 | ##### 识别参数
18 | |参数名|类型|必传|描述|示例|
19 | |---|---|---|---|---|
20 | |jDRecgEnum|JDRecgEnum|是|识别类型。
JD_OCR_VEHICLE:行驶证识别
JD_OCR_DRIVER:驾驶证识别
JD_OCR_CAR:车牌识别|JDRecgEnum.JD_OCR_VEHICLE|
21 |
22 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/words/vehicleRecg/API.html)
--------------------------------------------------------------------------------
/doc/ocr/PLACE.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 |
3 | ### 场所识别
4 |
5 | **示例代码**
6 | ```java
7 | PlaceRecClient client = new PlaceRecClient
8 | .Builder(appId, apiKey, apiSecret)
9 | .build();
10 | InputStream inputStream = new FileInputStream(new File(resourcePath + filePath));
11 | byte[] imageByteArray = IOUtils.readFully(inputStream, -1, true);
12 | String imageBase64 = Base64.getEncoder().encodeToString(imageByteArray);
13 | System.out.println(client.send(imageBase64, "jpg"));
14 | ```
15 |
16 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/ocr/PlaceRecClientApp.java)
17 |
18 | ##### 名片识别参数
19 | |参数名|类型|必传|描述|示例|
20 | |---|---|---|---|---|
21 | |imageBase64|String|是|图片的base64编码|无|
22 | |type|String|是|图片的格式|"jpg"|
23 |
24 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/image/place-recg/API.html)
25 |
--------------------------------------------------------------------------------
/doc/speech/IGR.md:
--------------------------------------------------------------------------------
1 | ### 性别年龄识别
2 |
3 | **示例代码**
4 |
5 | ```java
6 | import cn.xfyun.api.IgrClient;
7 |
8 | // 设置性别年龄识别参数,这里的appid,apiKey,apiSecret是在开放平台控制台获得
9 | IgrClient igrClient = new IgrClient.Builder()
10 | //... 这里可以继续设置评测相关参数,参数见下面表格
11 | .build();
12 |
13 | File file = new File(filePath);
14 | igrClient.send(file, new AbstractIgrWebSocketListener() {
15 | @Override
16 | public void onSuccess(WebSocket webSocket, IgrResponseData igrResponseData) {
17 | // 根据服务端成功响应,进行数据处理,处理方法可见demo
18 | }
19 |
20 | @Override
21 | public void onFail(WebSocket webSocket, Throwable t, Response response) {
22 | // 根据业务需求,对失败时的数据进行处理
23 | }
24 | });
25 |
26 | ```
27 |
28 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/speech/IgrClientApp.java)
29 |
30 | **评测参数**
31 |
32 | | 参数名 | 类型 | 必传 | 描述
33 | | -------- | ------ | ---- | ------------------------------------------------------------
34 | | ent | string | 是 | 引擎类型,目前仅支持igr |
35 | | aue | string | 是 | 音频格式
raw:原生音频数据pcm格式
speex:speex格式(rate需设置为8000)
speex-wb:宽频speex格式(rate需设置为16000)
amr:amr格式(rate需设置为8000)
amr-wb:宽频amr格式(rate需设置为16000)|
36 | |rate |int |是| 音频采样率 16000/8000|
37 |
38 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/voiceservice/sound-feature-recg/API.html)
--------------------------------------------------------------------------------
/doc/speech/ISE_HTTP.md:
--------------------------------------------------------------------------------
1 | ### 语音评测(普通版)
2 |
3 | **示例代码**
4 |
5 | ```java
6 | IseHttpClient client = new IseHttpClient
7 | .Builder(appId, apiKey, IseAueEnum.RAW, IseLanguageEnum.ZH_CN, IseCategoryEnum.READ_SENTENCE)
8 | //... 这里可以继续设置评测相关参数,参数见下面表格
9 | .build();
10 |
11 | // 进行数据处理,处理方法可见demo
12 | String result = client.send(new File(filePath));
13 |
14 | ```
15 |
16 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/speech/IseHttpClientApp.java)
17 |
18 | **评测参数**
19 |
20 | | 参数名 | 类型 | 必传 | 说明 | 示例 |
21 | | -------- | ------ | ---- | ------------------------------------------------------------ | ------- |
22 | | aue | string | 是 | 音频编码
raw(未压缩的 pcm 格式音频)
speex(标准开源speex) | raw |
23 | | speex_size | string | 否 | 标准speex解码帧的大小
当aue=speex时,若传此参数,表明音频格式为标准speex | 70 |
24 | |result_level|string| 否 |评测结果等级
entirety(默认值)
simple | entirety
25 | | language | string | 是 | 评测语种
en_us(英语)
zh_cn(汉语)| zh_cn |
26 | | category | string | 是 | 评测题型
read_syllable(单字朗读,汉语专有)
read_word(词语朗读)
read_sentence(句子朗读)
read_chapter(篇章朗读) | read_sentence |
27 | | extra_ability | string | 否 | 拓展能力
multi_dimension(全维度 ) | multi_dimension |
28 |
29 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/voiceservice/ise/API.html)
--------------------------------------------------------------------------------
/doc/speech/QBH.md:
--------------------------------------------------------------------------------
1 | ### 歌曲识别
2 |
3 | **示例代码**
4 |
5 | ```java
6 | QbhClient qbhClient = new QbhClient.Builder(appId,apiKey)
7 | //... 这里可以继续设置评测相关参数,参数见下面表格
8 | .build();
9 |
10 | // 进行数据处理,处理方法可见demo
11 | String result = qbhClient.send();
12 |
13 | ```
14 |
15 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/speech/QbhClientApp.java)
16 |
17 | **评测参数**
18 |
19 | | 参数名 | 类型 | 必传 | 说明 | 示例 |
20 | | -------- | ------ | ---- | ------------------------------------------------------------ | ------- |
21 | | engine_type | string | 是 | 引擎类型,可选值:afs(哼唱) | afs |
22 | | aue | string | 否 | 音频编码,可选值:raw(pcm、wav格式)、aac,默认raw | raw |
23 | |sample_rate|string| 否 | 采样率,可选值:8000、16000,默认16000,aue是aac,sample_rate必须是8000 | 8000 |
24 | | audio_url | string | 否 | 哼唱音频存放地址url | |
25 |
26 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/voiceservice/song-recognition/API.html)
27 |
--------------------------------------------------------------------------------
/doc/speech/RTASR.md:
--------------------------------------------------------------------------------
1 | # 讯飞开放平台AI能力-JAVASDK语音能力库
2 | #### 实时语音转写
3 | ##### 示例代码
4 | ```java
5 | //使用仅创建一个webSocket连接,需要用户自己处理分段 和 发送结束标识。否则服务端返回的结果不完善
6 |
7 | // step1: 创建 rtasrClient
8 | RtasrClient rtasrClient = new RtasrClient.Builder().signature("xxxxx", "xxxxxxxxx").build();
9 |
10 | CountDownLatch latch = new CountDownLatch(1);
11 |
12 | // setp2: 建立 websocket连接
13 | WebSocket webSocket = rtasrClient.newWebSocket(new AbstractRtasrWebSocketListener() {
14 | @Override
15 | public void onSuccess(WebSocket webSocket, String text) {
16 | // step4 : 接受服务端返回信息
17 | System.out.println(text);
18 | }
19 |
20 | @Override
21 | public void onFail(WebSocket webSocket, Throwable t, @Nullable Response response) {
22 | latch.countDown();
23 | }
24 |
25 | @Override
26 | public void onBusinessFail(WebSocket webSocket, String text) {
27 | System.out.println(text);
28 | latch.countDown();
29 | }
30 |
31 | @Override
32 | public void onClosed() {
33 | latch.countDown();
34 | }
35 | });
36 |
37 | try {
38 | byte[] bytes = new byte[1280];
39 | File file = new File(resourcePath + filePath);
40 | RandomAccessFile raf = new RandomAccessFile(file, "r");
41 | int len = -1;
42 | long lastTs = 0;
43 | while ((len = raf.read(bytes)) != -1) {
44 | if (len < 1280) {
45 | bytes = Arrays.copyOfRange(bytes, 0, len);
46 | webSocket.send(ByteString.of(bytes));
47 | break;
48 | }
49 |
50 | long curTs = System.currentTimeMillis();
51 | if (lastTs == 0) {
52 | lastTs = System.currentTimeMillis();
53 | } else {
54 | long s = curTs - lastTs;
55 | if (s < 40) {
56 | System.out.println("error time interval: " + s + " ms");
57 | }
58 | }
59 |
60 | // setp3: 发送数据
61 | webSocket.send(ByteString.of(bytes));
62 |
63 | // 每隔40毫秒发送一次数据
64 | Thread.sleep(40);
65 | }
66 |
67 | // step5: 发送结束标识
68 | rtasrClient.sendEnd();
69 | } catch (Exception e) {
70 | e.printStackTrace();
71 | }
72 | latch.await();
73 | ```
74 | 更详细请参见[Demo](https://github.com/iFLYTEK-OP/websdk-java-demo/blob/main/src/main/java/cn/xfyun/demo/speech/RtasrClientApp.java)
75 | ##### 实时语音转写参数
76 | |参数名|类型|必传|描述|示例|
77 | |---|---|---|---|---|
78 | |punc|string|否|标点过滤控制,默认返回标点。
0:返回标点(默认值)
1:不返回标点|punc="0"|
79 | |pd|string|否|垂直领域个性化参数:
法院: court
教育: edu
金融:finance
医疗:medical
科技: tech|设置示例:pd="edu"
参数pd为非必须设置,不设置参数默认为通用|
80 |
81 | *注:详细的参数可以参见[业务参数](https://www.xfyun.cn/doc/asr/rtasr/API.html)
82 |
--------------------------------------------------------------------------------
/websdk-java-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 | websdk-java-core
7 | jar
8 | ${websdk-java-core.version}
9 |
10 | websdk-java-parent
11 | cn.xfyun
12 | 2.1.2
13 | ../websdk-java-parent/pom.xml
14 |
15 |
16 |
17 |
18 |
19 | org.apache.maven.plugins
20 | maven-compiler-plugin
21 |
22 | 8
23 | 8
24 | UTF-8
25 |
26 |
27 |
28 | org.apache.maven.plugins
29 | maven-surefire-plugin
30 | 2.19.1
31 |
32 | true
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | com.squareup.okhttp3
41 | okhttp
42 | 3.14.2
43 |
44 |
45 |
46 | org.apache.httpcomponents
47 | httpclient
48 | 4.5.11
49 | compile
50 |
51 |
52 | org.apache.httpcomponents
53 | httpmime
54 | 4.5.11
55 | compile
56 |
57 |
58 | com.google.guava
59 | guava
60 | 22.0
61 | compile
62 |
63 |
64 | commons-codec
65 | commons-codec
66 | 1.13
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/base/Client.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.base;
2 |
3 |
4 | /**
5 | * @author
6 | * @description client父类
7 | * @date 2021/6/15
8 | */
9 | public class Client {
10 |
11 | protected String hostUrl;
12 |
13 | protected String appId;
14 |
15 | protected String apiKey;
16 |
17 | protected String apiSecret;
18 |
19 |
20 | public String getHostUrl() {
21 | return hostUrl;
22 | }
23 |
24 | public String getAppId() {
25 | return appId;
26 | }
27 |
28 | public String getApiKey() {
29 | return apiKey;
30 | }
31 |
32 | public String getApiSecret() {
33 | return apiSecret;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/base/http/platform/PlatformBuilder.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.base.http.platform;
2 |
3 |
4 | import cn.xfyun.base.http.HttpBuilder;
5 |
6 | /**
7 | * @author mqgao
8 | * @version 1.0
9 | * @date 2021/7/2 15:48
10 | */
11 | public abstract class PlatformBuilder extends HttpBuilder {
12 |
13 | private String serviceId;
14 |
15 | private int status = 3;
16 |
17 | private String encoding = "utf8";
18 |
19 | private String compress = "raw";
20 |
21 | private String format = "json";
22 |
23 |
24 | public String getServiceId() {
25 | return serviceId;
26 | }
27 |
28 | protected T serviceId(String serviceId) {
29 | this.serviceId = serviceId;
30 | return (T)this;
31 | }
32 |
33 | public int getStatus() {
34 | return status;
35 | }
36 |
37 | public T status(int status) {
38 | this.status = status;
39 | return (T)this;
40 | }
41 |
42 | public String getEncoding() {
43 | return encoding;
44 | }
45 |
46 | public T encoding(String encoding) {
47 | this.encoding = encoding;
48 | return (T)this;
49 | }
50 |
51 | public String getCompress() {
52 | return compress;
53 | }
54 |
55 | public T compress(String compress) {
56 | this.compress = compress;
57 | return (T)this;
58 | }
59 |
60 | public String getFormat() {
61 | return format;
62 | }
63 |
64 | public T format(String format) {
65 | this.format = format;
66 | return (T)this;
67 | }
68 |
69 | public PlatformBuilder(String hostUrl, String serviceId, String appId, String apiKey, String apiSecret) {
70 | super(hostUrl, appId, apiKey, apiSecret);
71 | this.serviceId = serviceId;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/base/http/platform/PlatformHttpClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.base.http.platform;
2 |
3 |
4 | import cn.xfyun.base.http.HttpClient;
5 | import com.google.gson.JsonObject;
6 |
7 | /**
8 | * 自研能力使用
9 | *
10 | * @author mqgao
11 | * @version 1.0
12 | * @date 2021/7/2 15:04
13 | */
14 | public abstract class PlatformHttpClient extends HttpClient {
15 |
16 | /**
17 | * 服务引擎ID
18 | */
19 | protected String serviceId;
20 |
21 | /**
22 | * 请求状态,取值范围为:3(一次传完)
23 | */
24 | protected int status;
25 |
26 | /**
27 | * 文本编码,可选值:utf8(默认值
28 | */
29 | protected String encoding;
30 |
31 | /**
32 | * 文本压缩格式,可选值:raw(默认值)
33 | */
34 | protected String compress;
35 |
36 | /**
37 | * 文本格式,可选值:json(默认值)
38 | */
39 | protected String format;
40 |
41 |
42 | public PlatformHttpClient(PlatformBuilder builder) {
43 | super(builder);
44 | this.serviceId = builder.getServiceId();
45 | this.status = builder.getStatus();
46 | this.encoding = builder.getEncoding();
47 | this.compress = builder.getCompress();
48 | this.format = builder.getFormat();
49 | }
50 |
51 | public String getServiceId() {
52 | return serviceId;
53 | }
54 |
55 | public int getStatus() {
56 | return status;
57 | }
58 |
59 | public String getEncoding() {
60 | return encoding;
61 | }
62 |
63 | public String getCompress() {
64 | return compress;
65 | }
66 |
67 | public String getFormat() {
68 | return format;
69 | }
70 |
71 | protected JsonObject buildHeader() {
72 | JsonObject header = new JsonObject();
73 | header.addProperty("app_id", appId);
74 | header.addProperty("status", status);
75 | return header;
76 | }
77 |
78 | protected JsonObject buildResult() {
79 | JsonObject faceCompareResult = new JsonObject();
80 | faceCompareResult.addProperty("encoding", encoding);
81 | faceCompareResult.addProperty("format", format);
82 | faceCompareResult.addProperty("compress", compress);
83 | return faceCompareResult;
84 | }
85 |
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/base/websocket/WebSocketClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.base.websocket;
2 |
3 | import cn.xfyun.base.Client;
4 | import cn.xfyun.model.sign.AbstractSignature;
5 | import cn.xfyun.model.sign.Hmac256Signature;
6 | import cn.xfyun.util.AuthUtil;
7 | import okhttp3.OkHttpClient;
8 | import okhttp3.Request;
9 | import okhttp3.WebSocket;
10 | import okhttp3.WebSocketListener;
11 |
12 | import java.net.MalformedURLException;
13 | import java.security.SignatureException;
14 |
15 | /**
16 | * @author
17 | * @description websocket能力的客户端
18 | * @date 2021/4/7
19 | */
20 | public abstract class WebSocketClient extends Client {
21 |
22 | protected String originHostUrl;
23 |
24 | protected AbstractSignature signature;
25 |
26 | /**
27 | * websocket相关配置
28 | */
29 | protected Request request;
30 |
31 | protected OkHttpClient okHttpClient;
32 |
33 | protected WebSocket webSocket;
34 |
35 |
36 | /**
37 | * webSocket超时时间相关
38 | */
39 | protected boolean retryOnConnectionFailure;
40 | protected int callTimeout;
41 | protected int connectTimeout;
42 | protected int readTimeout;
43 | protected int writeTimeout;
44 | protected int pingInterval;
45 |
46 | public WebSocket getWebSocket() {
47 | return webSocket;
48 | }
49 |
50 | /**
51 | * 生成鉴权对象,并建立websocket连接
52 | *
53 | * @return
54 | * @throws MalformedURLException
55 | * @throws SignatureException
56 | */
57 | protected void createWebSocketConnect(WebSocketListener webSocketListener) throws MalformedURLException, SignatureException {
58 | this.signature = new Hmac256Signature(apiKey, apiSecret, originHostUrl);
59 | String url = AuthUtil.generateRequestUrl(signature);
60 | this.hostUrl = url.replace("http://", "ws://").replace("https://", "wss://");
61 | this.request = new Request.Builder().url(this.hostUrl).build();
62 |
63 | // 创建websocket连接
64 | newWebSocket(webSocketListener);
65 | }
66 |
67 | /**
68 | * 为语音听写client新建webSocket
69 | *
70 | * @param listener
71 | * @return
72 | */
73 | protected void newWebSocket(WebSocketListener listener) {
74 | this.webSocket = okHttpClient.newWebSocket(request, listener);
75 | }
76 |
77 | /**
78 | * 关闭websocket连接
79 | */
80 | public void closeWebsocket() {
81 | this.webSocket.close(1000, null);
82 | okHttpClient.connectionPool().evictAll();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/config/FaceDetectEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/6 11:05
7 | */
8 | public enum FaceDetectEnum {
9 |
10 | ON("1"),
11 | OFF("0");
12 |
13 | private String value;
14 |
15 | FaceDetectEnum(String value) {
16 | this.value = value;
17 | }
18 |
19 | public String getValue() {
20 | return value;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/config/LtpFunctionEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/5 18:36
7 | */
8 | public enum LtpFunctionEnum {
9 |
10 | CWS("cws"),
11 | NER("ner"),
12 | DP("dp"),
13 | SRL("srl"),
14 | SDP("sdp"),
15 | SDGP("sdgp"),
16 | KE("ke"),
17 | POS("pos");
18 |
19 | private String value;
20 |
21 | LtpFunctionEnum(String value) {
22 | this.value = value;
23 | }
24 |
25 | public String getValue() {
26 | return value;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/config/ModeType.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 请求类型模式分类
5 | *
6 | * @author
7 | **/
8 | public enum ModeType {
9 |
10 | //代表本地图片base64的模式
11 | BASE64("base64"),
12 |
13 | //代表url外链的图片地址模式
14 | LINK("link");
15 |
16 | private final String value;
17 |
18 | ModeType(String value) {
19 | this.value = value;
20 | }
21 |
22 | public String getValue() {
23 | return value;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/config/SparkIatModelEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 转写大模型类型枚举类
5 | *
6 | * @author zyding6
7 | **/
8 | public enum SparkIatModelEnum {
9 |
10 | /**
11 | * 中文大模型
12 | */
13 | ZH_CN_MANDARIN(1, "中文大模型"),
14 | /**
15 | * 方言大模型
16 | */
17 | ZH_CN_MULACC(2, "方言大模型"),
18 | /**
19 | * 多语种大模型
20 | */
21 | MUL_CN_MANDARIN(3, "多语种大模型");
22 |
23 | private final Integer code;
24 | private final String desc;
25 |
26 | public Integer getCode() {
27 | return code;
28 | }
29 |
30 | public String getDesc() {
31 | return desc;
32 | }
33 |
34 | SparkIatModelEnum(Integer code, String desc) {
35 | this.code = code;
36 | this.desc = desc;
37 | }
38 |
39 | public boolean codeEquals(final Integer code) {
40 | return this.code.equals(code);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/config/TupApiEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/6 11:57
7 | */
8 | public enum TupApiEnum {
9 |
10 | AGE("age"),
11 | SEX("sex"),
12 | EXPRESSION("expression"),
13 | FACE_SCORE("face_score");
14 |
15 | private String value;
16 |
17 | TupApiEnum(String value) {
18 | this.value = value;
19 | }
20 |
21 | public String getValue() {
22 | return value;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/config/VoiceCloneLangEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 一句话复刻语种枚举类
5 | *
6 | * @author zyding6
7 | **/
8 | public enum VoiceCloneLangEnum {
9 |
10 | CN("中", 0),
11 | EN("英", 1),
12 | JA("日", 2),
13 | KO("韩", 3),
14 | ES("俄", 4);
15 |
16 | private final Integer code;
17 |
18 | private final String desc;
19 |
20 | VoiceCloneLangEnum(String desc, Integer code) {
21 | this.code = code;
22 | this.desc = desc;
23 | }
24 |
25 | public Integer code() {
26 | return code;
27 | }
28 |
29 | public String desc() {
30 | return desc;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/config/VoiceTrainEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 一句话训练枚举类
5 | *
6 | * @author zyding6
7 | **/
8 | public enum VoiceTrainEnum {
9 |
10 | TOKEN("http://avatar-hci.xfyousheng.com/aiauth/v1/token", "一句话复刻获取token"),
11 | TRAIN_TEXT("http://opentrain.xfyousheng.com/voice_train/task/traintext", "获取训练文本"),
12 | TASK_ADD("http://opentrain.xfyousheng.com/voice_train/task/add", "创建音色训练任务"),
13 | AUDIO_ADD("http://opentrain.xfyousheng.com/voice_train/audio/v1/add", "向训练任务添加音频(url链接)"),
14 | TASK_SUBMIT("http://opentrain.xfyousheng.com/voice_train/task/submit", "音色训练任务提交训练(异步)"),
15 | AUDIO_SUBMIT("http://opentrain.xfyousheng.com/voice_train/task/submitWithAudio", "向训练任务添加音频(本地文件)并提交训练任务"),
16 | TASK_RESULT("http://opentrain.xfyousheng.com/voice_train/task/result", "根据任务id查询音色训练任务的状态");
17 |
18 | private final String url;
19 | private final String desc;
20 |
21 | VoiceTrainEnum(String url, String desc) {
22 | this.url = url;
23 | this.desc = desc;
24 | }
25 |
26 | public String getUrl() {
27 | return url;
28 | }
29 |
30 | public String getDesc() {
31 | return desc;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/exception/BusinessException.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.exception;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/5 16:09
7 | */
8 | public class BusinessException extends RuntimeException{
9 |
10 | public BusinessException(String msg) {
11 | super(msg);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/exception/HttpException.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.exception;
2 |
3 | /**
4 | * http自定义异常
5 | *
6 | * @author : iflytek
7 | * @date : 2021年03月15日
8 | */
9 | public class HttpException extends Exception {
10 | private String errorCode;
11 |
12 | private String errorMsg;
13 |
14 | public HttpException(String errorCode, String errorMsg) {
15 | super(errorMsg);
16 | this.errorCode = errorCode;
17 | this.errorMsg = errorMsg;
18 | }
19 |
20 | public HttpException(String errorMsg) {
21 | super(errorMsg);
22 | this.errorMsg = errorMsg;
23 | }
24 |
25 | public HttpException(String message, Throwable cause) {
26 | super(message, cause);
27 | this.errorMsg = message;
28 | }
29 |
30 | public String getErrorCode() {
31 | return errorCode;
32 | }
33 |
34 | public void setErrorCode(String errorCode) {
35 | this.errorCode = errorCode;
36 | }
37 |
38 | public String getErrorMsg() {
39 | return errorMsg;
40 | }
41 |
42 | public void setErrorMsg(String errorMsg) {
43 | this.errorMsg = errorMsg;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/exception/LfasrException.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.exception;
2 |
3 | /**
4 | * 语音转写业务自定义异常
5 | *
6 | * @author : iflytek
7 | * @date : 2021年03月15日
8 | */
9 | public class LfasrException extends RuntimeException {
10 | public LfasrException(String error) {
11 | super(error);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/model/sign/LfasrSignature.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sign;
2 |
3 | import cn.xfyun.util.CryptTools;
4 | import cn.xfyun.util.StringUtils;
5 |
6 | import java.security.NoSuchAlgorithmException;
7 | import java.security.SignatureException;
8 |
9 | /**
10 | * Lfasr能力签名实体
11 | *
12 | * @author : jun
13 | * @date : 2021年03月29日
14 | */
15 | public class LfasrSignature extends AbstractSignature {
16 |
17 | /**
18 | *
19 | * @param appId
20 | * @param keySecret
21 | */
22 | public LfasrSignature(String appId, String keySecret) {
23 | super(appId, keySecret, null);
24 | }
25 |
26 | @Override
27 | public String getSigna() throws SignatureException {
28 | if (StringUtils.isNullOrEmpty(this.signa)) {
29 | this.setOriginSign(generateOriginSign());
30 | this.signa = generateSignature();
31 | }
32 | return this.signa;
33 | }
34 |
35 | /**
36 | * 生成最终的签名,需要先生成原始sign
37 | *
38 | * @throws SignatureException
39 | */
40 | public String generateSignature() throws SignatureException {
41 | return CryptTools.hmacEncrypt(CryptTools.HMAC_SHA1, this.getOriginSign(), this.getKey());
42 | }
43 |
44 | /**
45 | * 生成待加密原始字符
46 | *
47 | * @throws NoSuchAlgorithmException
48 | */
49 | @Override
50 | public String generateOriginSign() throws SignatureException {
51 | return CryptTools.md5Encrypt(this.getId() + this.getTs());
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/model/sign/RtasrSignature.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sign;
2 |
3 |
4 | import cn.xfyun.util.CryptTools;
5 |
6 | import java.net.URLEncoder;
7 |
8 | /**
9 | * @author mqgao
10 | * @version 1.0
11 | * @date 2021/4/8 15:37
12 | */
13 | public class RtasrSignature extends AbstractSignature{
14 |
15 |
16 | public RtasrSignature(String id, String key) {
17 | super(id, key, null);
18 | }
19 |
20 | @Override
21 | public String getSigna() {
22 | String id = getId();
23 | String key = getKey();
24 | String ts = getTs();
25 | try {
26 | signa = CryptTools.hmacEncrypt(CryptTools.HMAC_SHA1, CryptTools.md5Encrypt(id + ts), key);
27 | return "?appid=" + id + "&ts=" + ts + "&signa=" + URLEncoder.encode(signa, "UTF-8");
28 | } catch (Exception e) {
29 | e.printStackTrace();
30 | }
31 |
32 | return "";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/model/sign/TextCorrectionSignature.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sign;
2 |
3 |
4 | import java.net.MalformedURLException;
5 | import java.net.URL;
6 | import java.security.SignatureException;
7 |
8 | /**
9 | * @author mqgao
10 | * @version 1.0
11 | * @date 2021/6/10 11:23
12 | */
13 | public class TextCorrectionSignature extends Hmac256Signature{
14 |
15 |
16 | /**
17 | * 构造函数
18 | *
19 | * @param apiKey
20 | * @param secretKey
21 | * @param hostUrl
22 | */
23 | public TextCorrectionSignature(String apiKey, String secretKey, String hostUrl) {
24 | super(apiKey, secretKey, hostUrl);
25 | }
26 |
27 | /**
28 | * 生成待加密原始字符
29 | * 规则如下:
30 | * host: iat-api.xfyun.cn
31 | * date: Wed, 10 Jul 2019 07:35:43 GMT
32 | * GET /v2/iat HTTP/1.1
33 | *
34 | * @throws SignatureException
35 | */
36 | @Override
37 | public String generateOriginSign() throws SignatureException {
38 | try {
39 | URL url = new URL(this.getUrl());
40 |
41 | return "host: " + url.getHost() + "\n" +
42 | "date: " + this.getTs() + "\n" +
43 | "POST " + url.getPath() + " HTTP/1.1";
44 | } catch (MalformedURLException e) {
45 | throw new SignatureException("MalformedURLException:" + e.getMessage());
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/model/sign/TranSignatrue.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sign;
2 |
3 | import cn.xfyun.util.CryptTools;
4 | import org.apache.commons.codec.digest.DigestUtils;
5 |
6 | import java.net.MalformedURLException;
7 | import java.net.URL;
8 | import java.security.SignatureException;
9 |
10 | /**
11 | * @author
12 | * @description 小牛翻译及自研机器翻译鉴权
13 | * @date 2021/6/15
14 | */
15 | public class TranSignatrue extends Hmac256Signature {
16 |
17 | private String httpBody;
18 |
19 | public TranSignatrue(String apiKey, String secretKey, String hostUrl, boolean isPost) {
20 | super(apiKey, secretKey, hostUrl, isPost);
21 | }
22 |
23 | /**
24 | * 生成待加密原始字符
25 | * 规则如下:
26 | * host: iat-api.xfyun.cn
27 | * date: Wed, 10 Jul 2019 07:35:43 GMT
28 | * GET /v2/iat HTTP/1.1
29 | *
30 | * @throws SignatureException
31 | */
32 | @Override
33 | public String generateOriginSign() throws SignatureException {
34 | try {
35 | URL url = new URL(this.getUrl());
36 |
37 | String digestBase64 = "SHA-256=" + CryptTools.base64Encode(DigestUtils.sha256Hex(httpBody));
38 | StringBuilder builder = new StringBuilder("host: ").append(url.getHost()).append("\n")
39 | .append("date: ").append(this.getTs()).append("\n")
40 | .append(requestMethod).append(" ").append(url.getPath()).append(" HTTP/1.1").append("\n")
41 | .append("digest: ").append(digestBase64);
42 |
43 | return builder.toString();
44 | } catch (MalformedURLException e) {
45 | throw new SignatureException("MalformedURLException:" + e.getMessage());
46 | }
47 | }
48 |
49 | public TranSignatrue setHttpBody(String httpBody) {
50 | this.httpBody = httpBody;
51 | return this;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/model/sign/VoiceCloneSignature.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sign;
2 |
3 | import cn.xfyun.util.CryptTools;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | import java.util.HashMap;
8 | import java.util.Map;
9 |
10 | /**
11 | * 一句话复刻鉴权工具类
12 | *
13 | * @author zyding
14 | */
15 | public class VoiceCloneSignature {
16 |
17 | private static final Logger logger = LoggerFactory.getLogger(VoiceCloneSignature.class);
18 |
19 | /**
20 | * 一句话复刻获取token头
21 | *
22 | * @param apiKey 应用的key
23 | * @param timestamp 时间戳
24 | * @param body 请求体
25 | * @return header 请求头
26 | */
27 | public static Map tokenSign(String apiKey, String timestamp, String body) {
28 | try {
29 | Map header = new HashMap<>(6);
30 | String builder = CryptTools.md5Encrypt(apiKey + timestamp) + body;
31 | String authorization = CryptTools.md5Encrypt(builder);
32 | header.put("Authorization", authorization);
33 | header.put("Content-Type", "application/json");
34 | return header;
35 | } catch (Exception e) {
36 | logger.error("生成token头失败", e);
37 | }
38 | return null;
39 | }
40 |
41 | /**
42 | * 一句话复刻通用加密
43 | *
44 | * @param appId 应用ID
45 | * @param apiKey 应用的key
46 | * @param body 请求体
47 | * @return header 请求头
48 | */
49 | public static Map commonSign(String appId, String apiKey, String body, String token) {
50 | try {
51 | String timestamp = String.valueOf(System.currentTimeMillis());
52 | String builder = apiKey + timestamp + CryptTools.md5Encrypt(body);
53 | String authorization = CryptTools.md5Encrypt(builder);
54 |
55 | Map header = new HashMap<>(6);
56 | header.put("X-Sign", authorization);
57 | header.put("X-Token", token);
58 | header.put("X-AppId", appId);
59 | header.put("X-Time", timestamp);
60 | return header;
61 | } catch (Exception e) {
62 | logger.error("生成通用加密头失败", e);
63 | }
64 | return null;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/util/AuthUtil.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.util;
2 |
3 | import cn.xfyun.model.sign.AbstractSignature;
4 | import okhttp3.HttpUrl;
5 |
6 | import java.net.MalformedURLException;
7 | import java.net.URL;
8 | import java.security.SignatureException;
9 |
10 |
11 | /**
12 | * @author
13 | * @description 生成鉴权工具
14 | * @date 2021/3/24
15 | */
16 | public class AuthUtil {
17 |
18 | private static String algorithm = "hmac-sha256";
19 |
20 | public static String generateAuthorization(AbstractSignature signature) throws SignatureException {
21 | return generateAuthorization(signature, algorithm);
22 | }
23 |
24 | /**
25 | * 生成鉴权内容
26 | *
27 | * @param signature 鉴权实例
28 | * @param algorithm 加密方式
29 | * @return
30 | * @throws SignatureException
31 | */
32 | public static String generateAuthorization(AbstractSignature signature, String algorithm) throws SignatureException {
33 | return String.format("api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"",
34 | signature.getId(),
35 | algorithm,
36 | "host date request-line",
37 | signature.getSigna());
38 | }
39 |
40 | /**
41 | * 生成翻译鉴权内容
42 | *
43 | * @param signature 鉴权实例
44 | * @param algorithm 加密方式
45 | * @return
46 | * @throws SignatureException
47 | */
48 | public static String generateTransAuthorization(AbstractSignature signature, String algorithm) throws SignatureException {
49 | return String.format("api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"",
50 | signature.getId(),
51 | algorithm,
52 | "host date request-line digest",
53 | signature.getSigna());
54 | }
55 |
56 | /**
57 | * 生成带鉴权的请求URL
58 | *
59 | * @param signature 鉴权实例
60 | * @return
61 | * @throws MalformedURLException
62 | * @throws SignatureException
63 | */
64 | public static String generateRequestUrl(AbstractSignature signature) throws MalformedURLException, SignatureException {
65 | URL url = new URL(signature.getUrl());
66 | String authorization = generateAuthorization(signature);
67 |
68 | HttpUrl httpUrl = HttpUrl.parse("https://" + url.getHost() + url.getPath()).newBuilder()
69 | .addQueryParameter("authorization", CryptTools.base64Encode(authorization))
70 | .addQueryParameter("date", signature.getTs())
71 | .addQueryParameter("host", url.getHost())
72 | .build();
73 | return httpUrl.toString();
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/util/IOCloseUtil.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.util;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | import java.io.Closeable;
7 | import java.io.IOException;
8 |
9 | /**
10 | * @author
11 | * @description 关闭流工具
12 | * @date 2021/3/27
13 | */
14 | public class IOCloseUtil {
15 |
16 | private static final Logger logger = LoggerFactory.getLogger(IOCloseUtil.class);
17 |
18 | public static void close(Closeable closeable) {
19 | try {
20 | if (closeable != null) {
21 | closeable.close();
22 | }
23 | } catch (IOException e) {
24 | logger.error("Close IO exception ", e);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/websdk-java-core/src/main/java/cn/xfyun/util/SliceIdGenerator.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.util;
2 |
3 | /**
4 | * @author : iflytek
5 | * @date : 2021年03月15日
6 | */
7 | public class SliceIdGenerator {
8 | /**
9 | * INIT_STR最后一位是`, 其ASCII大小是96, 是a的前一位
10 | */
11 | private static final String INIT_STR = "aaaaaaaaa`";
12 |
13 | private static final int LENGTH = INIT_STR.length();
14 |
15 | private final char[] ch = INIT_STR.toCharArray();
16 |
17 | public String getNextSliceId() {
18 | for (int j = LENGTH - 1; j >= 0; j--) {
19 | if (this.ch[j] != 'z') {
20 | this.ch[j] = (char) (this.ch[j] + 1);
21 | break;
22 | }
23 | this.ch[j] = 'a';
24 | }
25 | return new String(this.ch);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/websdk-java-face-detector/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 | websdk-java-face-detector
7 | jar
8 | ${websdk-java-face-detector.version}
9 |
10 | websdk-java-parent
11 | cn.xfyun
12 | 2.1.2
13 | ../websdk-java-parent/pom.xml
14 |
15 |
16 |
17 |
18 | cn.xfyun
19 | websdk-java-core
20 | ${websdk-java-core.version}
21 |
22 |
23 |
24 |
25 |
26 |
27 | org.apache.maven.plugins
28 | maven-compiler-plugin
29 |
30 | 8
31 | 8
32 | UTF-8
33 |
34 |
35 |
36 | org.apache.maven.plugins
37 | maven-surefire-plugin
38 | 2.19.1
39 |
40 | true
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/main/java/cn/xfyun/api/AntiSpoofClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 |
4 |
5 | import cn.xfyun.base.http.platform.PlatformBuilder;
6 | import cn.xfyun.base.http.platform.PlatformHttpClient;
7 | import cn.xfyun.model.sign.Signature;
8 | import com.google.gson.JsonObject;
9 |
10 | import java.io.IOException;
11 |
12 | /**
13 | * 静默活体检测
14 | *
15 | * 基于讯飞自研的活体检测算法,针对打印照、屏幕二次翻拍等作弊场景,
16 | * 基于图片中人像破绽及成像畸形,可有效识别目标是否为活体,并给出置信度参考。
17 | *
18 | * 错误码链接:https://www.xfyun.cn/document/error-code (code返回错误码时必看)
19 | *
20 | * @author mqgao
21 | * @version 1.0
22 | * @date 2021/7/1 15:19
23 | */
24 | public class AntiSpoofClient extends PlatformHttpClient {
25 |
26 | public AntiSpoofClient(AntiSpoofClient.Builder builder) {
27 | super(builder);
28 | }
29 |
30 | public String faceContrast(String imageBase64, String encoding) throws IOException {
31 | String signUrl = Signature.signHostDateAuthorization(hostUrl, "POST", apiKey, apiSecret);
32 | return sendPost(signUrl, JSON, null, bodyParam(imageBase64, encoding));
33 | }
34 |
35 | private String bodyParam(String imageBase64, String encoding) {
36 | JsonObject jso = new JsonObject();
37 | jso.add("header", buildHeader());
38 | JsonObject service = new JsonObject();
39 | service.addProperty("service_kind", "anti_spoof");
40 | service.add("anti_spoof_result", buildResult());
41 |
42 | JsonObject parameter = new JsonObject();
43 | parameter.add(serviceId, service);
44 | jso.add("parameter", parameter);
45 |
46 | /** payload **/
47 | JsonObject payload = new JsonObject();
48 | JsonObject inputImage1 = new JsonObject();
49 | inputImage1.addProperty("encoding", encoding);
50 | inputImage1.addProperty("image", imageBase64);
51 | payload.add("input1", inputImage1);
52 |
53 | jso.add("payload", payload);
54 | return jso.toString();
55 | }
56 |
57 |
58 | public static final class Builder extends PlatformBuilder {
59 |
60 | private static final String HOST_URL = "https://api.xf-yun.com/v1/private/s67c9c78c";
61 |
62 | private static final String SERVICE_ID = "s67c9c78c";
63 |
64 | public Builder(String appId, String apiKey, String apiSecret) {
65 | super(HOST_URL, SERVICE_ID, appId, apiKey, apiSecret);
66 | }
67 |
68 | @Override
69 | public AntiSpoofClient build() {
70 | AntiSpoofClient client = new AntiSpoofClient(this);
71 | return client;
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/main/java/cn/xfyun/api/FaceStatusClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.platform.PlatformBuilder;
4 | import cn.xfyun.base.http.platform.PlatformHttpClient;
5 | import cn.xfyun.model.sign.Signature;
6 | import com.google.gson.JsonObject;
7 |
8 | import java.io.IOException;
9 |
10 | /**
11 | * 配合式活体检测
12 | *
13 | * 基于讯飞自研的人脸算法,可以通过用户提供的图片,对图片内人物眼睛是否睁开进行判断,并且返回得分。
14 | * 该能力是通过HTTP API的方式给开发者提供一个通用的接口。
15 | * HTTP API适用于一次性交互数据传输的AI服务场景,块式传输。相较于SDK,API具有轻量、跨语言的特点。
16 | *
17 | * @author mqgao
18 | * @version 1.0
19 | * @date 2021/7/1 15:46
20 | */
21 | public class FaceStatusClient extends PlatformHttpClient {
22 |
23 |
24 | public FaceStatusClient(FaceStatusClient.Builder builder) {
25 | super(builder);
26 | }
27 |
28 |
29 | public String faceContrast(String imageBase641, String encoding) throws IOException {
30 | String signUrl = Signature.signHostDateAuthorization(hostUrl, "POST", apiKey, apiSecret);
31 | return sendPost(signUrl, JSON, null, bodyParam(imageBase641, encoding));
32 | }
33 |
34 | private String bodyParam(String imageBase64, String encoding) {
35 | JsonObject jso = new JsonObject();
36 | jso.add("header", buildHeader());
37 | JsonObject service = new JsonObject();
38 | service.addProperty("service_kind", "face_status");
39 | service.add("face_status_result", buildResult());
40 |
41 | JsonObject parameter = new JsonObject();
42 | parameter.add(serviceId, service);
43 | jso.add("parameter", parameter);
44 |
45 | /** payload **/
46 | JsonObject payload = new JsonObject();
47 | JsonObject inputImage1 = new JsonObject();
48 | inputImage1.addProperty("encoding", encoding);
49 | inputImage1.addProperty("image", imageBase64);
50 | payload.add("input1", inputImage1);
51 |
52 | jso.add("payload", payload);
53 | return jso.toString();
54 | }
55 |
56 |
57 | public static final class Builder extends PlatformBuilder {
58 |
59 | private static final String HOST_URL = "https://api.xf-yun.com/v1/private/s67c9c78c";
60 |
61 | private static final String SERVICE_ID = "s67c9c78c";
62 |
63 |
64 | public Builder(String appId, String apiKey, String apiSecret) {
65 | super(HOST_URL, SERVICE_ID, appId, apiKey, apiSecret);
66 | }
67 |
68 | @Override
69 | public FaceStatusClient build() {
70 | FaceStatusClient client = new FaceStatusClient(this);
71 | return client;
72 | }
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/main/java/cn/xfyun/api/FaceVerificationClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.HttpBuilder;
4 | import cn.xfyun.base.http.HttpClient;
5 | import cn.xfyun.model.sign.Signature;
6 | import com.google.gson.JsonObject;
7 |
8 | import java.io.IOException;
9 | import java.net.URLEncoder;
10 | import java.util.Map;
11 |
12 | /**
13 | * 人脸比对sensetime
14 | *
15 | * 错误码链接:https://www.xfyun.cn/document/error-code
16 | *
17 | * @author mqgao
18 | * @version 1.0
19 | * @date 2021/7/1 14:24
20 | */
21 | public class FaceVerificationClient extends HttpClient {
22 |
23 | /**
24 | * 是否对图片进行自动旋转,true旋转,false不旋转,默认false
25 | */
26 | private boolean autoRotate;
27 |
28 | public boolean isAutoRotate() {
29 | return autoRotate;
30 | }
31 |
32 | public FaceVerificationClient(FaceVerificationClient.Builder builder) {
33 | super(builder);
34 | this.autoRotate = builder.autoRotate;
35 | }
36 |
37 | public String compareFace(String imageBase641, String imageBase642) throws IOException {
38 | JsonObject jso = new JsonObject();
39 | jso.addProperty("get_image", true);
40 | jso.addProperty("auto_rotate", autoRotate);
41 | String params = jso.toString();
42 | Map header = Signature.signHttpHeaderCheckSum(appId, apiKey, params);
43 | return sendPost(hostUrl, FORM, header, "first_image=" + URLEncoder.encode(imageBase641, "UTF-8") + "&" + "second_image="+ URLEncoder.encode(imageBase642, "UTF-8"));
44 | }
45 |
46 |
47 | public static final class Builder extends HttpBuilder {
48 |
49 | private static final String HOST_URL = "https://api.xfyun.cn/v1/service/v1/image_identify/face_verification";
50 |
51 | private boolean autoRotate = false;
52 |
53 | public Builder(String appId, String apiKey) {
54 | super(HOST_URL, appId, apiKey, null);
55 | }
56 |
57 | public FaceVerificationClient.Builder url(String url) {
58 | this.hostUrl(url);
59 | return this;
60 | }
61 |
62 | public FaceVerificationClient.Builder autoRotate(boolean autoRotate) {
63 | this.autoRotate = autoRotate;
64 | return this;
65 | }
66 |
67 | @Override
68 | public FaceVerificationClient build() {
69 | FaceVerificationClient client = new FaceVerificationClient(this);
70 | return client;
71 | }
72 |
73 | }
74 |
75 |
76 |
77 |
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/main/java/cn/xfyun/api/SilentDetectionClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.HttpBuilder;
4 | import cn.xfyun.base.http.HttpClient;
5 | import cn.xfyun.model.sign.Signature;
6 | import com.google.gson.JsonObject;
7 |
8 | import java.io.IOException;
9 | import java.net.URLEncoder;
10 | import java.util.Map;
11 |
12 | /**
13 | * 基于商汤的活体检测技术,将一段实地拍摄的人脸视频进行云端检测,
14 | * 判断是否为真人活体,该接口用于对一段短视频进行静默活体检测,判断视频中人脸是否为活体。
15 | *
16 | * @author mqgao
17 | * @version 1.0
18 | * @date 2021/7/1 15:56
19 | */
20 | public class SilentDetectionClient extends HttpClient {
21 |
22 | public SilentDetectionClient(SilentDetectionClient.Builder builder) {
23 | super(builder);
24 | }
25 |
26 |
27 | public String silentDetection(String audioBase64) throws IOException {
28 | JsonObject jso = new JsonObject();
29 | jso.addProperty("get_image", true);
30 | String params = jso.toString();
31 | Map header = Signature.signHttpHeaderCheckSum(appId, apiKey, params);
32 | return sendPost(hostUrl, FORM, header, "file=" + URLEncoder.encode(audioBase64, "UTF-8"));
33 | }
34 |
35 | public static final class Builder extends HttpBuilder {
36 |
37 | private static final String HOST_URL = "https://api.xfyun.cn/v1/service/v1/image_identify/silent_detection";
38 |
39 | public Builder(String appId, String apiKey) {
40 | super(HOST_URL, appId, apiKey, null);
41 | }
42 |
43 | @Override
44 | public SilentDetectionClient build() {
45 | SilentDetectionClient client = new SilentDetectionClient(this);
46 | return client;
47 | }
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/main/java/cn/xfyun/api/TupApiClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.HttpBuilder;
4 | import cn.xfyun.base.http.HttpClient;
5 | import cn.xfyun.config.TupApiEnum;
6 | import cn.xfyun.model.sign.Signature;
7 |
8 | import java.io.IOException;
9 | import java.util.Map;
10 |
11 | /**
12 | * 人脸特征分析年龄
13 | *
14 | * 人脸特征分析,基于图普的深度学习算法,
15 | * 可以检测图像中的人脸并进行一系列人脸相关的特征分析,当前支持识别出包括性别、颜值、年龄、表情多维度人脸信息。
16 | * 可用作基础人脸信息的解析,智能分析人群特征。
17 | *
18 | * 人脸特征分析年龄WebAPI接口调用示例接口文档(必看):https://doc.xfyun.cn/rest_api/%E4%BA%BA%E8%84%B8%E7%89%B9%E5%BE%81%E5%88%86%E6%9E%90-%E5%B9%B4%E9%BE%84.html
19 | * 图片属性:png、jpg、jpeg、bmp、tif图片大小不超过800k
20 | * (Very Important)创建完webapi应用添加服务之后一定要设置ip白名单,找到控制台--我的应用--设置ip白名单,如何设置参考:http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=41891
21 | *
22 | * 错误码链接:https://www.xfyun.cn/document/error-code (code返回错误码时必看)
23 | *
24 | * @author mqgao
25 | * @version 1.0
26 | * @date 2021/7/1 17:12
27 | */
28 | public class TupApiClient extends HttpClient {
29 |
30 | private TupApiEnum func;
31 |
32 | public TupApiEnum getFunc() {
33 | return func;
34 | }
35 |
36 | public TupApiClient(TupApiClient.Builder builder) {
37 | super(builder);
38 | this.func = builder.func;
39 | }
40 |
41 | public String recognition(String imageName, byte[] imageByteArray) throws IOException {
42 | String param = "{\"image_name\":\"" + imageName + "\"}";
43 | Map header = Signature.signHttpHeaderCheckSum(appId, apiKey, param);
44 | return sendPost(hostUrl + func.getValue(), BINARY, header, imageByteArray);
45 | }
46 |
47 |
48 | public static final class Builder extends HttpBuilder {
49 |
50 | private static final String HOST_URL = "http://tupapi.xfyun.cn/v1/";
51 |
52 | private TupApiEnum func;
53 |
54 |
55 | public Builder(String appId, String apiKey, TupApiEnum func) {
56 | super(HOST_URL, appId, apiKey, null);
57 | this.func = func;
58 | }
59 |
60 | public TupApiClient.Builder func(TupApiEnum func) {
61 | this.func = func;
62 | return this;
63 | }
64 |
65 | @Override
66 | public TupApiClient build() {
67 | TupApiClient client = new TupApiClient(this);
68 | return client;
69 | }
70 |
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/main/java/cn/xfyun/api/WatermarkVerificationClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.HttpBuilder;
4 | import cn.xfyun.base.http.HttpClient;
5 | import cn.xfyun.model.sign.Signature;
6 | import com.google.gson.JsonObject;
7 |
8 | import java.io.IOException;
9 | import java.util.HashMap;
10 | import java.util.Map;
11 |
12 | /**
13 | * 人脸水印照比对
14 | *
15 | * 错误码链接:https://www.xfyun.cn/document/error-code (code返回错误码时必看)
16 | *
17 | * @author mqgao
18 | * @version 1.0
19 | * @date 2021/7/1 15:00
20 | */
21 | public class WatermarkVerificationClient extends HttpClient {
22 |
23 | /**
24 | * 是否对图片进行自动旋转,true旋转,false不旋转,默认false
25 | */
26 | private boolean autoRotate;
27 |
28 |
29 | public WatermarkVerificationClient(WatermarkVerificationClient.Builder builder) {
30 | super(builder);
31 | this.autoRotate = builder.autoRotate;
32 | }
33 |
34 | public String compare(String faceImageBase64, String watermarkImageBase64) throws IOException {
35 | JsonObject jso = new JsonObject();
36 | jso.addProperty("get_image", true);
37 | jso.addProperty("auto_rotate", autoRotate);
38 | String params = jso.toString();
39 | Map header = Signature.signHttpHeaderCheckSum(appId, apiKey, params);
40 | Map body = new HashMap<>(2);
41 | body.put("face_image", faceImageBase64);
42 | body.put("watermark_image", watermarkImageBase64);
43 | return sendPost(hostUrl, header, body);
44 | }
45 |
46 |
47 | public static final class Builder extends HttpBuilder {
48 |
49 | private static final String HOST_URL = "https://api.xfyun.cn/v1/service/v1/image_identify/watermark_verification";
50 |
51 | private boolean autoRotate = false;
52 |
53 | public Builder(String appId, String apiKey) {
54 | super(HOST_URL, appId, apiKey, null);
55 | }
56 |
57 | public Builder autoRotate(boolean autoRotate) {
58 | this.autoRotate = autoRotate;
59 | return this;
60 | }
61 |
62 | @Override
63 | public WatermarkVerificationClient build() {
64 | WatermarkVerificationClient client = new WatermarkVerificationClient(this);
65 | return client;
66 | }
67 |
68 | }
69 |
70 | }
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/test/resources/image/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-face-detector/src/test/resources/image/1.jpg
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/test/resources/image/12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-face-detector/src/test/resources/image/12.jpg
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/test/resources/image/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-face-detector/src/test/resources/image/2.png
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/test/resources/image/daiye2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-face-detector/src/test/resources/image/daiye2.jpg
--------------------------------------------------------------------------------
/websdk-java-face-detector/src/test/resources/test.properties:
--------------------------------------------------------------------------------
1 | appId=
2 | antiSpoofClientApiKey=
3 | antiSpoofClientApiSecret=
4 | faceCompareClientApiKey=
5 | faceCompareClientApiSecret=
6 | faceDetectClientApiKey=
7 | faceDetectClientApiSecret=
8 | faceStatusClientApiKey=
9 | faceStatusClientApiSecret=
10 | faceVerificationClientApiKey=
11 | silentDetectionClientApiKey=
12 | tupApiClientApiKey=
13 | watermarkVerificationApiKey=
14 |
15 |
--------------------------------------------------------------------------------
/websdk-java-nlp/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 | websdk-java-nlp
7 | jar
8 | ${websdk-java-nlp.version}
9 |
10 | websdk-java-parent
11 | cn.xfyun
12 | 2.1.2
13 | ../websdk-java-parent/pom.xml
14 |
15 |
16 |
17 |
18 | cn.xfyun
19 | websdk-java-core
20 | ${websdk-java-core.version}
21 |
22 |
23 |
24 |
25 |
26 |
27 | org.apache.maven.plugins
28 | maven-compiler-plugin
29 |
30 | 8
31 | 8
32 | UTF-8
33 |
34 |
35 |
36 | org.apache.maven.plugins
37 | maven-surefire-plugin
38 | 2.19.1
39 |
40 | true
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/api/SaClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.HttpBuilder;
4 | import cn.xfyun.base.http.HttpClient;
5 | import cn.xfyun.model.sign.Signature;
6 |
7 | import java.io.IOException;
8 |
9 | /**
10 | * 情感分析
11 | *
12 | * @author mqgao
13 | * @version 1.0
14 | * @date 2021/6/11 10:43
15 | */
16 | public class SaClient extends HttpClient {
17 |
18 | private static final String TYPE = "{\"type\":\"dependent\"}";
19 |
20 | public SaClient(SaClient.Builder builder) {
21 | super(builder);
22 | }
23 |
24 |
25 | public String send(String text) throws IOException {
26 | return sendPost(hostUrl, FORM, Signature.signHttpHeaderCheckSum(appId, apiKey,TYPE), "text=" + text);
27 | }
28 |
29 |
30 | public static final class Builder extends HttpBuilder {
31 | /**
32 | * 服务请求地址
33 | */
34 | private static final String HOST_URL = "https://ltpapi.xfyun.cn/v2/sa";;
35 |
36 | public Builder(String appId, String apiKey) {
37 | super(HOST_URL, appId, apiKey, null);
38 | }
39 |
40 | @Override
41 | public SaClient build() {
42 | return new SaClient(this);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/api/TextCheckClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.platform.PlatformBuilder;
4 | import cn.xfyun.base.http.platform.PlatformHttpClient;
5 | import cn.xfyun.exception.BusinessException;
6 | import cn.xfyun.model.sign.Signature;
7 | import cn.xfyun.util.StringUtils;
8 | import com.google.gson.JsonObject;
9 |
10 | import java.io.IOException;
11 | import java.util.Base64;
12 |
13 | /**
14 | *
15 | * 文本纠错 API
16 | *
17 | * @author mqgao
18 | * @version 1.0
19 | * @date 2021/6/8 14:32
20 | */
21 | public class TextCheckClient extends PlatformHttpClient {
22 |
23 |
24 | public TextCheckClient(TextCheckClient.Builder builder) {
25 | super(builder);
26 | }
27 |
28 |
29 | public String send(String text) throws Exception {
30 | if (StringUtils.isNullOrEmpty(text)) {
31 | throw new BusinessException("text不能为空");
32 | }
33 | String realUrl = Signature.signHostDateAuthorization(hostUrl, "POST", apiKey, apiSecret);
34 | return sendPost(realUrl, JSON, null, buildParam(text));
35 | }
36 |
37 | private String buildParam(String text) throws IOException {
38 | JsonObject req = new JsonObject();
39 | //平台参数
40 | req.add("header", buildHeader());
41 | //功能参数
42 | JsonObject parameter = new JsonObject();
43 |
44 | JsonObject result = new JsonObject();
45 |
46 | result.add("result", buildResult());
47 | parameter.add(this.serviceId, result);
48 | //请求数据
49 | JsonObject payload = new JsonObject();
50 | JsonObject input = new JsonObject();
51 | //jpg:jpg格式,jpeg:jpeg格式,png:png格式,bmp:bmp格式
52 | input.addProperty("encoding",encoding);
53 | //raw,gzip
54 | input.addProperty("compress",compress);
55 | //plain,json,xml
56 | input.addProperty("format",format);
57 | //3:一次性传完
58 | input.addProperty("status",status);
59 | //文本数据,base64
60 | input.addProperty("text", Base64.getEncoder().encodeToString(text.getBytes("UTF-8")));
61 | payload.add("input",input);
62 |
63 | req.add("parameter",parameter);
64 | req.add("payload",payload);
65 |
66 | return req.toString();
67 | }
68 |
69 |
70 | public static final class Builder extends PlatformBuilder {
71 |
72 | private static final String HOST_URL = "https://api.xf-yun.com/v1/private/s9a87e3ec";
73 |
74 | private static final String SERVICE_ID = "s9a87e3ec";
75 |
76 | public Builder(String appId, String apiKey, String apiSecret) {
77 | super(HOST_URL, SERVICE_ID, appId, apiKey, apiSecret);
78 | }
79 |
80 | @Override
81 | public TextCheckClient build() {
82 | TextCheckClient client = new TextCheckClient(this);
83 | return client;
84 | }
85 |
86 | }
87 |
88 |
89 | }
90 |
91 |
92 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/config/AudioFormat.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 音频类型枚举类
5 | *
6 | * @author
7 | **/
8 | public enum AudioFormat {
9 |
10 | MP3("mp3"),
11 | ALAW("alaw"),
12 | ULAW("ulaw"),
13 | PCM("pcm"),
14 | AAC("aac"),
15 | WAV("wav");
16 |
17 | private final String format;
18 |
19 | AudioFormat(String format) {
20 | this.format = format;
21 | }
22 |
23 | public String getFormat() {
24 | return format;
25 | }
26 |
27 | @Override
28 | public String toString() {
29 | return this.format;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/config/CategoryEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 词条敏感分类
5 | *
6 | * @author
7 | **/
8 | public enum CategoryEnum {
9 |
10 | PORNO_DETECTION("pornDetection", "色情"),
11 | VIOLENT_TERRORISM("violentTerrorism", "暴恐"),
12 | POLITICAL("political", "涉政"),
13 | LOW_QUALITY_IRRIGATION("lowQualityIrrigation", "低质量灌水"),
14 | CONTRABAND("contraband", "违禁"),
15 | ADVERTISEMENT("advertisement", "广告"),
16 | UNCIVILIZED_LANGUAGE("uncivilizedLanguage", "不文明用语");
17 |
18 | private final String code;
19 | private final String description;
20 |
21 | CategoryEnum(String code, String description) {
22 | this.code = code;
23 | this.description = description;
24 | }
25 |
26 | public String getCode() {
27 | return code;
28 | }
29 |
30 | public String getDescription() {
31 | return description;
32 | }
33 |
34 | public static CategoryEnum fromCode(String code) {
35 | for (CategoryEnum category : CategoryEnum.values()) {
36 | if (category.getCode().equalsIgnoreCase(code)) {
37 | return category;
38 | }
39 | }
40 | throw new IllegalArgumentException("Unknown content category code: " + code);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/config/VideoFormat.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 视频类型分类
5 | *
6 | * @author
7 | **/
8 | public enum VideoFormat {
9 |
10 | MP4("mp4"),
11 | THREE_GP("3gp"),
12 | ASF("asf"),
13 | AVI("avi"),
14 | RMVB("rmvb"),
15 | MPEG("mpeg"),
16 | WMV("wmv"),
17 | RM("rm"),
18 | MPEG4("mpeg4"),
19 | MPV("mpv"),
20 | MKV("mkv"),
21 | FLV("flv"),
22 | VOB("vob");
23 |
24 | private final String format;
25 |
26 | VideoFormat(String format) {
27 | this.format = format;
28 | }
29 |
30 | public String getFormat() {
31 | return format;
32 | }
33 |
34 | /**
35 | * 根据格式字符串获取对应的枚举
36 | */
37 | public static VideoFormat fromString(String format) {
38 | if (format != null) {
39 | for (VideoFormat vf : VideoFormat.values()) {
40 | if (vf.getFormat().equalsIgnoreCase(format)) {
41 | return vf;
42 | }
43 | }
44 | }
45 | throw new IllegalArgumentException("Unknown video format: " + format);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/config/WordLibEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 词库请求枚举类
5 | *
6 | * @author
7 | **/
8 | public enum WordLibEnum {
9 |
10 | CREATE_BLACK("https://audit.iflyaisol.com/audit_res/v1/wordLib/createBlack", "新增黑名单词库", "POST"),
11 | CREATE_WHITE("https://audit.iflyaisol.com/audit_res/v1/wordLib/createWhite", "新增白名单词库", "POST"),
12 | ADD_WORD("https://audit.iflyaisol.com/audit_res/v1/wordLib/addWord", "根据lib_id添加黑名单词条", "POST"),
13 | INFO("https://audit.iflyaisol.com/audit_res/v1/wordLib/info", "根据lib_id查询词条明细", "POST"),
14 | DEL_WORD("https://audit.iflyaisol.com/audit_res/v1/wordLib/delWord", "根据lib_id删除词条", "POST"),
15 | LIST("https://audit.iflyaisol.com/audit_res/v1/wordLib/list", "根据appid查询账户下所有词库", "POST"),
16 | DEL_LIB("https://audit.iflyaisol.com/audit_res/v1/wordLib/delete", "根据lib_id删除词库", "POST");
17 |
18 | private final String url;
19 | private final String desc;
20 | private final String method;
21 |
22 | WordLibEnum(String url, String desc, String method) {
23 | this.url = url;
24 | this.desc = desc;
25 | this.method = method;
26 | }
27 |
28 | public String getUrl() {
29 | return url;
30 | }
31 |
32 | public String getDesc() {
33 | return desc;
34 | }
35 |
36 | public String getMethod() {
37 | return method;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/model/Audio.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | /**
6 | * 音频信息实体类
7 | *
8 | * @author
9 | **/
10 | public class Audio {
11 |
12 | /**
13 | * 音频类型,如果不传,取 url 后缀名作为格式
14 | * 支持类型:mp3、alaw、ulaw、pcm、aac、wav
15 | */
16 | @SerializedName("audio_type")
17 | private String audioType;
18 |
19 | /**
20 | * 音频地址,长度限制 500字符以内
21 | * 通过URL外链的音频时长建议限制在1小时内
22 | */
23 | @SerializedName("file_url")
24 | private String fileUrl;
25 |
26 | /**
27 | * 音频名称
28 | */
29 | private String name;
30 |
31 | public Audio(Builder builder) {
32 | this.audioType = builder.audioType;
33 | this.fileUrl = builder.fileUrl;
34 | this.name = builder.name;
35 | }
36 |
37 | public String getAudioType() {
38 | return audioType;
39 | }
40 |
41 | public String getFileUrl() {
42 | return fileUrl;
43 | }
44 |
45 | public String getName() {
46 | return name;
47 | }
48 |
49 | public void setAudioType(String audioType) {
50 | this.audioType = audioType;
51 | }
52 |
53 | public void setFileUrl(String fileUrl) {
54 | this.fileUrl = fileUrl;
55 | }
56 |
57 | public void setName(String name) {
58 | this.name = name;
59 | }
60 |
61 | public static final class Builder {
62 |
63 | private String audioType;
64 | private String fileUrl;
65 | private String name;
66 |
67 | public Audio build() {
68 | return new Audio(this);
69 | }
70 |
71 | public Builder audioType(String audioType) {
72 | this.audioType = audioType;
73 | return this;
74 | }
75 |
76 | public Builder fileUrl(String fileUrl) {
77 | this.fileUrl = fileUrl;
78 | return this;
79 | }
80 |
81 | public Builder name(String name) {
82 | this.name = name;
83 | return this;
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/model/Video.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | /**
6 | * 视频信息实体类
7 | *
8 | * @author
9 | **/
10 | public class Video {
11 |
12 | /**
13 | * 视频格式
14 | * 支持mp4、3gp、asf、avi、rmvb、mpeg、wmv、rm、mpeg4、mpv、mkv、flv、vob格式
15 | */
16 | @SerializedName("video_type")
17 | private String videoType;
18 |
19 | /**
20 | * 视频地址,长度限制 500字符以内
21 | * 通过URL外链的音频时长建议限制在2小时内
22 | */
23 | @SerializedName("file_url")
24 | private String fileUrl;
25 |
26 | /**
27 | * 视频名称
28 | */
29 | private String name;
30 |
31 | public Video(Builder builder) {
32 | this.videoType = builder.videoType;
33 | this.fileUrl = builder.fileUrl;
34 | this.name = builder.name;
35 | }
36 |
37 |
38 | public String getFileUrl() {
39 | return fileUrl;
40 | }
41 |
42 | public String getName() {
43 | return name;
44 | }
45 |
46 | public String getVideoType() {
47 | return videoType;
48 | }
49 |
50 | public void setVideoType(String videoType) {
51 | this.videoType = videoType;
52 | }
53 |
54 | public void setFileUrl(String fileUrl) {
55 | this.fileUrl = fileUrl;
56 | }
57 |
58 | public void setName(String name) {
59 | this.name = name;
60 | }
61 |
62 | public static final class Builder {
63 |
64 | private String videoType;
65 | private String fileUrl;
66 | private String name;
67 |
68 | public Video build() {
69 | return new Video(this);
70 | }
71 |
72 | public Builder videoType(String videoType) {
73 | this.videoType = videoType;
74 | return this;
75 | }
76 |
77 | public Builder fileUrl(String fileUrl) {
78 | this.fileUrl = fileUrl;
79 | return this;
80 | }
81 |
82 | public Builder name(String name) {
83 | this.name = name;
84 | return this;
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/model/simult/response/Streamtrans.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.simult.response;
2 |
3 | /**
4 | * 同声传译返回参数
5 | *
6 | * @author
7 | */
8 | public class Streamtrans {
9 |
10 |
11 | /**
12 | * src : 一个面向全球的中文学习爱好者的一个
13 | * dst : A global Chinese learningenthusiasts for a
14 | * wb : 10
15 | * we : 2480
16 | * is_final : 0
17 | */
18 |
19 | private String src;
20 | private String dst;
21 | private Integer wb;
22 | private Integer we;
23 | private Integer is_final;
24 |
25 | public String getSrc() {
26 | return src;
27 | }
28 |
29 | public void setSrc(String src) {
30 | this.src = src;
31 | }
32 |
33 | public String getDst() {
34 | return dst;
35 | }
36 |
37 | public void setDst(String dst) {
38 | this.dst = dst;
39 | }
40 |
41 | public Integer getWb() {
42 | return wb;
43 | }
44 |
45 | public void setWb(Integer wb) {
46 | this.wb = wb;
47 | }
48 |
49 | public Integer getWe() {
50 | return we;
51 | }
52 |
53 | public void setWe(Integer we) {
54 | this.we = we;
55 | }
56 |
57 | public Integer getIs_final() {
58 | return is_final;
59 | }
60 |
61 | public void setIs_final(Integer is_final) {
62 | this.is_final = is_final;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/main/java/cn/xfyun/model/translate/TransParam.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.translate;
2 |
3 | /**
4 | * 翻译请求参数
5 | *
6 | * @author
7 | */
8 | public class TransParam {
9 |
10 | /**
11 | * 需要翻译的文本
12 | */
13 | private String text;
14 |
15 | /**
16 | * 源语种
17 | */
18 | private String from;
19 |
20 | /**
21 | * 翻译语种
22 | */
23 | private String to;
24 |
25 | /**
26 | * 个性化术语ID
27 | */
28 | private String resId;
29 |
30 | public TransParam() {
31 | }
32 |
33 | public TransParam(Builder builder) {
34 | this.text = builder.text;
35 | this.from = builder.from;
36 | this.to = builder.to;
37 | this.resId = builder.resId;
38 | }
39 |
40 | public String getText() {
41 | return text;
42 | }
43 |
44 | public void setText(String text) {
45 | this.text = text;
46 | }
47 |
48 | public String getFrom() {
49 | return from;
50 | }
51 |
52 | public void setFrom(String from) {
53 | this.from = from;
54 | }
55 |
56 | public String getTo() {
57 | return to;
58 | }
59 |
60 | public void setTo(String to) {
61 | this.to = to;
62 | }
63 |
64 | public String getResId() {
65 | return resId;
66 | }
67 |
68 | public void setResId(String resId) {
69 | this.resId = resId;
70 | }
71 |
72 | public static Builder builder() {
73 | return new Builder();
74 | }
75 |
76 | public static final class Builder {
77 |
78 | private String text;
79 | private String from = "cn";
80 | private String to = "en";
81 | private String resId;
82 |
83 | private Builder() {
84 | }
85 |
86 | public TransParam build() {
87 | return new TransParam(this);
88 | }
89 |
90 | public Builder text(String text) {
91 | this.text = text;
92 | return this;
93 | }
94 |
95 | public Builder from(String from) {
96 | this.from = from;
97 | return this;
98 | }
99 |
100 | public Builder to(String to) {
101 | this.to = to;
102 | return this;
103 | }
104 |
105 | public Builder resId(String resId) {
106 | this.resId = resId;
107 | return this;
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/test/java/api/SaClientTest.java:
--------------------------------------------------------------------------------
1 | package api;
2 |
3 | import cn.xfyun.api.SaClient;
4 | import config.PropertiesConfig;
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.powermock.core.classloader.annotations.PowerMockIgnore;
9 | import org.powermock.core.classloader.annotations.PrepareForTest;
10 | import org.powermock.modules.junit4.PowerMockRunner;
11 | import org.powermock.reflect.Whitebox;
12 |
13 | import static org.junit.Assert.assertEquals;
14 |
15 | /**
16 | * @author mqgao
17 | * @version 1.0
18 | * @date 2021/6/11 11:08
19 | */
20 | @RunWith(PowerMockRunner.class)
21 | @PrepareForTest({SaClientTest.class})
22 | @PowerMockIgnore("javax.net.ssl.*")
23 | public class SaClientTest {
24 |
25 | private static final String appId = PropertiesConfig.getAppId();
26 | private static final String apiKey = PropertiesConfig.getSaClientApiKey();
27 |
28 | /**
29 | * 测试参数设置
30 | */
31 | @Test
32 | public void testParams() {
33 | SaClient saClient = new SaClient
34 | .Builder(appId, apiKey)
35 | .build();
36 | assertEquals(appId, saClient.getAppId());
37 | assertEquals(apiKey, saClient.getApiKey());
38 | assertEquals("https://ltpapi.xfyun.cn/v2/sa", Whitebox.getInternalState(saClient, "hostUrl"));
39 | }
40 |
41 | @Test
42 | public void testBuildParams() {
43 | SaClient saClient = new SaClient
44 | .Builder(appId, apiKey)
45 | .connectTimeout(1)
46 | .readTimeout(2)
47 | .callTimeout(3)
48 | .writeTimeout(4)
49 | .build();
50 | Assert.assertEquals(3, saClient.getCallTimeout());
51 | Assert.assertEquals(2, saClient.getReadTimeout());
52 | Assert.assertEquals(4, saClient.getWriteTimeout());
53 | Assert.assertEquals(1, saClient.getConnectTimeout());
54 | }
55 |
56 | /**
57 | * 一句话调用服务
58 | *
59 | * @throws Exception
60 | */
61 | @Test
62 | public void test() throws Exception {
63 | SaClient saClient = new SaClient.Builder(appId, apiKey)
64 | .build();
65 | System.out.println(saClient.send("你好,李焕英"));
66 | }
67 |
68 |
69 | @Test
70 | public void test1() throws Exception {
71 | SaClient saClient = new SaClient.Builder(appId, apiKey)
72 | .connectTimeout(3)
73 | .writeTimeout(2)
74 | .readTimeout(1)
75 | .build();
76 | System.out.println(saClient.send("websdk java"));
77 | }
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/test/java/api/TextCheckClientTest.java:
--------------------------------------------------------------------------------
1 | package api;
2 |
3 | import cn.xfyun.api.TextCheckClient;
4 | import cn.xfyun.exception.BusinessException;
5 | import config.PropertiesConfig;
6 | import org.junit.Assert;
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 | import org.powermock.core.classloader.annotations.PowerMockIgnore;
10 | import org.powermock.core.classloader.annotations.PrepareForTest;
11 | import org.powermock.modules.junit4.PowerMockRunner;
12 |
13 |
14 | /**
15 | * @author mqgao
16 | * @version 1.0
17 | * @date 2021/6/11 10:14
18 | */
19 | @RunWith(PowerMockRunner.class)
20 | @PrepareForTest({TextCheckClient.class})
21 | @PowerMockIgnore({"cn.xfyun.util.HttpConnector", "javax.crypto.*", "javax.net.ssl.*"})
22 | public class TextCheckClientTest {
23 |
24 | private static final String appId = PropertiesConfig.getAppId();
25 | private static final String apiKey = PropertiesConfig.getTextCheckClientApiKey();
26 | private static final String apiSecret = PropertiesConfig.getTextCheckClientApiSecret();
27 |
28 | @Test
29 | public void defaultParamTest() {
30 | TextCheckClient client = new TextCheckClient
31 | .Builder(appId, apiKey, apiSecret).build();
32 | Assert.assertEquals(client.getAppId(), appId);
33 | Assert.assertEquals(client.getApiKey(), apiKey);
34 | Assert.assertEquals(client.getApiSecret(), apiSecret);
35 | Assert.assertEquals(3, client.getReadTimeout());
36 | Assert.assertEquals(3, client.getWriteTimeout());
37 | Assert.assertEquals(3, client.getConnectTimeout());
38 | }
39 |
40 | @Test
41 | public void testParamBuild() {
42 | TextCheckClient client = new TextCheckClient
43 | .Builder(appId, apiKey, apiSecret)
44 | .compress("gzip")
45 | .format("plain")
46 | .encoding("base64")
47 | .status(2)
48 | .build();
49 | Assert.assertEquals(client.getServiceId(), "s9a87e3ec");
50 | Assert.assertEquals(client.getCompress(), "gzip");
51 | Assert.assertEquals(client.getFormat(), "plain");
52 | Assert.assertEquals(client.getEncoding(), "base64");
53 | Assert.assertEquals(client.getStatus(), 2);
54 | }
55 |
56 |
57 | @Test
58 | public void testSuccess() throws Exception {
59 | TextCheckClient correctionClient = new TextCheckClient
60 | .Builder(appId, apiKey, apiSecret)
61 | .build();
62 | String result = correctionClient.send("画蛇天足");
63 | System.out.println("返回结果: " + result);
64 | }
65 |
66 | @Test
67 | public void testSendNull() throws Exception {
68 | TextCheckClient correctionClient = new TextCheckClient
69 | .Builder(appId, apiKey, apiSecret)
70 | .build();
71 | try {
72 | String result = correctionClient.send("");
73 | System.out.println("返回结果: " + result);
74 | } catch (BusinessException e) {
75 | System.out.println(e);
76 | }
77 |
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/websdk-java-nlp/src/test/resources/audio/original.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-nlp/src/test/resources/audio/original.pcm
--------------------------------------------------------------------------------
/websdk-java-nlp/src/test/resources/image/political.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-nlp/src/test/resources/image/political.png
--------------------------------------------------------------------------------
/websdk-java-nlp/src/test/resources/test.properties:
--------------------------------------------------------------------------------
1 | appId=
2 | ltpClientApiKey=
3 | saClientApiKey=
4 | textCheckClientApiKey=
5 | textCheckClientApiSecret=
6 | transClientApiKey=
7 | transClientApiSecret=
8 | textComplianceClientApiKey=
9 | textComplianceClientApiSecret=
10 | picComplianceClientApiKey=
11 | picComplianceClientApiSecret=
12 | audioComplianceClientApiKey=
13 | audioComplianceClientApiSecret=
14 | videoComplianceClientApiKey=
15 | videoComplianceClientApiSecret=
16 | textProofClientApiKey=
17 | textProofClientApiSecret=
18 | textReWriteClientApiKey=
19 | textReWriteClientApiSecret=
20 | simInterpClientApiKey=
21 | simInterpClientApiSecret=
22 |
23 |
--------------------------------------------------------------------------------
/websdk-java-ocr/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 | jar
7 | websdk-java-ocr
8 | ${websdk-java-ocr.version}
9 |
10 | websdk-java-parent
11 | cn.xfyun
12 | 2.1.2
13 | ../websdk-java-parent/pom.xml
14 |
15 |
16 |
17 |
18 | cn.xfyun
19 | websdk-java-core
20 | ${websdk-java-core.version}
21 |
22 |
23 |
24 |
25 |
26 |
27 | org.apache.maven.plugins
28 | maven-compiler-plugin
29 |
30 | 8
31 | 8
32 | UTF-8
33 |
34 |
35 |
36 | org.apache.maven.plugins
37 | maven-surefire-plugin
38 | 2.19.1
39 |
40 | true
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/api/BankcardClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.HttpBuilder;
4 | import cn.xfyun.base.http.HttpClient;
5 | import cn.xfyun.model.sign.Signature;
6 | import com.google.gson.JsonObject;
7 |
8 | import java.io.IOException;
9 | import java.util.Map;
10 |
11 | /**
12 | * 银行卡识别
13 | *
14 | * 错误码链接:https://www.xfyun.cn/document/error-code (code返回错误码时必看)
15 | *
16 | * @author mqgao
17 | * @version 1.0
18 | * @date 2021/7/7 10:35
19 | */
20 | public class BankcardClient extends HttpClient {
21 |
22 | /**
23 | * 是否返回卡号区域截图,默认为0,如果设为 1,则返回base64编码的卡号区域截图。
24 | */
25 | private String cardNumberImage;
26 |
27 | public BankcardClient(Builder builder) {
28 | super(builder);
29 | this.cardNumberImage = builder.cardNumberImage;
30 | }
31 |
32 |
33 | public String bankcard(String imageBase64) throws IOException {
34 | JsonObject jsonObject = new JsonObject();
35 | jsonObject.addProperty("engine_type", "bankcard");
36 | jsonObject.addProperty("card_number_image", "0");
37 | Map header = Signature.signHttpHeaderCheckSum(appId, apiKey, jsonObject.toString());
38 | return sendPost(hostUrl, FORM, header, "image=" + imageBase64);
39 | }
40 |
41 |
42 |
43 | public static final class Builder extends HttpBuilder {
44 |
45 | private static final String HOST_URL = "https://webapi.xfyun.cn/v1/service/v1/ocr/bankcard";
46 |
47 | private String cardNumberImage = "0";
48 |
49 | public Builder(String appId, String apiKey) {
50 | super(HOST_URL, appId, apiKey, null);
51 | }
52 |
53 | public Builder cardNumberImage() {
54 | this.cardNumberImage = "1";
55 | return this;
56 | }
57 |
58 | @Override
59 | public BankcardClient build() {
60 | return new BankcardClient(this);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/api/BusinessCardClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.HttpBuilder;
4 | import cn.xfyun.base.http.HttpClient;
5 | import cn.xfyun.model.sign.Signature;
6 | import com.google.gson.JsonObject;
7 |
8 | import java.io.IOException;
9 | import java.util.Map;
10 |
11 | /**
12 | * 名片识别
13 | *
14 | * 错误码链接:https://www.xfyun.cn/document/error-code (code返回错误码时必看)
15 | *
16 | * @author mqgao
17 | * @version 1.0
18 | * @date 2021/7/7 13:36
19 | */
20 | public class BusinessCardClient extends HttpClient {
21 |
22 | private static final String BUSINESS_CARD = "business_card";
23 |
24 | private String picRequired;
25 |
26 | public BusinessCardClient(Builder builder) {
27 | super(builder);
28 | this.picRequired = builder.picRequired;
29 | }
30 |
31 | public String businessCard(String imageBase64) throws IOException {
32 | JsonObject jsonObject = new JsonObject();
33 | jsonObject.addProperty("engine_type", BUSINESS_CARD);
34 | jsonObject.addProperty("pic_required", picRequired);
35 | Map header = Signature.signHttpHeaderCheckSum(appId, apiKey, jsonObject.toString());
36 | return sendPost(hostUrl, FORM, header, "image=" + imageBase64);
37 | }
38 |
39 | public static final class Builder extends HttpBuilder {
40 |
41 | private static final String HOST_URL = "https://webapi.xfyun.cn/v1/service/v1/ocr/business_card";
42 |
43 | private String picRequired = "0";
44 |
45 | public Builder(String appId, String apiKey) {
46 | super(HOST_URL, appId, apiKey, null);
47 | }
48 |
49 | public Builder picRequired() {
50 | picRequired = "1";
51 | return this;
52 | }
53 |
54 | @Override
55 | public BusinessCardClient build() {
56 | return new BusinessCardClient(this);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/api/ImageRecClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.HttpBuilder;
4 | import cn.xfyun.base.http.HttpClient;
5 | import cn.xfyun.config.ImageRecEnum;
6 | import cn.xfyun.config.IntsigRecgEnum;
7 | import cn.xfyun.model.sign.Signature;
8 | import com.google.gson.JsonObject;
9 |
10 | import java.io.IOException;
11 | import java.util.Map;
12 |
13 | /**
14 | *
15 | * 场景识别 & 物体识别
16 | *
17 | * @author mqgao
18 | * @version 1.0
19 | * @date 2021/7/27 9:48
20 | */
21 | public class ImageRecClient extends HttpClient {
22 |
23 | public ImageRecClient(HttpBuilder builder) {
24 | super(builder);
25 | }
26 |
27 |
28 | public String send(String imageName, byte[] body) throws IOException {
29 | JsonObject jsonObject = new JsonObject();
30 | jsonObject.addProperty("image_name", imageName);
31 | Map header = Signature.signHttpHeaderCheckSum(appId, apiKey, jsonObject.toString());
32 | return sendPost(hostUrl, FORM, header, body);
33 | }
34 |
35 |
36 | public static final class Builder extends HttpBuilder {
37 |
38 | public Builder(String appId, String apiKey, ImageRecEnum recgEnum) {
39 | super(recgEnum.getValue(), appId, apiKey, null);
40 | }
41 |
42 | @Override
43 | public ImageRecClient build() {
44 | return new ImageRecClient(this);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/api/ItrClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.HttpBuilder;
4 | import cn.xfyun.base.http.HttpClient;
5 | import cn.xfyun.config.ItrEntEnum;
6 | import cn.xfyun.model.sign.Signature;
7 | import com.google.gson.JsonObject;
8 |
9 | import java.util.Map;
10 |
11 | /**
12 | * 拍照速算识别 & 公式识别
13 | *
14 | * 拍照速算识别基于深度学习的端到端识别技术,自动识别图片中的速算题并智能批改,
15 | * 返回标准LaTeX公式及批改结果。覆盖K12教育范围内15种题型,支持口算、竖式、方程、脱式计算等,
16 | * 详细请参照 速算题型 。支持的场景有印刷体、手写体、拍照场景。
17 | *
18 | *
19 | * @author mqgao
20 | * @version 1.0
21 | * @date 2021/7/7 13:50
22 | */
23 | public class ItrClient extends HttpClient {
24 |
25 | private ItrEntEnum itrEntEnum;
26 |
27 | public ItrEntEnum getItrEntEnum() {
28 | return itrEntEnum;
29 | }
30 |
31 | public ItrClient(Builder builder) {
32 | super(builder);
33 | this.itrEntEnum = builder.itrEntEnum;
34 | }
35 |
36 |
37 | public String itr(String imageBase64) throws Exception {
38 | String body = buildHttpBody(imageBase64);
39 | Map header = Signature.signHttpHeaderDigest(hostUrl, "POST", apiKey, apiSecret, body);
40 | return sendPost(hostUrl, JSON, header, body);
41 | }
42 |
43 |
44 | private String buildHttpBody(String imageBase64) {
45 | JsonObject body = new JsonObject();
46 | JsonObject business = new JsonObject();
47 | JsonObject common = new JsonObject();
48 | JsonObject data = new JsonObject();
49 | //填充common
50 | common.addProperty("app_id", appId);
51 | //填充business
52 | business.addProperty("ent", itrEntEnum.getValue());
53 | business.addProperty("aue", "raw");
54 | //填充data
55 | data.addProperty("image", imageBase64);
56 | //填充body
57 | body.add("common", common);
58 | body.add("business", business);
59 | body.add("data", data);
60 | return body.toString();
61 | }
62 |
63 |
64 |
65 | public static final class Builder extends HttpBuilder {
66 |
67 | private static final String HOST_URL = "https://rest-api.xfyun.cn/v2/itr";
68 |
69 | private ItrEntEnum itrEntEnum;
70 |
71 | public Builder(String appId, String apiKey, String apiSecret, ItrEntEnum itrEntEnum) {
72 | super(HOST_URL, appId, apiKey, apiSecret);
73 | this.itrEntEnum = itrEntEnum;
74 | }
75 |
76 | @Override
77 | public ItrClient build() {
78 | return new ItrClient(this);
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/api/PlaceRecClient.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import cn.xfyun.base.http.platform.PlatformBuilder;
4 | import cn.xfyun.base.http.platform.PlatformHttpClient;
5 | import cn.xfyun.model.sign.Signature;
6 | import com.google.gson.JsonObject;
7 |
8 | import java.io.IOException;
9 |
10 | /**
11 | * 场所识别
12 | *
13 | * @author mqgao
14 | * @version 1.0
15 | * @date 2021/7/27 10:03
16 | */
17 | public class PlaceRecClient extends PlatformHttpClient {
18 |
19 | public PlaceRecClient(Builder builder) {
20 | super(builder);
21 | }
22 |
23 | public String send(String imageBase64, String type) throws IOException {
24 | String realUrl = Signature.signHostDateAuthorization(hostUrl, "POST", apiKey, apiSecret);
25 | return sendPost(realUrl, JSON, buildParam(imageBase64, type));
26 | }
27 |
28 |
29 | private String buildParam(String imageBase64, String type) {
30 | JsonObject req = new JsonObject();
31 | //平台参数
32 | req.add("header", buildHeader());
33 | //功能参数
34 | JsonObject parameter = new JsonObject();
35 |
36 | JsonObject result = new JsonObject();
37 |
38 | result.add("result", buildResult());
39 | result.addProperty("func", "image/place");
40 |
41 | parameter.add(this.serviceId, result);
42 | //请求数据
43 | JsonObject payload = new JsonObject();
44 | JsonObject input = new JsonObject();
45 | input.addProperty("encoding", type);
46 | input.addProperty("image", imageBase64);
47 | input.addProperty("status", status);
48 | payload.add("data1", input);
49 |
50 | req.add("parameter", parameter);
51 | req.add("payload", payload);
52 | return req.toString();
53 | }
54 |
55 |
56 | public static final class Builder extends PlatformBuilder {
57 |
58 | private static final String HOST_URL = "https://api.xf-yun.com/v1/private/s5833e7f6";
59 |
60 | public Builder(String appId, String apiKey, String apiSecret) {
61 | super(HOST_URL, "s5833e7f6", appId, apiKey, apiSecret);
62 | }
63 |
64 | @Override
65 | public PlaceRecClient build() {
66 | return new PlaceRecClient(this);
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/config/IdcardEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/7 11:38
7 | */
8 | public enum IdcardEnum {
9 |
10 | /**
11 | * 返回文本位置信息
12 | */
13 | ON("1"),
14 |
15 | /**
16 | * 不返回文本位置信息
17 | */
18 | OFF("0");
19 |
20 | private String value;
21 |
22 | IdcardEnum(String value){
23 | this.value = value;
24 | }
25 |
26 |
27 | public String getValue() {
28 | return value;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/config/ImageRecEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/27 9:59
7 | */
8 | public enum ImageRecEnum {
9 |
10 |
11 | /**
12 | * 场景识别
13 | */
14 | SCENE("http://tupapi.xfyun.cn/v1/scene"),
15 |
16 |
17 | /**
18 | * 物体识别
19 | */
20 | CURRENCY("http://tupapi.xfyun.cn/v1/currency");
21 |
22 | private String value;
23 |
24 | ImageRecEnum(String value) {
25 | this.value = value;
26 | }
27 |
28 | public String getValue() {
29 | return value;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/config/ImageWordEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/8 13:40
7 | */
8 | public enum ImageWordEnum {
9 |
10 | /**
11 | * 营业执照识别
12 | */
13 | BUSINESS_LICENSE("sff4ea3cf", "bus_license", "sff4ea3cf_data_1"),
14 |
15 | /**
16 | * 出租车发票识别
17 | */
18 | TAXI_INVOICE("sb6db0171", "taxi_ticket", "sb6db0171_data_1"),
19 |
20 | /**
21 | * 火车票识别
22 | */
23 | TRAIN_TICKET("s19cfe728", "train_ticket", "s19cfe728_data_1"),
24 |
25 | /**
26 | * 增值税发票识别
27 | */
28 | INVOICE("s824758f1", "vat_invoice", "s824758f1_data_1"),
29 |
30 | /**
31 | * 身份证识别
32 | */
33 | IDCARD("s5ccecfce", "id_card", "s5ccecfce_data_1"),
34 |
35 | /**
36 | * 多语种文字识别
37 | */
38 | PRINTED_WORD("s00b65163", "vat_invoice", "s00b65163_data_1");
39 |
40 | private String serviceId;
41 |
42 | private String templateList;
43 |
44 | private String payload;
45 |
46 | ImageWordEnum(String serviceId, String templateList, String payload){
47 | this.serviceId = serviceId;
48 | this.templateList = templateList;
49 | this.payload = payload;
50 | }
51 |
52 | public String getServiceId() {
53 | return serviceId;
54 | }
55 |
56 | public String getTemplateList() {
57 | return templateList;
58 | }
59 |
60 | public String getPayload() {
61 | return payload;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/config/IntsigRecgEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 合合能力
5 | *
6 | * @author mqgao
7 | * @version 1.0
8 | * @date 2021/7/8 11:05
9 | */
10 | public enum IntsigRecgEnum {
11 | /**
12 | * 身份证识别
13 | */
14 | IDCARD("idcard"),
15 |
16 | /**
17 | * 营业执照识别
18 | */
19 | BUSINESS_LICENSE("business_license"),
20 |
21 | /**
22 | * 增值税发票识别
23 | */
24 | INVOICE("invoice"),
25 |
26 | /**
27 | * 印刷文字识别(多语种)
28 | */
29 | RECOGNIZE_DOCUMENT("recognize_document");
30 |
31 | String value;
32 |
33 | IntsigRecgEnum(String value) {
34 | this.value = value;
35 | }
36 |
37 | public String getValue() {
38 | return value;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/config/ItrEntEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/7 14:00
7 | */
8 | public enum ItrEntEnum {
9 |
10 | /**
11 | * 拍照速算识别
12 | */
13 | MATH_ARITH("math-arith"),
14 |
15 | /**
16 | * 公式识别
17 | */
18 | TEACH_PHOTO_PRINT("teach-photo-print");
19 |
20 | private String value;
21 |
22 | ItrEntEnum(String value){
23 | this.value = value;
24 | }
25 |
26 |
27 | public String getValue() {
28 | return value;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/config/JDRecgEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 |
4 | /**
5 | * @author mqgao
6 | * @version 1.0
7 | * @date 2021/7/7 16:15
8 | */
9 | public enum JDRecgEnum {
10 |
11 | /**
12 | * 行驶证识别
13 | */
14 | JD_OCR_VEHICLE("jd_ocr_vehicle", "vehicleLicenseRes", "jd_ocr_vehicle", "vehicleLicense"),
15 |
16 | /**
17 | * 驾驶证识别
18 | */
19 | JD_OCR_DRIVER("jd_ocr_driver", "driverLicenseRes", "jd_ocr_driver", "driverLicense"),
20 |
21 | /**
22 | * 车牌识别
23 | */
24 | JD_OCR_CAR("jd_ocr_car", "carLicenseRes", "jd_ocr_car", "carImgBase64Str");
25 |
26 | private String value;
27 | private String service;
28 | private String parameter;
29 | private String payload;
30 |
31 | JDRecgEnum(String value, String service, String parameter, String payload){
32 | this.value = value;
33 | this.service = service;
34 | this.parameter = parameter;
35 | this.payload = payload;
36 | }
37 |
38 |
39 | public String getValue() {
40 | return value;
41 | }
42 |
43 | public String getService() {
44 | return service;
45 | }
46 |
47 | public String getParameter() {
48 | return parameter;
49 | }
50 |
51 | public String getPayload() {
52 | return payload;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/config/LanguageEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/6 17:08
7 | */
8 | public enum LanguageEnum {
9 |
10 | /**
11 | * 英文
12 | */
13 | EN("en"),
14 |
15 | /**
16 | * 中英文混合
17 | */
18 | CN("cn|en");
19 |
20 |
21 | private String value;
22 |
23 | LanguageEnum(String value) {
24 | this.value = value;
25 | }
26 |
27 | public String getValue() {
28 | return value;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/config/LocationEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/6 17:17
7 | */
8 | public enum LocationEnum {
9 | /**
10 | * 返回文本位置信息
11 | */
12 | ON("true"),
13 |
14 | /**
15 | * 不返回文本位置信息
16 | */
17 | OFF("false");
18 |
19 | String value;
20 |
21 | LocationEnum(String value) {
22 | this.value = value;
23 | }
24 |
25 | public String getValue() {
26 | return value;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/main/java/cn/xfyun/config/OcrWordsEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/8 10:51
7 | */
8 | public enum OcrWordsEnum {
9 |
10 | /**
11 | * 印刷文字识别
12 | */
13 | PRINT("general"),
14 |
15 | /**
16 | * 手写文字识别
17 | */
18 | HANDWRITING("handwriting");
19 |
20 | String value;
21 |
22 | OcrWordsEnum(String value) {
23 | this.value = value;
24 | }
25 |
26 | public String getValue() {
27 | return value;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/websdk-java-ocr/src/test/resources/image/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-ocr/src/test/resources/image/1.jpg
--------------------------------------------------------------------------------
/websdk-java-ocr/src/test/resources/image/backcard.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-ocr/src/test/resources/image/backcard.jpg
--------------------------------------------------------------------------------
/websdk-java-ocr/src/test/resources/image/car.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-ocr/src/test/resources/image/car.jpg
--------------------------------------------------------------------------------
/websdk-java-ocr/src/test/resources/image/finger.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-ocr/src/test/resources/image/finger.jpg
--------------------------------------------------------------------------------
/websdk-java-ocr/src/test/resources/image/itr.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-ocr/src/test/resources/image/itr.jpg
--------------------------------------------------------------------------------
/websdk-java-ocr/src/test/resources/test.properties:
--------------------------------------------------------------------------------
1 | appId=
2 | bankcardClientApiKey=
3 | businessCardClientApiKey=
4 | fingerOcrClientApiKey=
5 | fingerOcrClientApiSecret=
6 | generalWordsClientApiKey=
7 | imageRecClientApiKey=
8 | imageWordClientApiKey=
9 | imageWordClientApiSecret=
10 | intsigOcrClientApiKey=
11 | itrClientApiKey=
12 | itrClientApiSecret=
13 | jDOcrClientApiKey=
14 | jDOcrClientApiSecret=
15 | placeRecClientApiKey=
16 | placeRecClientApiSecret=
17 |
18 |
--------------------------------------------------------------------------------
/websdk-java-parent/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | websdk-java
7 | cn.xfyun
8 | 2.1.2
9 |
10 |
11 | 4.0.0
12 | websdk-java-parent
13 | ${project.artifactId}
14 | pom
15 | 2.1.2
16 |
17 |
18 |
19 | junit
20 | junit
21 | 4.11
22 | test
23 |
24 |
25 | org.powermock
26 | powermock-module-junit4
27 | ${powermock.version}
28 | test
29 |
30 |
31 | org.powermock
32 | powermock-api-mockito2
33 | ${powermock.version}
34 | test
35 |
36 |
37 |
38 | org.slf4j
39 | slf4j-api
40 | 1.7.21
41 |
42 |
43 |
44 | com.google.code.gson
45 | gson
46 | 2.8.2
47 |
48 |
49 |
50 | org.jacoco
51 | org.jacoco.agent
52 | ${jacoco.version}
53 | runtime
54 |
55 |
56 |
57 |
58 | commons-codec
59 | commons-codec
60 | 1.10
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/websdk-java-spark/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 | websdk-java-spark
7 | jar
8 | ${websdk-java-spark.version}
9 |
10 | websdk-java-parent
11 | cn.xfyun
12 | 2.1.2
13 | ../websdk-java-parent/pom.xml
14 |
15 |
16 |
17 |
18 | cn.xfyun
19 | websdk-java-core
20 | ${websdk-java-core.version}
21 |
22 |
23 |
24 |
25 |
26 |
27 | org.apache.maven.plugins
28 | maven-compiler-plugin
29 |
30 | 8
31 | 8
32 | UTF-8
33 |
34 |
35 |
36 | org.apache.maven.plugins
37 | maven-surefire-plugin
38 | 2.19.1
39 |
40 | true
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/config/AIPPTEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 智能ppt枚举类
5 | *
6 | * @author
7 | **/
8 | public enum AIPPTEnum {
9 |
10 | LIST("https://zwapi.xfyun.cn/api/ppt/v2/template/list", "PPT主题列表查询", "POST"),
11 | CREATE("https://zwapi.xfyun.cn/api/ppt/v2/create", "PPT生成", "POST"),
12 | CREATE_OUTLINE("https://zwapi.xfyun.cn/api/ppt/v2/createOutline", "大纲生成", "POST"),
13 | CREATE_OUTLINE_BY_DOC("https://zwapi.xfyun.cn/api/ppt/v2/createOutlineByDoc", "自定义大纲生成", "POST"),
14 | CREATE_PPT_BY_OUTLINE("https://zwapi.xfyun.cn/api/ppt/v2/createPptByOutline", "通过大纲生成PPT", "POST"),
15 | PROGRESS("https://zwapi.xfyun.cn/api/ppt/v2/progress?sid=%s", "PPT进度查询", "GET");
16 |
17 | private final String url;
18 | private final String desc;
19 | private final String method;
20 |
21 | AIPPTEnum(String url, String desc, String method) {
22 | this.url = url;
23 | this.desc = desc;
24 | this.method = method;
25 | }
26 |
27 | public String getUrl() {
28 | return url;
29 | }
30 |
31 | public String getDesc() {
32 | return desc;
33 | }
34 |
35 | public String getMethod() {
36 | return method;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/config/AgeGroupEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 年龄段枚举类
5 | *
6 | * @author
7 | **/
8 | public enum AgeGroupEnum {
9 |
10 | CHILD(1, "儿童"),
11 | YOUTH(2, "青年"),
12 | MIDDLE_AGED(3, "中年"),
13 | SENIOR(4, "中老年");
14 |
15 | private final int value;
16 | private final String description;
17 |
18 | AgeGroupEnum(int value, String description) {
19 | this.value = value;
20 | this.description = description;
21 | }
22 |
23 | public int getValue() {
24 | return value;
25 | }
26 |
27 | public String getDescription() {
28 | return description;
29 | }
30 |
31 | public static AgeGroupEnum fromValue(int value) {
32 | for (AgeGroupEnum group : values()) {
33 | if (group.value == value) {
34 | return group;
35 | }
36 | }
37 | return CHILD; // 默认值为儿童
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/config/Role.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 大模型角色枚举类
5 | *
6 | * @author
7 | **/
8 | public enum Role {
9 |
10 | USER("user"),
11 | ASSISTANT("assistant"),
12 | SYSTEM("system");
13 |
14 | private final String value;
15 |
16 | Role(String value) {
17 | this.value = value;
18 | }
19 |
20 | public String getValue() {
21 | return value;
22 | }
23 |
24 | public static Role fromValue(String value) {
25 | for (Role role : Role.values()) {
26 | if (role.getValue().equalsIgnoreCase(value)) {
27 | return role;
28 | }
29 | }
30 | throw new IllegalArgumentException("Unknown role: " + value);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/config/SexEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 性别枚举类
5 | *
6 | * @author
7 | **/
8 | public enum SexEnum {
9 |
10 | MALE(1, "男"),
11 | FEMALE(2, "女");
12 |
13 | private final int value;
14 | private final String description;
15 |
16 | SexEnum(int value, String description) {
17 | this.value = value;
18 | this.description = description;
19 | }
20 |
21 | public int getValue() {
22 | return value;
23 | }
24 |
25 | public String getDescription() {
26 | return description;
27 | }
28 |
29 | public static SexEnum fromValue(int value) {
30 | for (SexEnum sex : values()) {
31 | if (sex.value == value) {
32 | return sex;
33 | }
34 | }
35 | return MALE; // 默认值为男
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/config/SparkBatchEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 |
4 | /**
5 | * 大模型批处理枚举类
6 | *
7 | * @author
8 | **/
9 | public enum SparkBatchEnum {
10 |
11 | UPLOAD_FILE("https://spark-api-open.xf-yun.com/v1/files", "上传文件", "POST"),
12 | GET_FILES("https://spark-api-open.xf-yun.com/v1/files?page=%s&size=%s", "查询文件列表", "GET"),
13 | GET_FILE("https://spark-api-open.xf-yun.com/v1/files/%s", "查询单个文件", "GET"),
14 | DELETE_FILE("https://spark-api-open.xf-yun.com/v1/files/%s", "删除文件", "DELETE"),
15 | DOWNLOAD_FILE("https://spark-api-open.xf-yun.com/v1/files/%s/content", "下载文件", "GET"),
16 | CREATE("https://spark-api-open.xf-yun.com/v1/batches", "创建Batch任务", "POST"),
17 | GET_BATCH("https://spark-api-open.xf-yun.com/v1/batches/%s", "查询Batch任务", "GET"),
18 | CANCEL("https://spark-api-open.xf-yun.com/v1/batches/%s/cancel", "取消Batch任务", "POST"),
19 | GET_BATCHES("https://spark-api-open.xf-yun.com/v1/batches?limit=%s&after=%s", "查询Batch列表", "GET");
20 |
21 | private final String url;
22 | private final String desc;
23 | private final String method;
24 |
25 | SparkBatchEnum(String url, String desc, String method) {
26 | this.url = url;
27 | this.desc = desc;
28 | this.method = method;
29 | }
30 |
31 | public String getUrl() {
32 | return url;
33 | }
34 |
35 | public String getDesc() {
36 | return desc;
37 | }
38 |
39 | public String getMethod() {
40 | return method;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/config/SparkModel.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 星火大模型类型枚举类
5 | *
6 | * @author
7 | **/
8 | public enum SparkModel {
9 |
10 | SPARK_X1("https://spark-api.xf-yun.com/v1/x1", "x1", "X1推理大模型", true, true, true),
11 | SPARK_4_0_ULTRA("https://spark-api.xf-yun.com/v4.0/chat", "4.0Ultra", "4.0Ultra大模型", true, true, true),
12 | SPARK_MAX_32K("https://spark-api.xf-yun.com/chat/max-32k", "max-32k", "max-32k大模型", true, false, true),
13 | SPARK_MAX("https://spark-api.xf-yun.com/v3.5/chat", "generalv3.5", "generalv3.5大模型", true, true, true),
14 | SPARK_PRO_128K("https://spark-api.xf-yun.com/chat/pro-128k", "pro-128k", "长文本大模型", true, false, true),
15 | SPARK_PRO("https://spark-api.xf-yun.com/v3.1/chat", "generalv3", "generalv3大模型", true, true, true),
16 | SPARK_LITE("https://spark-api.xf-yun.com/v1.1/chat", "lite", "lite模型", false, false, false),
17 | CHAT_KJWX("https://spark-openapi-n.cn-huabei-1.xf-yun.com/v1.1/chat_kjwx", "kjwx", "科研大模型", false, false, false),
18 | CHAT_MULTILANG("https://spark-api-n.xf-yun.com/v1.1/chat_multilang", "multilang", "多语种大模型", false, false, false);
19 |
20 | private final String url;
21 | private final String domain;
22 | private final String desc;
23 | private final boolean functionEnable;
24 | private final boolean webSearchEnable;
25 | private final boolean systemEnable;
26 |
27 | SparkModel(String url, String domain, String desc, boolean functionEnable, boolean webSearchEnable, boolean systemEnable) {
28 | this.url = url;
29 | this.domain = domain;
30 | this.desc = desc;
31 | this.functionEnable = functionEnable;
32 | this.webSearchEnable = webSearchEnable;
33 | this.systemEnable = systemEnable;
34 | }
35 |
36 | public String getUrl() {
37 | return url;
38 | }
39 |
40 | public String getDomain() {
41 | return domain;
42 | }
43 |
44 | public String getDesc() {
45 | return desc;
46 | }
47 |
48 | public boolean isFunctionEnable() {
49 | return functionEnable;
50 | }
51 |
52 | public boolean isWebSearchEnable() {
53 | return webSearchEnable;
54 | }
55 |
56 | public boolean isSystemEnable() {
57 | return systemEnable;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/aippt/request/Outline.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.aippt.request;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * 大纲内容请求实体类
7 | *
8 | * @author
9 | **/
10 | public class Outline {
11 |
12 | /**
13 | * PPT主标题
14 | */
15 | private String title;
16 |
17 | /**
18 | * PPT副标题
19 | */
20 | private String subTitle;
21 |
22 | /**
23 | * 章节
24 | */
25 | private List chapters;
26 |
27 | public String getTitle() {
28 | return title;
29 | }
30 |
31 | public void setTitle(String title) {
32 | this.title = title;
33 | }
34 |
35 | public String getSubTitle() {
36 | return subTitle;
37 | }
38 |
39 | public void setSubTitle(String subTitle) {
40 | this.subTitle = subTitle;
41 | }
42 |
43 | public List getChapters() {
44 | return chapters;
45 | }
46 |
47 | public void setChapters(List chapters) {
48 | this.chapters = chapters;
49 | }
50 |
51 | public static class Chapters {
52 |
53 | /**
54 | * 子章节标题名称
55 | */
56 | private String chapterTitle;
57 |
58 | /**
59 | * 二级大纲
60 | */
61 | private List chapterContents;
62 |
63 | public String getChapterTitle() {
64 | return chapterTitle;
65 | }
66 |
67 | public void setChapterTitle(String chapterTitle) {
68 | this.chapterTitle = chapterTitle;
69 | }
70 |
71 | public List getChapterContents() {
72 | return chapterContents;
73 | }
74 |
75 | public void setChapterContents(List chapterContents) {
76 | this.chapterContents = chapterContents;
77 | }
78 |
79 | public static class ChapterContents {
80 |
81 | /**
82 | * 二级大纲标题
83 | */
84 | private String chapterTitle;
85 |
86 | /**
87 | * 二级大纲内容
88 | */
89 | private Object chapterContents;
90 |
91 | public String getChapterTitle() {
92 | return chapterTitle;
93 | }
94 |
95 | public void setChapterTitle(String chapterTitle) {
96 | this.chapterTitle = chapterTitle;
97 | }
98 |
99 | public Object getChapterContents() {
100 | return chapterContents;
101 | }
102 |
103 | public void setChapterContents(Object chapterContents) {
104 | this.chapterContents = chapterContents;
105 | }
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/maas/request/MaasHttpRequest.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.maas.request;
2 |
3 | import cn.xfyun.model.sparkmodel.RoleContent;
4 | import com.google.gson.annotations.SerializedName;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * 精调文本大模型http请求实体类
10 | *
11 | * @author zyding6
12 | **/
13 | public class MaasHttpRequest {
14 | private String model;
15 | private List messages;
16 | private Boolean stream;
17 | private Float temperature;
18 | @SerializedName("max_tokens")
19 | private Integer maxTokens;
20 | @SerializedName("extra_headers")
21 | private Object extraHeaders;
22 | @SerializedName("extra_body")
23 | private Object extraBody;
24 | @SerializedName("stream_options")
25 | private Object streamOptions;
26 |
27 | public String getModel() {
28 | return model;
29 | }
30 |
31 | public void setModel(String model) {
32 | this.model = model;
33 | }
34 |
35 | public List getMessages() {
36 | return messages;
37 | }
38 |
39 | public void setMessages(List messages) {
40 | this.messages = messages;
41 | }
42 |
43 | public Boolean getStream() {
44 | return stream;
45 | }
46 |
47 | public void setStream(Boolean stream) {
48 | this.stream = stream;
49 | }
50 |
51 | public Float getTemperature() {
52 | return temperature;
53 | }
54 |
55 | public void setTemperature(Float temperature) {
56 | this.temperature = temperature;
57 | }
58 |
59 | public Integer getMaxTokens() {
60 | return maxTokens;
61 | }
62 |
63 | public void setMaxTokens(Integer maxTokens) {
64 | this.maxTokens = maxTokens;
65 | }
66 |
67 | public Object getExtraHeaders() {
68 | return extraHeaders;
69 | }
70 |
71 | public void setExtraHeaders(Object extraHeaders) {
72 | this.extraHeaders = extraHeaders;
73 | }
74 |
75 | public Object getExtraBody() {
76 | return extraBody;
77 | }
78 |
79 | public void setExtraBody(Object extraBody) {
80 | this.extraBody = extraBody;
81 | }
82 |
83 | public Object getStreamOptions() {
84 | return streamOptions;
85 | }
86 |
87 | public void setStreamOptions(Object streamOptions) {
88 | this.streamOptions = streamOptions;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/sparkmodel/FileContent.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sparkmodel;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * 大模型会话带文件实体类
7 | *
8 | * @author
9 | **/
10 | public class FileContent {
11 |
12 | private String role;
13 | private Object content;
14 |
15 | public String getRole() {
16 | return role;
17 | }
18 |
19 | public void setRole(String role) {
20 | this.role = role;
21 | }
22 |
23 | public Object getContent() {
24 | return content;
25 | }
26 |
27 | public void setContent(Object content) {
28 | this.content = content;
29 | }
30 |
31 | public static class Content {
32 |
33 | private String type;
34 | private List file;
35 | private String text;
36 |
37 | public String getType() {
38 | return type;
39 | }
40 |
41 | public void setType(String type) {
42 | this.type = type;
43 | }
44 |
45 | public List getFile() {
46 | return file;
47 | }
48 |
49 | public void setFile(List file) {
50 | this.file = file;
51 | }
52 |
53 | public String getText() {
54 | return text;
55 | }
56 |
57 | public void setText(String text) {
58 | this.text = text;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/sparkmodel/RoleContent.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sparkmodel;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | /**
6 | * 大模型会话message实体类
7 | *
8 | * @author
9 | **/
10 | public class RoleContent {
11 |
12 | private String role;
13 | private String content;
14 | @SerializedName("content_type")
15 | private String contentType;
16 |
17 | public RoleContent(Builder builder) {
18 | this.role = builder.role;
19 | this.content = builder.content;
20 | this.contentType = builder.contentType;
21 | }
22 |
23 | public RoleContent() {
24 | }
25 |
26 | public String getRole() {
27 | return role;
28 | }
29 |
30 | public void setRole(String role) {
31 | this.role = role;
32 | }
33 |
34 | public String getContent() {
35 | return content;
36 | }
37 |
38 | public void setContent(String content) {
39 | this.content = content;
40 | }
41 |
42 | public String getContentType() {
43 | return contentType;
44 | }
45 |
46 | public void setContentType(String contentType) {
47 | this.contentType = contentType;
48 | }
49 |
50 | public static Builder builder() {
51 | return new Builder();
52 | }
53 |
54 | public static final class Builder {
55 |
56 | private String role;
57 | private String content;
58 | private String contentType;
59 |
60 | private Builder() {
61 | }
62 |
63 | public RoleContent build() {
64 | return new RoleContent(this);
65 | }
66 |
67 | public Builder role(String role) {
68 | this.role = role;
69 | return this;
70 | }
71 |
72 | public Builder content(String content) {
73 | this.content = content;
74 | return this;
75 | }
76 |
77 | public Builder contentType(String contentType) {
78 | this.contentType = contentType;
79 | return this;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/sparkmodel/WebSearch.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sparkmodel;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | /**
6 | * 联网搜索工具实体类
7 | *
8 | * @author
9 | **/
10 | public class WebSearch {
11 |
12 | /**
13 | * enable:是否开启搜索功能,设置为true,
14 | * 模型会根据用户输入判断是否触发联网搜索,false则完全不触发;
15 | * 非必传,默认开启(true)
16 | */
17 | private boolean enable;
18 |
19 | /**
20 | * show_ref_label 开关控制触发联网搜索时是否返回信源信息(仅在enable为true时生效)
21 | * 如果开启,则先返回搜索结果,之后再返回模型回复内容
22 | * 非必传,默认关闭(false)
23 | */
24 | @SerializedName("show_ref_label")
25 | private boolean showRefLabel;
26 |
27 | /**
28 | * search_mode 控制联网搜索策略(仅在enable为true时生效)
29 | * normal:标准搜索模式,模型引用搜索返回的摘要内容回答问题
30 | * deep:深度搜索模式,模型引用搜索返回的全文内容,回复的更准确;同时会带来额外的token消耗(返回search_prompt字段)
31 | * 非必传,默认标准搜索(normal)
32 | */
33 | @SerializedName("search_mode")
34 | private String searchMode;
35 |
36 | public boolean isEnable() {
37 | return enable;
38 | }
39 |
40 | public void setEnable(boolean enable) {
41 | this.enable = enable;
42 | }
43 |
44 | public boolean isShowRefLabel() {
45 | return showRefLabel;
46 | }
47 |
48 | public void setShowRefLabel(boolean showRefLabel) {
49 | this.showRefLabel = showRefLabel;
50 | }
51 |
52 | public String getSearchMode() {
53 | return searchMode;
54 | }
55 |
56 | public void setSearchMode(String searchMode) {
57 | this.searchMode = searchMode;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/sparkmodel/batch/BatchListResponse.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sparkmodel.batch;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * 大模型批处理批次查询响应体
7 | *
8 | * @author
9 | **/
10 | public class BatchListResponse {
11 |
12 | /**
13 | * object : 返回类型
14 | * data : 批次集合
15 | * first_id : 第一个id
16 | * last_id : 最后一个id
17 | * has_more : 是否全部返回(取反)
18 | */
19 |
20 | private String object;
21 | private List data;
22 | private String first_id;
23 | private String last_id;
24 | private Boolean has_more;
25 |
26 | public String getObject() {
27 | return object;
28 | }
29 |
30 | public void setObject(String object) {
31 | this.object = object;
32 | }
33 |
34 | public List getData() {
35 | return data;
36 | }
37 |
38 | public void setData(List data) {
39 | this.data = data;
40 | }
41 |
42 | public String getFirstId() {
43 | return first_id;
44 | }
45 |
46 | public void setFirstId(String firstId) {
47 | this.first_id = firstId;
48 | }
49 |
50 | public String getLastId() {
51 | return last_id;
52 | }
53 |
54 | public void setLastId(String lastId) {
55 | this.last_id = lastId;
56 | }
57 |
58 | public Boolean getHasMore() {
59 | return has_more;
60 | }
61 |
62 | public void setHasMore(Boolean hasMore) {
63 | this.has_more = hasMore;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/sparkmodel/batch/DeleteResponse.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sparkmodel.batch;
2 |
3 | /**
4 | * 大模型批处理删除响应体
5 | *
6 | * @author
7 | **/
8 | public class DeleteResponse {
9 |
10 | /**
11 | * id : 文件ID
12 | * object : 文件类型
13 | * deleted : 是否删除成功
14 | */
15 |
16 | private String id;
17 | private String object;
18 | private Boolean deleted;
19 |
20 | public String getId() {
21 | return id;
22 | }
23 |
24 | public void setId(String id) {
25 | this.id = id;
26 | }
27 |
28 | public String getObject() {
29 | return object;
30 | }
31 |
32 | public void setObject(String object) {
33 | this.object = object;
34 | }
35 |
36 | public Boolean getDeleted() {
37 | return deleted;
38 | }
39 |
40 | public void setDeleted(Boolean deleted) {
41 | this.deleted = deleted;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/sparkmodel/batch/FileInfo.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sparkmodel.batch;
2 |
3 |
4 | /**
5 | * 大模型批处理文件实体类
6 | *
7 | * @author
8 | **/
9 | public class FileInfo {
10 |
11 | /**
12 | * id : 文件唯一标识符(全局唯一)格式为:file_xxxxx
13 | * object : 上传类型(扩展字段,当前仅为 file)
14 | * bytes : 文件长度(单位:Byte)
15 | * created_at : 文件创建时间
16 | * filename : 文件名
17 | * purpose : 上传文件的意图(请求参数传入值)
18 | */
19 |
20 | private String id;
21 | private String object;
22 | private Integer bytes;
23 | private Integer created_at;
24 | private String filename;
25 | private String purpose;
26 |
27 | public String getId() {
28 | return id;
29 | }
30 |
31 | public void setId(String id) {
32 | this.id = id;
33 | }
34 |
35 | public String getObject() {
36 | return object;
37 | }
38 |
39 | public void setObject(String object) {
40 | this.object = object;
41 | }
42 |
43 | public Integer getBytes() {
44 | return bytes;
45 | }
46 |
47 | public void setBytes(Integer bytes) {
48 | this.bytes = bytes;
49 | }
50 |
51 | public Integer getCreatedAt() {
52 | return created_at;
53 | }
54 |
55 | public void setCreatedAt(Integer createdAt) {
56 | this.created_at = createdAt;
57 | }
58 |
59 | public String getFilename() {
60 | return filename;
61 | }
62 |
63 | public void setFilename(String filename) {
64 | this.filename = filename;
65 | }
66 |
67 | public String getPurpose() {
68 | return purpose;
69 | }
70 |
71 | public void setPurpose(String purpose) {
72 | this.purpose = purpose;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/sparkmodel/batch/FileListResponse.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sparkmodel.batch;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * 大模型批处理查询响应体
7 | *
8 | * @author
9 | **/
10 | public class FileListResponse {
11 |
12 | /**
13 | * object : 返回类型
14 | * data : 文件集合
15 | */
16 |
17 | private String object;
18 | private List data;
19 |
20 | public String getObject() {
21 | return object;
22 | }
23 |
24 | public void setObject(String object) {
25 | this.object = object;
26 | }
27 |
28 | public List getData() {
29 | return data;
30 | }
31 |
32 | public void setData(List data) {
33 | this.data = data;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/main/java/cn/xfyun/model/sparkmodel/request/KnowledgeFileUpload.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.sparkmodel.request;
2 |
3 | import cn.xfyun.exception.BusinessException;
4 | import cn.xfyun.util.StringUtils;
5 |
6 | import java.io.File;
7 |
8 | /**
9 | * 知识库文件上传请求实体类
10 | *
11 | * @author
12 | **/
13 | public class KnowledgeFileUpload {
14 |
15 | /**
16 | * 文件对象
17 | */
18 | private File file;
19 |
20 | /**
21 | * 知识库名称
22 | */
23 | private String knowledgeName;
24 |
25 | /**
26 | * 该文件使用功能,
27 | * 目前取值:文件提取(file-extract)
28 | */
29 | private String purpose;
30 |
31 | public KnowledgeFileUpload(Builder builder) {
32 | this.file = builder.file;
33 | this.knowledgeName = builder.knowledgeName;
34 | this.purpose = builder.purpose;
35 | }
36 |
37 | public KnowledgeFileUpload() {
38 | }
39 |
40 | public File getFile() {
41 | return file;
42 | }
43 |
44 | public void setFile(File file) {
45 | this.file = file;
46 | }
47 |
48 | public String getKnowledgeName() {
49 | return knowledgeName;
50 | }
51 |
52 | public void setKnowledgeName(String knowledgeName) {
53 | this.knowledgeName = knowledgeName;
54 | }
55 |
56 | public String getPurpose() {
57 | return purpose;
58 | }
59 |
60 | public void setPurpose(String purpose) {
61 | this.purpose = purpose;
62 | }
63 |
64 | public void selfCheck() {
65 | if (StringUtils.isNullOrEmpty(knowledgeName)) {
66 | throw new BusinessException("知识库名称不能为空");
67 | } else if (null == purpose) {
68 | throw new BusinessException("purpose不能为空");
69 | } else if (null == file) {
70 | throw new BusinessException("媒体文件不能为空");
71 | }
72 | }
73 |
74 | public static Builder builder() {
75 | return new Builder();
76 | }
77 |
78 | public static final class Builder {
79 | private File file;
80 | private String knowledgeName;
81 | private String purpose = "file-extract";
82 |
83 | private Builder() {
84 | }
85 |
86 | public KnowledgeFileUpload build() {
87 | return new KnowledgeFileUpload(this);
88 | }
89 |
90 | public Builder file(File file) {
91 | this.file = file;
92 | return this;
93 | }
94 |
95 | public Builder knowledgeName(String knowledgeName) {
96 | this.knowledgeName = knowledgeName;
97 | return this;
98 | }
99 |
100 | public Builder purpose(String purpose) {
101 | this.purpose = purpose;
102 | return this;
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/websdk-java-spark/src/test/resources/audio/16k_10.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-spark/src/test/resources/audio/16k_10.pcm
--------------------------------------------------------------------------------
/websdk-java-spark/src/test/resources/audio/20210329145025829.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-spark/src/test/resources/audio/20210329145025829.mp3
--------------------------------------------------------------------------------
/websdk-java-spark/src/test/resources/document/aipptv2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-spark/src/test/resources/document/aipptv2.pdf
--------------------------------------------------------------------------------
/websdk-java-spark/src/test/resources/document/batch.jsonl:
--------------------------------------------------------------------------------
1 | {"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "4.0Ultra", "messages": [{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "1+1=?"}],"max_tokens": 1000}}
--------------------------------------------------------------------------------
/websdk-java-spark/src/test/resources/image/car.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-spark/src/test/resources/image/car.jpg
--------------------------------------------------------------------------------
/websdk-java-spark/src/test/resources/image/hidream_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-spark/src/test/resources/image/hidream_1.jpg
--------------------------------------------------------------------------------
/websdk-java-spark/src/test/resources/image/hidream_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-spark/src/test/resources/image/hidream_2.jpg
--------------------------------------------------------------------------------
/websdk-java-spark/src/test/resources/test.properties:
--------------------------------------------------------------------------------
1 | appId=
2 | ltpClientApiKey=
3 | saClientApiKey=
4 | textCheckClientApiKey=
5 | textCheckClientApiSecret=
6 | transClientApiKey=
7 | transClientApiSecret=
8 | aiPPTClientApiKey=
9 | aiPPTClientApiSecret=
10 | oralAPPKey=
11 | oralAPPSecret=
12 | sparkIatAPPKey=
13 | sparkIatAPPSecret=
14 | maasAPPKey=
15 | maasAPPSecret=
16 | maasAPIKey=
17 | voiceCloneAPPKey=
18 | voiceCloneAPPSecret=
19 | sparkAPPKey=
20 | sparkAPPSecret=
21 | sparkAPIPassword=
22 | imageGenAPPKey=
23 | imageGenAPPSecret=
24 | hidreamAPPKey=
25 | hidreamAPPSecret=
26 | imgUnderstandAPIKey=
27 | imgUnderstandAPPSecret=
28 | resumeGenClientApiKey=
29 | resumeGenClientApiSecret=
30 | sparkBatchAPIPassword=
--------------------------------------------------------------------------------
/websdk-java-speech/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | websdk-java-speech
6 | jar
7 | ${websdk-java-speech.version}
8 |
9 | websdk-java-parent
10 | cn.xfyun
11 | 2.1.2
12 | ../websdk-java-parent/pom.xml
13 |
14 |
15 |
16 |
17 | cn.xfyun
18 | websdk-java-core
19 | ${websdk-java-core.version}
20 |
21 |
22 |
23 |
24 |
25 |
26 | org.apache.maven.plugins
27 | maven-compiler-plugin
28 |
29 | 8
30 | 8
31 | UTF-8
32 |
33 |
34 |
35 | org.apache.maven.plugins
36 | maven-surefire-plugin
37 | 2.19.1
38 |
39 | true
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/common/IgrConstant.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.common;
2 |
3 | /**
4 | * @author:
5 | * @description: 性别年龄评测常量
6 | * @version: v1.0
7 | * @create: 2021-06-02 10:22
8 | **/
9 | public class IgrConstant {
10 |
11 | public static final String HOST_URL = "https://ws-api.xfyun.cn/v2/igr";
12 |
13 | /**
14 | * 首次上传
15 | */
16 | public static final int IGR_STATUS_FRAME_START = 0;
17 | /**
18 | * 中间上传
19 | */
20 | public static final int IGR_STATUS_FRAME_CONTINUE = 1;
21 | /**
22 | * 最后一次上传
23 | */
24 | public static final int IGR_STATUS_FRAME_END = 2;
25 | /**
26 | * 每一帧音频的大小,建议每 40ms 发送 1280B,大小可调整,
27 | */
28 | public static final int IGR_SIZE_FRAME = 1280;
29 | public static final int IGR_FRAME_INTERVEL = 40;
30 | public static final int CODE_STATUS_SUCCESS = 2;
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/common/IseConstant.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.common;
2 |
3 | /**
4 | * @author: flhong2
5 | * @description: 语音评测常量
6 | * @create: 2021-03-18 15:13
7 | **/
8 | public class IseConstant {
9 |
10 | public static final String HOST_URL = "https://ise-api.xfyun.cn/v2/open-ise";
11 | public static final String ISE_SUB = "ise";
12 |
13 | /**
14 | * 中文
15 | */
16 | public static final String ISE_ENT_CN = "cn_vip";
17 | /**
18 | * 英文
19 | */
20 | public static final String ISE_ENT_EN = "en_vip";
21 | /**
22 | * 首次上传
23 | */
24 | public static final int ISE_STATUS_FRAME_START = 0;
25 | /**
26 | * 中间上传
27 | */
28 | public static final int ISE_STATUS_FRAME_CONTINUE = 1;
29 | /**
30 | * 最后一次上传
31 | */
32 | public static final int ISE_STATUS_FRAME_END = 2;
33 | /**
34 | * 每一帧音频的大小,建议每 40ms 发送 1280B,大小可调整,
35 | * 但是不要超过19200B,即base64压缩后能超过26000B,否则会报错10163数据过长错误
36 | */
37 | public static final int ISE_SIZE_FRAME = 1280;
38 | public static final int ISE_FRAME_INTERVEL = 40;
39 |
40 | public static final int CODE_STATUS_SUCCESS = 2;
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/config/IseAueEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/9 14:24
7 | */
8 | public enum IseAueEnum {
9 |
10 | /**
11 | * 未压缩的 pcm 格式音频
12 | */
13 | RAW("raw"),
14 |
15 | /**
16 | * 标准开源speex
17 | */
18 | SPEEX("speex");
19 |
20 | private String value;
21 |
22 | IseAueEnum(String value) {
23 | this.value = value;
24 | }
25 |
26 | public String getValue() {
27 | return value;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/config/IseCategoryEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/9 14:29
7 | */
8 | public enum IseCategoryEnum {
9 |
10 | /**
11 | * 单字朗读,汉语专有
12 | */
13 | READ_SYLLABLE("read_syllable"),
14 |
15 | /**
16 | * 词语朗读
17 | */
18 | READ_WORD("read_word"),
19 |
20 | /**
21 | * 句子朗读
22 | */
23 | READ_SENTENCE("read_sentence"),
24 |
25 | /**
26 | * 篇章朗读
27 | */
28 | READ_CHAPTER("read_chapter");
29 |
30 | private String value;
31 |
32 | IseCategoryEnum(String value) {
33 | this.value = value;
34 | }
35 |
36 | public String getValue() {
37 | return value;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/config/IseLanguageEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/9 14:27
7 | */
8 | public enum IseLanguageEnum {
9 |
10 | /**
11 | * 英语
12 | */
13 | EN_US("en_us"),
14 |
15 | /**
16 | * 汉语
17 | */
18 | ZH_CN("zh_cn");
19 |
20 | private String value;
21 |
22 | IseLanguageEnum(String value) {
23 | this.value = value;
24 | }
25 |
26 | public String getValue() {
27 | return value;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/config/IseResultLevelEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/7/9 14:34
7 | */
8 | public enum IseResultLevelEnum {
9 |
10 | ENTIRETY("entirety"),
11 |
12 | SIMPLE("simple");
13 |
14 | private String value;
15 |
16 | IseResultLevelEnum(String value) {
17 | this.value = value;
18 | }
19 |
20 | public String getValue() {
21 | return value;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/config/LfasrFailTypeEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 语音转写任务异常类型枚举
5 | *
6 | * @author kaili23
7 | */
8 | public enum LfasrFailTypeEnum {
9 |
10 | /**
11 | * 音频正常执行
12 | */
13 | NORMAL_EXECUTION(0, "音频正常执行"),
14 |
15 | /**
16 | * 音频上传失败
17 | */
18 | UPLOAD_FAILED(1, "音频上传失败"),
19 |
20 | /**
21 | * 音频转码失败
22 | */
23 | TRANSCODING_FAILED(2, "音频转码失败"),
24 |
25 | /**
26 | * 音频识别失败
27 | */
28 | RECOGNITION_FAILED(3, "音频识别失败"),
29 |
30 | /**
31 | * 音频时长超限(最大音频时长为5小时)
32 | */
33 | DURATION_EXCEEDED(4, "音频时长超限(最大音频时长为5小时)"),
34 |
35 | /**
36 | * 音频校验失败(duration对应的值与真实音频时长不符合要求)
37 | */
38 | VALIDATION_FAILED(5, "音频校验失败(duration对应的值与真实音频时长不符合要求)"),
39 |
40 | /**
41 | * 静音文件
42 | */
43 | SILENT_FILE(6, "静音文件"),
44 |
45 | /**
46 | * 翻译失败
47 | */
48 | TRANSLATION_FAILED(7, "翻译失败"),
49 |
50 | /**
51 | * 账号无翻译权限
52 | */
53 | NO_TRANSLATION_PERMISSION(8, "账号无翻译权限"),
54 |
55 | /**
56 | * 转写质检失败
57 | */
58 | QUALITY_INSPECTION_FAILED(9, "转写质检失败"),
59 |
60 | /**
61 | * 转写质检未匹配出关键词
62 | */
63 | NO_KEYWORDS_MATCHED(10, "转写质检未匹配出关键词"),
64 |
65 | /**
66 | * 未开启质检或者翻译能力
67 | */
68 | CAPABILITY_NOT_ENABLED(11, "未开启质检或者翻译能力"),
69 |
70 | /**
71 | * 其他错误
72 | */
73 | OTHER_ERROR(99, "其他错误");
74 |
75 | private final int key;
76 | private final String value;
77 |
78 | LfasrFailTypeEnum(int key, String value) {
79 | this.key = key;
80 | this.value = value;
81 | }
82 |
83 | public int getKey() {
84 | return key;
85 | }
86 |
87 | public String getValue() {
88 | return value;
89 | }
90 |
91 | public static LfasrFailTypeEnum getEnum(int key) {
92 | for (LfasrFailTypeEnum typeEnum : LfasrFailTypeEnum.values()) {
93 | if (typeEnum.getKey() == key) {
94 | return typeEnum;
95 | }
96 | }
97 | return OTHER_ERROR;
98 | }
99 |
100 | }
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/config/LfasrOrderStatusEnum.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.config;
2 |
3 | /**
4 | * 语音转写订单状态枚举
5 | *
6 | * @author kaili23
7 | */
8 | public enum LfasrOrderStatusEnum {
9 |
10 | /**
11 | * 订单已创建
12 | */
13 | CREATED(0, "订单已创建"),
14 |
15 | /**
16 | * 订单等待中
17 | */
18 | WAITING(1, "订单等待中"),
19 |
20 | /**
21 | * 订单处理中
22 | */
23 | PROCESSING(3, "订单处理中"),
24 |
25 | /**
26 | * 订单已完成
27 | */
28 | COMPLETED(4, "订单已完成"),
29 |
30 | /**
31 | * 订单失败
32 | */
33 | FAILED(-1, "订单失败");
34 |
35 | private final int key;
36 | private final String value;
37 |
38 | LfasrOrderStatusEnum(int key, String value) {
39 | this.key = key;
40 | this.value = value;
41 | }
42 |
43 | public int getKey() {
44 | return key;
45 | }
46 |
47 | public String getValue() {
48 | return value;
49 | }
50 |
51 | public static LfasrOrderStatusEnum getEnum(int key) {
52 | for (LfasrOrderStatusEnum statusEnum : LfasrOrderStatusEnum.values()) {
53 | if (statusEnum.getKey() == key) {
54 | return statusEnum;
55 | }
56 | }
57 | return null;
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/request/iat/IatRequest.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.request.iat;
2 |
3 | import com.google.gson.JsonObject;
4 |
5 | /**
6 | * @author
7 | * @description 语音听写请求
8 | * @date 2021/3/24
9 | */
10 | public class IatRequest {
11 | /**
12 | * 公共参数,仅在握手成功后首帧请求时上传
13 | * 目前仅有app_id
14 | */
15 | private JsonObject common;
16 |
17 | /**
18 | * 业务参数,仅在握手成功后首帧请求时上传
19 | */
20 | private IatBusiness business;
21 |
22 | /**
23 | * 业务数据流参数,在握手成功后的所有请求中都需要上传,
24 | */
25 | private IatRequestData data;
26 |
27 | public JsonObject getCommon() {
28 | return common;
29 | }
30 |
31 | public void setCommon(JsonObject common) {
32 | this.common = common;
33 | }
34 |
35 | public IatBusiness getBusiness() {
36 | return business;
37 | }
38 |
39 | public void setBusiness(IatBusiness business) {
40 | this.business = business;
41 | }
42 |
43 | public IatRequestData getData() {
44 | return data;
45 | }
46 |
47 | public void setData(IatRequestData data) {
48 | this.data = data;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/request/iat/IatRequestData.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.request.iat;
2 |
3 | import cn.xfyun.api.IatClient;
4 |
5 | /**
6 | * @author
7 | * @description 语音听写请求
8 | * @date 2021/3/24
9 | */
10 | public class IatRequestData {
11 |
12 | /**
13 | * 音频的状态
14 | * 0 :第一帧音频
15 | * 1 :中间的音频
16 | * 2 :最后一帧音频,最后一帧必须要发送
17 | */
18 | private Integer status;
19 |
20 | /**
21 | * 音频的采样率支持16k和8k
22 | * 16k音频:audio/L16;rate=16000
23 | * 8k音频:audio/L16;rate=8000
24 | */
25 | private String format;
26 |
27 | /**
28 | * 音频数据格式
29 | * raw:原生音频(支持单声道的pcm)
30 | * speex:speex压缩后的音频(8k)
31 | * speex-wb:speex压缩后的音频(16k)
32 | * 请注意压缩前也必须是采样率16k或8k单声道的pcm。
33 | * lame:mp3格式(仅中文普通话和英文支持,方言及小语种暂不支持)
34 | */
35 | private String encoding;
36 |
37 | /**
38 | * 音频内容,采用base64编码
39 | */
40 | private String audio;
41 |
42 | public IatRequestData(IatClient iatClient) {
43 | this.encoding = iatClient.getEncoding();
44 | this.format = iatClient.getFormat();
45 | }
46 |
47 | public Integer getStatus() {
48 | return status;
49 | }
50 |
51 | public void setStatus(Integer status) {
52 | this.status = status;
53 | }
54 |
55 | public String getFormat() {
56 | return format;
57 | }
58 |
59 | public void setFormat(String format) {
60 | this.format = format;
61 | }
62 |
63 | public String getEncoding() {
64 | return encoding;
65 | }
66 |
67 | public void setEncoding(String encoding) {
68 | this.encoding = encoding;
69 | }
70 |
71 | public String getAudio() {
72 | return audio;
73 | }
74 |
75 | public void setAudio(String audio) {
76 | this.audio = audio;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/request/igr/IgrRequest.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.request.igr;
2 |
3 | import com.google.gson.JsonObject;
4 |
5 | /**
6 | * @author:
7 | * @description: 性别年龄识别请求体
8 | * @version: v1.0
9 | * @create: 2021-06-02 14:20
10 | **/
11 | public class IgrRequest {
12 | /**
13 | * 公共参数,仅在握手成功后首帧请求时上传
14 | * 目前仅有app_id
15 | */
16 | private JsonObject common;
17 |
18 | /**
19 | * 业务,仅在握手成功后首帧请求时上传
20 | * ent 引擎类型,目前仅支持igr
21 | * aue 音频格式
22 | * rate 音频采样率 16000/8000
23 | */
24 | private JsonObject business;
25 |
26 | /**
27 | * 业务数据流参数,在握手成功后的所有请求中都需要上传
28 | * status 音频的状态 0 :第一帧音频 1 :中间的音频 2 :最后一帧音频,最后一帧必须要发送
29 | * audio 音频的数据,需进行base64编码
30 | */
31 | private JsonObject data;
32 |
33 | public void setCommon(JsonObject common) {
34 | this.common = common;
35 | }
36 |
37 | public void setBusiness(JsonObject business) {
38 | this.business = business;
39 | }
40 |
41 | public void setData(JsonObject data) {
42 | this.data = data;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/request/ise/IseRequest.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.request.ise;
2 |
3 | import com.google.gson.JsonObject;
4 |
5 | /**
6 | * @author:
7 | * @description: 语音评测请求
8 | * @version: v1.0
9 | * @create: 2021-04-06 10:07
10 | **/
11 | public class IseRequest {
12 | /**
13 | * 公共参数,仅在握手成功后首帧请求时上传
14 | * 目前仅有app_id
15 | */
16 | private JsonObject common;
17 |
18 | /**
19 | * 业务参数,仅在握手成功后首帧请求时上传
20 | */
21 | private IseBusiness business;
22 |
23 | /**
24 | * 业务数据流参数,在握手成功后的所有请求中都需要上传,
25 | */
26 | private IseRequestData data;
27 |
28 | public JsonObject getCommon() {
29 | return common;
30 | }
31 |
32 | public void setCommon(JsonObject common) {
33 | this.common = common;
34 | }
35 |
36 | public IseBusiness getBusiness() {
37 | return business;
38 | }
39 |
40 | public void setBusiness(IseBusiness business) {
41 | this.business = business;
42 | }
43 |
44 | public IseRequestData getData() {
45 | return data;
46 | }
47 |
48 | public void setData(IseRequestData data) {
49 | this.data = data;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/request/ise/IseRequestData.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.request.ise;
2 |
3 | /**
4 | * @author:
5 | * @description:
6 | * @version: v1.0
7 | * @create: 2021-04-06 10:12
8 | **/
9 | public class IseRequestData {
10 | /**
11 | * 音频的状态
12 | * 0 :第一帧音频
13 | * 1 :中间的音频
14 | * 2 :最后一帧音频,最后一帧必须要发送
15 | */
16 | private Integer status;
17 |
18 | /**
19 | * 音频内容,采用base64编码
20 | */
21 | private String data;
22 |
23 | public Integer getStatus() {
24 | return status;
25 | }
26 |
27 | public void setStatus(Integer status) {
28 | this.status = status;
29 | }
30 |
31 | public String getData() {
32 | return data;
33 | }
34 |
35 | public void setData(String data) {
36 | this.data = data;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/request/telerobot/Callout.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.request.telerobot;
2 |
3 | /**
4 | * 直接外呼参数
5 | *
6 | * @author : jun
7 | * @date : 2021年06月16日
8 | */
9 | public class Callout {
10 |
11 | /**
12 | * 话术编号
13 | */
14 | private String robot_id;
15 | /**
16 | * 线路号码
17 | */
18 | private String line_num;
19 | /**
20 | * 外呼数据列
21 | */
22 | private String[] call_column;
23 | /**
24 | * 外呼数据行 单次上限50条
25 | */
26 | private String[][] call_list;
27 | /**
28 | * 发音人编码(非必传)
29 | */
30 | private String voice_code;
31 |
32 |
33 | public String getRobot_id() {
34 | return robot_id;
35 | }
36 |
37 | public void setRobot_id(String robot_id) {
38 | this.robot_id = robot_id;
39 | }
40 |
41 | public String getLine_num() {
42 | return line_num;
43 | }
44 |
45 | public void setLine_num(String line_num) {
46 | this.line_num = line_num;
47 | }
48 |
49 | public String[] getCall_column() {
50 | return call_column;
51 | }
52 |
53 | public void setCall_column(String[] call_column) {
54 | this.call_column = call_column;
55 | }
56 |
57 | public String getVoice_code() {
58 | return voice_code;
59 | }
60 |
61 | public void setVoice_code(String voice_code) {
62 | this.voice_code = voice_code;
63 | }
64 |
65 | public String[][] getCall_list() {
66 | return call_list;
67 | }
68 |
69 | public void setCall_list(String[][] call_list) {
70 | this.call_list = call_list;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/request/telerobot/TaskInsert.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.request.telerobot;
2 |
3 | /**
4 | * 提交任务数据
5 | *
6 | * @author : jun
7 | * @date : 2021年06月16日
8 | */
9 | public class TaskInsert {
10 |
11 | /**
12 | * 任务id
13 | */
14 | private String task_id;
15 | /**
16 | * 数据列映射
17 | */
18 | private String[] call_column;
19 | /**
20 | * 数据行 单次上限50条
21 | */
22 | private String[][] call_list;
23 |
24 |
25 | public String getTask_id() {
26 | return task_id;
27 | }
28 |
29 | public void setTask_id(String task_id) {
30 | this.task_id = task_id;
31 | }
32 |
33 | public String[] getCall_column() {
34 | return call_column;
35 | }
36 |
37 | public void setCall_column(String[] call_column) {
38 | this.call_column = call_column;
39 | }
40 |
41 | public String[][] getCall_list() {
42 | return call_list;
43 | }
44 |
45 | public void setCall_list(String[][] call_list) {
46 | this.call_list = call_list;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/request/telerobot/TaskQuery.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.request.telerobot;
2 |
3 | /**
4 | * 查询任务数据
5 | *
6 | * @author : jun
7 | * @date : 2021年06月16日
8 | */
9 | public class TaskQuery {
10 | /**
11 | * 任务id
12 | */
13 | private String task_id;
14 |
15 | /**
16 | * 开始时间
17 | */
18 | private Long time_begin;
19 | /**
20 | * 结束时间
21 | */
22 | private Long time_end;
23 |
24 | /**
25 | * 任务名称 模糊检索
26 | */
27 | private String task_name;
28 | /**
29 | * 页大小 最大值50,默认20
30 | */
31 | private Integer page_size;
32 | /**
33 | * 当前页码 从1开始
34 | */
35 | private Integer page_index;
36 |
37 | /**
38 | * 排序字段 ID:任务编号,NAME:任务名称,CREATETIME:任务创建时间,STARTTIME:任务开始时间,ENDTIME:任务结束时间
39 | */
40 | private String sort_name;
41 | /**
42 | * 排序字段方式 "ASC" 正序 "DESC" 倒序
43 | */
44 | private String sort_order;
45 |
46 | public String getTask_id() {
47 | return task_id;
48 | }
49 |
50 | public void setTask_id(String task_id) {
51 | this.task_id = task_id;
52 | }
53 |
54 | public Long getTime_begin() {
55 | return time_begin;
56 | }
57 |
58 | public void setTime_begin(Long time_begin) {
59 | this.time_begin = time_begin;
60 | }
61 |
62 | public Long getTime_end() {
63 | return time_end;
64 | }
65 |
66 | public void setTime_end(Long time_end) {
67 | this.time_end = time_end;
68 | }
69 |
70 | public String getTask_name() {
71 | return task_name;
72 | }
73 |
74 | public void setTask_name(String task_name) {
75 | this.task_name = task_name;
76 | }
77 |
78 | public Integer getPage_size() {
79 | return page_size;
80 | }
81 |
82 | public void setPage_size(Integer page_size) {
83 | this.page_size = page_size;
84 | }
85 |
86 | public Integer getPage_index() {
87 | return page_index;
88 | }
89 |
90 | public void setPage_index(Integer page_index) {
91 | this.page_index = page_index;
92 | }
93 |
94 | public String getSort_name() {
95 | return sort_name;
96 | }
97 |
98 | public void setSort_name(String sort_name) {
99 | this.sort_name = sort_name;
100 | }
101 |
102 | public String getSort_order() {
103 | return sort_order;
104 | }
105 |
106 | public void setSort_order(String sort_order) {
107 | this.sort_order = sort_order;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/iat/IatData.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.iat;
2 |
3 | /**
4 | * @author
5 | * @description 语音听写响应结果
6 | * @date 2021/3/24
7 | */
8 | public class IatData {
9 |
10 | /**
11 | * 音频的状态
12 | * 0 :第一帧音频
13 | * 1 :中间的音频
14 | * 2 :最后一帧音频,最后一帧必须要发送
15 | */
16 | private int status;
17 |
18 | /**
19 | * 听写结果
20 | */
21 | private IatResult result;
22 |
23 | public int getStatus() {
24 | return status;
25 | }
26 |
27 | public void setStatus(int status) {
28 | this.status = status;
29 | }
30 |
31 | public IatResult getResult() {
32 | return result;
33 | }
34 |
35 | public void setResult(IatResult result) {
36 | this.result = result;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/iat/IatResponse.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.iat;
2 |
3 | /**
4 | * @author
5 | * @description 语音听写响应
6 | * @date 2021/3/24
7 | */
8 | public class IatResponse {
9 | private int code;
10 | private String message;
11 | private String sid;
12 | private IatData data;
13 |
14 | public IatResponse() {
15 | }
16 |
17 | public IatResponse(int code, String message) {
18 | this.code = code;
19 | this.message = message;
20 | }
21 |
22 | public int getCode() {
23 | return code;
24 | }
25 |
26 | public void setCode(int code) {
27 | this.code = code;
28 | }
29 |
30 | public String getMessage() {
31 | return this.message;
32 | }
33 |
34 | public void setMessage(String message) {
35 | this.message = message;
36 | }
37 |
38 | public String getSid() {
39 | return sid;
40 | }
41 |
42 | public void setSid(String sid) {
43 | this.sid = sid;
44 | }
45 |
46 | public IatData getData() {
47 | return data;
48 | }
49 |
50 | public void setData(IatData data) {
51 | this.data = data;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/iat/Text.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.iat;
2 |
3 | import com.google.gson.JsonObject;
4 |
5 | import java.util.Arrays;
6 |
7 | /**
8 | * @author
9 | * @description
10 | * @date 2021/3/24
11 | */
12 | public class Text {
13 |
14 | int sn;
15 | int bg;
16 | int ed;
17 | String text;
18 | String pgs;
19 | int[] rg;
20 | boolean deleted;
21 | boolean ls;
22 | JsonObject vad;
23 |
24 | public int getSn() {
25 | return sn;
26 | }
27 |
28 | public void setSn(int sn) {
29 | this.sn = sn;
30 | }
31 |
32 | public int getBg() {
33 | return bg;
34 | }
35 |
36 | public void setBg(int bg) {
37 | this.bg = bg;
38 | }
39 |
40 | public int getEd() {
41 | return ed;
42 | }
43 |
44 | public void setEd(int ed) {
45 | this.ed = ed;
46 | }
47 |
48 | public String getText() {
49 | return text;
50 | }
51 |
52 | public void setText(String text) {
53 | this.text = text;
54 | }
55 |
56 | public String getPgs() {
57 | return pgs;
58 | }
59 |
60 | public void setPgs(String pgs) {
61 | this.pgs = pgs;
62 | }
63 |
64 | public int[] getRg() {
65 | return rg;
66 | }
67 |
68 | public void setRg(int[] rg) {
69 | this.rg = rg;
70 | }
71 |
72 | public boolean isDeleted() {
73 | return deleted;
74 | }
75 |
76 | public void setDeleted(boolean deleted) {
77 | this.deleted = deleted;
78 | }
79 |
80 | public boolean isLs() {
81 | return ls;
82 | }
83 |
84 | public void setLs(boolean ls) {
85 | this.ls = ls;
86 | }
87 |
88 | public JsonObject getVad() {
89 | return vad;
90 | }
91 |
92 | public void setVad(JsonObject vad) {
93 | this.vad = vad;
94 | }
95 |
96 | @Override
97 | public String toString() {
98 | return "Text{" +
99 | "bg=" + bg +
100 | ", ed=" + ed +
101 | ", ls=" + ls +
102 | ", sn=" + sn +
103 | ", text='" + text + '\'' +
104 | ", pgs=" + pgs +
105 | ", rg=" + Arrays.toString(rg) +
106 | ", deleted=" + deleted +
107 | ", vad=" + (vad == null ? "null" : vad.getAsJsonArray("ws").toString()) +
108 | '}';
109 | }
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/igr/IgrResponseData.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.igr;
2 |
3 | import com.google.gson.JsonObject;
4 |
5 | /**
6 | * @author:
7 | * @description: 接口返回消息体
8 | * @version: v1.0
9 | * @create: 2021-06-02 15:20
10 | **/
11 | public class IgrResponseData {
12 | private int code;
13 | private String message;
14 | private String sid;
15 | private JsonObject data;
16 |
17 | public int getCode() {
18 | return code;
19 | }
20 |
21 | public String getMessage() {
22 | return message;
23 | }
24 |
25 | public String getSid() {
26 | return sid;
27 | }
28 |
29 | public JsonObject getData() {
30 | return data;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/ise/IseResponse.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.ise;
2 |
3 | /**
4 | * @version 1.0
5 | * @author:
6 | * @description: 语音评测返回体
7 | * @create: 2021-03-17 20:58
8 | **/
9 | public class IseResponse {
10 | private int status;
11 | private String data;
12 |
13 | public int getStatus() {
14 | return status;
15 | }
16 | public String getData() {
17 | return data;
18 | }
19 |
20 | @Override
21 | public String toString() {
22 | return "IseResponse{" +
23 | "status=" + status +
24 | ", data='" + data + '\'' +
25 | '}';
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/ise/IseResponseData.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.ise;
2 |
3 | /**
4 | * @author:
5 | * @description: 接口返回消息体
6 | * @version 1.0
7 | * @create: 2021-03-22 16:25
8 | **/
9 | public class IseResponseData {
10 | private int code;
11 | private String message;
12 | private String sid;
13 | private IseResponse data;
14 | public int getCode() {
15 | return code;
16 | }
17 | public String getMessage() {
18 | return message;
19 | }
20 | public String getSid() {
21 | return sid;
22 | }
23 | public IseResponse getData() {
24 | return data;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/lfasr/LfasrTransResult.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.lfasr;
2 |
3 | import java.io.Serializable;
4 | import java.util.List;
5 |
6 | /**
7 | * 翻译结果实体类
8 | *
9 | * @author kaili23
10 | */
11 | public class LfasrTransResult implements Serializable {
12 |
13 | private static final long serialVersionUID = 1L;
14 |
15 | /**
16 | * 段落序号
17 | */
18 | private String segId;
19 |
20 | /**
21 | * 翻译结果
22 | */
23 | private String dst;
24 |
25 | /**
26 | * 开始时间
27 | */
28 | private int bg;
29 |
30 | /**
31 | * 结束时间
32 | */
33 | private int ed;
34 |
35 | /**
36 | * 标签
37 | */
38 | private List tags;
39 |
40 | /**
41 | * 角色
42 | */
43 | private List roles;
44 |
45 | public String getSegId() {
46 | return segId;
47 | }
48 |
49 | public void setSegId(String segId) {
50 | this.segId = segId;
51 | }
52 |
53 | public String getDst() {
54 | return dst;
55 | }
56 |
57 | public void setDst(String dst) {
58 | this.dst = dst;
59 | }
60 |
61 | public int getBg() {
62 | return bg;
63 | }
64 |
65 | public void setBg(int bg) {
66 | this.bg = bg;
67 | }
68 |
69 | public int getEd() {
70 | return ed;
71 | }
72 |
73 | public void setEd(int ed) {
74 | this.ed = ed;
75 | }
76 |
77 | public List getTags() {
78 | return tags;
79 | }
80 |
81 | public void setTags(List tags) {
82 | this.tags = tags;
83 | }
84 |
85 | public List getRoles() {
86 | return roles;
87 | }
88 |
89 | public void setRoles(List roles) {
90 | this.roles = roles;
91 | }
92 |
93 | @Override
94 | public String toString() {
95 | return "TransResult{" +
96 | "segId='" + segId + '\'' +
97 | ", dst='" + dst + '\'' +
98 | ", bg=" + bg +
99 | ", ed=" + ed +
100 | ", tags=" + tags +
101 | ", roles=" + roles +
102 | '}';
103 | }
104 |
105 | }
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/rtasr/RtasrResponse.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.rtasr;
2 |
3 | /**
4 | * @author mqgao
5 | * @version 1.0
6 | * @date 2021/3/23 14:08
7 | */
8 | public class RtasrResponse {
9 |
10 | private String action;
11 |
12 | private String code;
13 |
14 | private String data;
15 |
16 | private String desc;
17 |
18 | private String sid;
19 |
20 |
21 | public String getAction() {
22 | return action;
23 | }
24 |
25 | public void setAction(String action) {
26 | this.action = action;
27 | }
28 |
29 | public String getCode() {
30 | return code;
31 | }
32 |
33 | public void setCode(String code) {
34 | this.code = code;
35 | }
36 |
37 | public String getData() {
38 | return data;
39 | }
40 |
41 | public void setData(String data) {
42 | this.data = data;
43 | }
44 |
45 | public String getDesc() {
46 | return desc;
47 | }
48 |
49 | public void setDesc(String desc) {
50 | this.desc = desc;
51 | }
52 |
53 | public String getSid() {
54 | return sid;
55 | }
56 |
57 | public void setSid(String sid) {
58 | this.sid = sid;
59 | }
60 |
61 | public RtasrResponse() {
62 |
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/TelerobotCallout.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot;
2 |
3 | /**
4 | * 外呼结果
5 | *
6 | * @author : jun
7 | * @date : 2021年06月21日
8 | */
9 | public class TelerobotCallout {
10 | /**
11 | * 号码总数
12 | */
13 | private Integer total;
14 | /**
15 | * 外呼数据行对应的任务数据编号,用于结果推送数据关联。
16 | */
17 | private Long[] task_data_ids;
18 |
19 | public Integer getTotal() {
20 | return total;
21 | }
22 |
23 | public void setTotal(Integer total) {
24 | this.total = total;
25 | }
26 |
27 | public Long[] getTask_data_ids() {
28 | return task_data_ids;
29 | }
30 |
31 | public void setTask_data_ids(Long[] task_data_ids) {
32 | this.task_data_ids = task_data_ids;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/TelerobotCreate.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot;
2 |
3 | /**
4 | * TODO
5 | *
6 | * @author : jun
7 | * @date : 2021年06月21日
8 | */
9 | public class TelerobotCreate {
10 | /**
11 | * 外呼任务id
12 | */
13 | private String task_id;
14 |
15 | public String getTask_id() {
16 | return task_id;
17 | }
18 |
19 | public void setTask_id(String task_id) {
20 | this.task_id = task_id;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/TelerobotQuery.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot;
2 |
3 | import cn.xfyun.model.response.telerobot.vo.Line;
4 | import cn.xfyun.model.response.telerobot.vo.Robot;
5 | import cn.xfyun.model.response.telerobot.vo.Url;
6 | import cn.xfyun.model.response.telerobot.vo.Voice;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * 查询配置
12 | *
13 | * @author : jun
14 | * @date : 2021年06月21日
15 | */
16 | public class TelerobotQuery {
17 | private List lines;
18 | private List robots;
19 | private List urls;
20 | private List voices;
21 |
22 | public List getLines() {
23 | return lines;
24 | }
25 |
26 | public void setLines(List lines) {
27 | this.lines = lines;
28 | }
29 |
30 | public List getRobots() {
31 | return robots;
32 | }
33 |
34 | public void setRobots(List robots) {
35 | this.robots = robots;
36 | }
37 |
38 | public List getUrls() {
39 | return urls;
40 | }
41 |
42 | public void setUrls(List urls) {
43 | this.urls = urls;
44 | }
45 |
46 | public List getVoices() {
47 | return voices;
48 | }
49 |
50 | public void setVoices(List voices) {
51 | this.voices = voices;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/TelerobotResponse.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot;
2 |
3 | /**
4 | * AI客服平台能力中间件 返回值类型
5 | */
6 | public class TelerobotResponse {
7 | private int code;
8 | private String message;
9 | private T result;
10 |
11 | public TelerobotResponse() {
12 | }
13 |
14 | public TelerobotResponse(int code, String message) {
15 | this.code = code;
16 | this.message = message;
17 | }
18 |
19 | public int getCode() {
20 | return code;
21 | }
22 |
23 | public void setCode(int code) {
24 | this.code = code;
25 | }
26 |
27 | public String getMessage() {
28 | return this.message;
29 | }
30 |
31 | public void setMessage(String message) {
32 | this.message = message;
33 | }
34 |
35 | public T getResult() {
36 | return result;
37 | }
38 |
39 | public void setResult(T result) {
40 | this.result = result;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/TelerobotTaskQuery.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot;
2 |
3 | import cn.xfyun.model.response.telerobot.vo.Task;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * 外呼任务查询
9 | *
10 | * @author : jun
11 | * @date : 2021年06月21日
12 | */
13 | public class TelerobotTaskQuery {
14 | /**
15 | * 总行数
16 | */
17 | private Integer total_rows;
18 | /**
19 | * 结果列表
20 | */
21 | private List rows;
22 |
23 | public Integer getTotal_rows() {
24 | return total_rows;
25 | }
26 |
27 | public void setTotal_rows(Integer total_rows) {
28 | this.total_rows = total_rows;
29 | }
30 |
31 | public List getRows() {
32 | return rows;
33 | }
34 |
35 | public void setRows(List rows) {
36 | this.rows = rows;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/TelerobotToken.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot;
2 |
3 | /**
4 | * token解析
5 | *
6 | * @author : jun
7 | * @date : 2021年06月21日
8 | */
9 | public class TelerobotToken {
10 | /**
11 | * 令牌
12 | */
13 | private String token;
14 | /**
15 | * 有效期 单位:秒。默认3600。
16 | */
17 | private Long time_expire;
18 |
19 | public String getToken() {
20 | return token;
21 | }
22 |
23 | public void setToken(String token) {
24 | this.token = token;
25 | }
26 |
27 | public Long getTime_expire() {
28 | return time_expire;
29 | }
30 |
31 | public void setTime_expire(Long time_expire) {
32 | this.time_expire = time_expire;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/vo/Line.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot.vo;
2 |
3 | /**
4 | * 线路
5 | *
6 | * @author : jun
7 | * @date : 2021年06月21日
8 | */
9 | public class Line {
10 | /**
11 | * 号码
12 | */
13 | private String line_num;
14 |
15 | /**
16 | * 并发数 此线路的最大并发数
17 | */
18 | private Integer concurrents;
19 | /**
20 | * 工作时段 电话机器人工作时段
21 | */
22 | private String[] time_work;
23 | /**
24 | * 状态 0:空闲,即该线路上没有正在执行的任务 1:任务占用中,即该线路上当前有任务正在执行。
25 | */
26 | private Integer status;
27 | /**
28 | * 申请时间 线路的对接时间。数值:毫秒时间戳
29 | */
30 | private Long time_apply;
31 | /**
32 | * 有效期 线路的有效期。单位:秒。-1:永久有效。
33 | */
34 | private Long time_expire;
35 |
36 |
37 | public String getLine_num() {
38 | return line_num;
39 | }
40 |
41 | public void setLine_num(String line_num) {
42 | this.line_num = line_num;
43 | }
44 |
45 | public Integer getConcurrents() {
46 | return concurrents;
47 | }
48 |
49 | public void setConcurrents(Integer concurrents) {
50 | this.concurrents = concurrents;
51 | }
52 |
53 | public String[] getTime_work() {
54 | return time_work;
55 | }
56 |
57 | public void setTime_work(String[] time_work) {
58 | this.time_work = time_work;
59 | }
60 |
61 | public Integer getStatus() {
62 | return status;
63 | }
64 |
65 | public void setStatus(Integer status) {
66 | this.status = status;
67 | }
68 |
69 | public Long getTime_apply() {
70 | return time_apply;
71 | }
72 |
73 | public void setTime_apply(Long time_apply) {
74 | this.time_apply = time_apply;
75 | }
76 |
77 | public Long getTime_expire() {
78 | return time_expire;
79 | }
80 |
81 | public void setTime_expire(Long time_expire) {
82 | this.time_expire = time_expire;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/vo/Robot.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot.vo;
2 |
3 | /**
4 | * 话术
5 | *
6 | * @author : jun
7 | * @date : 2021年06月21日
8 | */
9 | public class Robot {
10 | /**
11 | * 话术编号
12 | */
13 | private String robot_id;
14 | /**
15 | * 话术名称
16 | */
17 | private String robot_name;
18 | /**
19 | * 外呼数据列模板 第一列必须是客户手机号,其他列是话术动态信息。
20 | */
21 | private String[] call_column;
22 | /**
23 | * 话术状态 当前已创建的话术库状态。 1:审核中,2:未通过,3:待发布,4:已发布。
24 | */
25 | private Integer status;
26 | /**
27 | * 话术类型 1:普通话术,2:动态话术。
28 | * 其中动态话术是指包含多个话术组,能够实现动态跳转,动态话术适用于业务模式比较大流程比较复杂的情况,
29 | * 划分成多个子流程后,一方面管理维护容易,另外一方面可以复用。详细请登录后台管理平台话术库中体验。
30 | */
31 | private Integer type;
32 | /**
33 | * 删除标记 0:未删除,1:已删除。
34 | */
35 | private Integer deleted;
36 | /**
37 | * 话术创建时间 毫秒时间戳
38 | */
39 | private Long time_create;
40 | /**
41 | * 话术更新时间 毫秒时间戳
42 | */
43 | private Long time_update;
44 |
45 |
46 | public void setRobot_id(String robot_id) {
47 | this.robot_id = robot_id;
48 | }
49 |
50 | public void setRobot_name(String robot_name) {
51 | this.robot_name = robot_name;
52 | }
53 |
54 | public void setCall_column(String[] call_column) {
55 | this.call_column = call_column;
56 | }
57 |
58 | public void setStatus(Integer status) {
59 | this.status = status;
60 | }
61 |
62 | public void setType(Integer type) {
63 | this.type = type;
64 | }
65 |
66 | public void setDeleted(Integer deleted) {
67 | this.deleted = deleted;
68 | }
69 |
70 | public void setTime_create(Long time_create) {
71 | this.time_create = time_create;
72 | }
73 |
74 | public void setTime_update(Long time_update) {
75 | this.time_update = time_update;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/vo/Task.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot.vo;
2 |
3 | /**
4 | * 外呼任务
5 | *
6 | * @author : jun
7 | * @date : 2021年06月21日
8 | */
9 | public class Task {
10 | /**
11 | * 外呼任务id
12 | */
13 | private String task_id;
14 | /**
15 | * 任务名称
16 | */
17 | private String task_name;
18 | /**
19 | * 任务状态 0:新建,1:启动,2:运行,3:暂停,4:完成
20 | */
21 | private Integer status;
22 | /**
23 | * 任务类型 0:普通任务,2:任务池
24 | */
25 | private Integer task_type;
26 | /**
27 | * 删除标志 1:删除,0:正常
28 | */
29 | private String deleted;
30 | /**
31 | * 运行开始时间 毫秒时间戳
32 | */
33 | private Long time_task_start;
34 | /**
35 | * (仅限普通任务) 运行结束时间 毫秒时间戳
36 | */
37 | private Long time_task_finish;
38 | /**
39 | * 已呼叫次数
40 | */
41 | private Integer process_count;
42 | /**
43 | * 已呼叫号码数
44 | */
45 | private Integer process_tel_count;
46 | /**
47 | * 已接通量
48 | */
49 | private Integer process_through_count;
50 | /**
51 | * 当前接通率
52 | */
53 | private Double process_through_rate;
54 | /**
55 | * 任务号码量
56 | */
57 | private Integer count_tel;
58 | /**
59 | * (仅限普通任务) 任务已重试次数
60 | */
61 | private Integer count_recalled;
62 | /**
63 | * (仅限普通任务) 预设开始时间
64 | */
65 | private Long time_task_estimate_begin;
66 | /**
67 | * (仅限普通任务) 预设结束时间
68 | */
69 | private Long time_task_estimate_end;
70 | /**
71 | * (仅限普通任务) 线路号码
72 | */
73 | private String line_num;
74 | /**
75 | * (仅限普通任务) 话术id
76 | */
77 | private String robot_id;
78 | /**
79 | * (仅限普通任务) 话术名称
80 | */
81 | private String robot_name;
82 | /**
83 | * (仅限普通任务) 发音人编码
84 | */
85 | private String voice_code;
86 | /**
87 | * (仅限普通任务) 发音人语速,默认为1
88 | */
89 | private String voice_speed;
90 | /**
91 | * (仅限普通任务) 预设任务重试次数
92 | */
93 | private String count_max_recall;
94 | /**
95 | * (仅限普通任务) 预设重试外呼等待时间 单位:秒。
96 | */
97 | private String time_recall_wait;
98 | /**
99 | * (仅限普通任务) 预设外呼时间段
100 | */
101 | private String time_range;
102 | /**
103 | * (仅限普通任务) 预设推送意向度门限
104 | */
105 | private String intention_push;
106 | }
107 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/vo/Url.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot.vo;
2 |
3 | /**
4 | * 接口
5 | *
6 | * @author : jun
7 | * @date : 2021年06月21日
8 | */
9 | public class Url {
10 |
11 | /**
12 | * 接口URL 应用方提供给平台回调的接口服务url地址,用于结果数据推送和呼入话术上下文动态数据获取(可选)。
13 | */
14 | private String url;
15 | /**
16 | * 接口模块 详见结果数据推送 和 呼入话术上下文动态数据获取 中的接口模块名称。
17 | */
18 | private String url_module;
19 | }
20 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/main/java/cn/xfyun/model/response/telerobot/vo/Voice.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.model.response.telerobot.vo;
2 |
3 |
4 | /**
5 | * 发音人
6 | *
7 | * @author : jun
8 | * @date : 2021年06月21日
9 | */
10 | public class Voice {
11 | /**
12 | * 发音人编码 见【常用发音人清单】
13 | */
14 | private String voice_code;
15 |
16 | /**
17 | * 发音人名称 见【常用发音人清单】
18 | */
19 | private String voice_name;
20 |
21 | public void setVoice_code(String voice_code) {
22 | this.voice_code = voice_code;
23 | }
24 |
25 | public void setVoice_name(String voice_name) {
26 | this.voice_name = voice_name;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/java/cn/xfyun/api/QbhClientTest.java:
--------------------------------------------------------------------------------
1 | package cn.xfyun.api;
2 |
3 | import config.PropertiesConfig;
4 | import cn.xfyun.exception.HttpException;
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.powermock.core.classloader.annotations.PowerMockIgnore;
9 | import org.powermock.core.classloader.annotations.PrepareForTest;
10 | import org.powermock.modules.junit4.PowerMockRunner;
11 |
12 | import java.io.*;
13 |
14 | /**
15 | * @author:
16 | * @description: 歌曲识别测试
17 | * @version: v1.0
18 | * @create: 2021-06-04 11:02
19 | **/
20 | @RunWith(PowerMockRunner.class)
21 | @PrepareForTest({IatClient.class})
22 | @PowerMockIgnore({"cn.xfyun.util.HttpConnector", "javax.crypto.*", "javax.net.ssl.*"})
23 | public class QbhClientTest {
24 |
25 | private static final String appId = PropertiesConfig.getAppId();
26 | private static final String apiKey = PropertiesConfig.getQbhClientApiKey();
27 | String filePath = "src/test/resources/audio/audio_qbh.wav";
28 |
29 | @Test
30 | public void defaultParamTest() {
31 | QbhClient qbhClient = new QbhClient.Builder(appId, apiKey)
32 | .build();
33 | Assert.assertEquals(qbhClient.getAppId(), appId);
34 | Assert.assertEquals(qbhClient.getApiKey(), apiKey);
35 | Assert.assertEquals(qbhClient.getAue(), "raw");
36 | Assert.assertEquals(qbhClient.getEngineType(), "afs");
37 | Assert.assertEquals(qbhClient.getSampleRate(), "16000");
38 |
39 | }
40 |
41 | @Test
42 | public void testParamBuild() {
43 | QbhClient qbhClient = new QbhClient
44 | .Builder(appId, apiKey)
45 | .aue("aac")
46 | .engineType("afs")
47 | .sampleRate("8000")
48 | .build();
49 |
50 | Assert.assertEquals(qbhClient.getAppId(), appId);
51 | Assert.assertEquals(qbhClient.getApiKey(), apiKey);
52 | Assert.assertEquals(qbhClient.getAue(), "aac");
53 | Assert.assertEquals(qbhClient.getEngineType(), "afs");
54 | Assert.assertEquals(qbhClient.getSampleRate(), "8000");
55 |
56 | }
57 |
58 | @Test
59 | public void testSuccessByBytes() throws IOException, HttpException {
60 | QbhClient qbhClient = new QbhClient
61 | .Builder(appId, apiKey)
62 | .build();
63 |
64 | InputStream inputStream = new FileInputStream(new File(filePath));
65 | byte[] buffer = new byte[102400];
66 | inputStream.read(buffer);
67 | String result = qbhClient.send(buffer);
68 | System.out.println("返回结果: " + result);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/java/cn/xfyun/service/IatSendTaskTest.java:
--------------------------------------------------------------------------------
1 | //package cn.xfyun.service;
2 | //
3 | //import cn.xfyun.service.iat.IatSendTask;
4 | //import cn.xfyun.api.IatClient;
5 | //import org.junit.Test;
6 | //
7 | //import java.net.MalformedURLException;
8 | //import java.security.SignatureException;
9 | //
10 | ///**
11 | // * @author
12 | // * @description
13 | // * @date 2021/3/31
14 | // */
15 | //public class IatSendTaskTest {
16 | // private String appId = "";
17 | // private String apiKey = "";
18 | // private String secretKey = "";
19 | //
20 | // @Test
21 | // public void testSendTask() throws MalformedURLException, SignatureException {
22 | // IatClient iatClient = new IatClient.Builder()
23 | // .signature(appId, apiKey, secretKey)
24 | // .build();
25 | // IatSendTask iatSendTask = new IatSendTask();
26 | // new IatSendTask.Builder()
27 | // .webSocketClient(iatClient)
28 | // .build(iatSendTask);
29 | //
30 | // String content = "test";
31 | // byte[] bytes = content.getBytes();
32 | //
33 | // // 第一帧
34 | // String result = iatSendTask.businessDataProcess(bytes, false);
35 | // System.out.println(result);
36 | //
37 | // // 中间帧
38 | // result = iatSendTask.businessDataProcess(bytes, false);
39 | // System.out.println(result);
40 | //
41 | // //最后一帧
42 | // result = iatSendTask.businessDataProcess(bytes, true);
43 | // System.out.println(result);
44 | //
45 | // }
46 | //}
47 |
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/16k_10.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/16k_10.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/20210329145025829.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/20210329145025829.mp3
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/20210330112033093.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/20210330112033093.mp3
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/20210330141636536.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/20210330141636536.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/audio_qbh.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/audio_qbh.wav
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/content_null.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/cn/content_null.mp3
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/luanshuo.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/cn/luanshuo.mp3
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/read_sentence_cn.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/cn/read_sentence_cn.mp3
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/read_sentence_cn.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/cn/read_sentence_cn.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/read_sentence_cn.txt:
--------------------------------------------------------------------------------
1 | 今天天气怎么样
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/read_sentence_cn.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/cn/read_sentence_cn.wav
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/read_syllable_cn.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/cn/read_syllable_cn.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/read_syllable_cn.txt:
--------------------------------------------------------------------------------
1 | 好
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/read_word_cn.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/cn/read_word_cn.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/cn/read_word_cn.txt:
--------------------------------------------------------------------------------
1 | 漂亮
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/free_reading_en.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/en/free_reading_en.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/free_reading_en.txt:
--------------------------------------------------------------------------------
1 | [topic]
2 | 1. hello
3 | 1.1. hello world
4 | [vocabulary]
5 | hello/hh ax - 'l ow | hh eh - 'l ow/
6 | world/w er r l d | w er l d/
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/oral_translation_en.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/en/oral_translation_en.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/picture_talk_en.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/en/picture_talk_en.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/read_choice_en.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/en/read_choice_en.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/read_choice_en.txt:
--------------------------------------------------------------------------------
1 | [choice]
2 | 1. Snakes.
3 | 2. Children.
4 | 3. Cats.
5 | [keywords]
6 | cats
7 | [question]
8 | What did the woman dislike?
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/read_sentence_en.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/en/read_sentence_en.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/read_sentence_en.txt:
--------------------------------------------------------------------------------
1 | [content]
2 | there was a gentleman live near my house
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/read_word_en.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/en/read_word_en.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/read_word_en.txt:
--------------------------------------------------------------------------------
1 | [word]
2 | house
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/retell_en.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/en/retell_en.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/simple_expression_en.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/en/simple_expression_en.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/en/topic_en.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/en/topic_en.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/lfasr.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/lfasr.wav
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/lfasr_max.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/lfasr_max.wav
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/audio/rtasr.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iFLYTEK-OP/websdk-java/ae9e1b3ec1870adfd331d730d128d0a99e99e076/websdk-java-speech/src/test/resources/audio/rtasr.pcm
--------------------------------------------------------------------------------
/websdk-java-speech/src/test/resources/test.properties:
--------------------------------------------------------------------------------
1 | appId=
2 | iatClientApiKey=
3 | iatClientApiSecret=
4 | igrClientApiKey=
5 | igrClientApiSecret=
6 | iseClientApiKey=
7 | iseClientApiSecret=
8 | iseHttpClientApiKey=
9 | secretKey=
10 | qbhClientApiKey=
11 | rtasrClientApiKey=
12 | ttsClientApiKey=
13 | ttsClientApiSecret=
14 | telerobotAPPKey=
15 | telerobotAPPSecret=
--------------------------------------------------------------------------------