|
22 | 22 | import com.ke.bella.openapi.protocol.log.EndpointLogger; |
23 | 23 | import com.ke.bella.openapi.protocol.realtime.RealTimeAdaptor; |
24 | 24 | import com.ke.bella.openapi.protocol.realtime.RealTimeHandler; |
| 25 | +import com.ke.bella.openapi.protocol.speaker.SpeakerEmbeddingAdaptor; |
| 26 | +import com.ke.bella.openapi.protocol.speaker.SpeakerEmbeddingProperty; |
| 27 | +import com.ke.bella.openapi.protocol.speaker.SpeakerEmbeddingRequest; |
| 28 | +import com.ke.bella.openapi.protocol.speaker.SpeakerEmbeddingResponse; |
25 | 29 | import com.ke.bella.openapi.protocol.tts.TtsAdaptor; |
26 | 30 | import com.ke.bella.openapi.protocol.tts.TtsProperty; |
27 | 31 | import com.ke.bella.openapi.protocol.tts.TtsRequest; |
@@ -269,4 +273,25 @@ public FlashAsrResponse flashAsr(@RequestHeader(value = "format", defaultValue = |
269 | 273 | return adaptor.asr(request, url, property, processData); |
270 | 274 | } |
271 | 275 |
|
| 276 | + @PostMapping("/speaker/embedding") |
| 277 | + @SuppressWarnings({ "rawtypes", "unchecked" }) |
| 278 | + public SpeakerEmbeddingResponse speakerEmbedding(@RequestBody SpeakerEmbeddingRequest request) { |
| 279 | + String endpoint = EndpointContext.getRequest().getRequestURI(); |
| 280 | + String model = request.getModel(); |
| 281 | + EndpointContext.setEndpointData(endpoint, model, request); |
| 282 | + EndpointProcessData processData = EndpointContext.getProcessData(); |
| 283 | + ChannelDB channel = router.route(endpoint, model, EndpointContext.getApikey(), processData.isMock()); |
| 284 | + EndpointContext.setEndpointData(channel); |
| 285 | + if(!EndpointContext.getProcessData().isPrivate()) { |
| 286 | + limiterManager.incrementConcurrentCount(EndpointContext.getProcessData().getAkCode(), model); |
| 287 | + } |
| 288 | + String protocol = processData.getProtocol(); |
| 289 | + String url = processData.getForwardUrl(); |
| 290 | + String channelInfo = channel.getChannelInfo(); |
| 291 | + SpeakerEmbeddingAdaptor adaptor = adaptorManager.getProtocolAdaptor(endpoint, protocol, SpeakerEmbeddingAdaptor.class); |
| 292 | + SpeakerEmbeddingProperty property = (SpeakerEmbeddingProperty) JacksonUtils.deserialize(channelInfo, adaptor.getPropertyClass()); |
| 293 | + EndpointContext.setEncodingType(property.getEncodingType()); |
| 294 | + return adaptor.speakerEmbedding(request, url, property); |
| 295 | + } |
| 296 | + |
272 | 297 | } |
0 commit comments