()
| 14 | public class QwenASRUsage { |
| 15 | private static final String modelName = "qwen3-asr-flash"; |
| 16 | public static void streamCall() |
| 17 | throws ApiException, NoApiKeyException, UploadFileException { |
| 18 | MultiModalConversation conv = new MultiModalConversation(); |
| 19 | // must create mutable map. |
| 20 | MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue()) |
| 21 | .content(Arrays.asList(new HashMap<String, Object>(){{put("audio", "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/welcome.mp3");}} |
| 22 | )).build(); |
| 23 | MultiModalConversationParam param = MultiModalConversationParam.builder() |
| 24 | .model(modelName) |
| 25 | .message(userMessage) |
| 26 | .parameter("asr_options", new HashMap<String, Object>(){{put("enable_lid", true); put("language", "zh");}}) |
| 27 | .incrementalOutput(true) |
| 28 | .build(); |
| 29 | Flowable<MultiModalConversationResult> result = conv.streamCall(param); |
| 30 | result.blockingForEach(item -> { |
| 31 | if (item.getOutput() == null) { |
| 32 | return; |
| 33 | } |
| 34 | try { |
| 35 | System.out.println(item.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text")); |
| 36 | } catch (Exception e){ |
| 37 | System.exit(0); |
| 38 | } |
| 39 | }); |
| 40 | } |
| 41 | public static void main(String[] args) { |
| 42 | try { |
| 43 | streamCall(); |
no test coverage detected