MCPcopy Create free account
hub / github.com/dashscope/dashscope-sdk-java / streamCall

Method streamCall

samples/QwenASRUsage.java:16–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14public 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();

Callers 1

mainMethod · 0.95

Calls 7

streamCallMethod · 0.95
builderMethod · 0.80
getMessageMethod · 0.80
buildMethod · 0.65
getContentMethod · 0.65
getValueMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected