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