(String[] args)
| 47 | private static volatile QwenLiveConversation conversation; |
| 48 | |
| 49 | public static void main(String[] args) throws Exception { |
| 50 | if (args.length < 3 || args.length > 4) { |
| 51 | System.out.println( |
| 52 | "Usage: QwenLiveUsage <workspaceId> <client|responses> <pcmFile> [backendModel]"); |
| 53 | return; |
| 54 | } |
| 55 | String workspaceId = args[0]; |
| 56 | String mode = args[1]; |
| 57 | Path pcm = Paths.get(args[2]); |
| 58 | String backendModel = args.length == 4 ? args[3] : null; |
| 59 | if (!"client".equals(mode) && !"responses".equals(mode)) { |
| 60 | System.out.println("mode must be client or responses, got: " + mode); |
| 61 | return; |
| 62 | } |
| 63 | if ("responses".equals(mode) && (backendModel == null || backendModel.trim().isEmpty())) { |
| 64 | System.out.println("responses mode requires an explicit backendModel argument."); |
| 65 | return; |
| 66 | } |
| 67 | if (!Files.isRegularFile(pcm) || Files.size(pcm) == 0) { |
| 68 | System.out.println("pcmFile must be a non-empty regular file: " + pcm); |
| 69 | return; |
| 70 | } |
| 71 | if (hasWavHeader(pcm)) { |
| 72 | System.out.println( |
| 73 | "pcmFile looks like a WAV container; strip the header and pass raw PCM16."); |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | QwenLiveDelegation delegation; |
| 78 | if ("client".equals(mode)) { |
| 79 | delegation = QwenLiveDelegation.builder().type(QwenLiveDelegationType.CLIENT).build(); |
| 80 | } else { |
| 81 | delegation = |
| 82 | QwenLiveDelegation.builder() |
| 83 | .type(QwenLiveDelegationType.RESPONSES) |
| 84 | .responses( |
| 85 | QwenLiveResponsesConfig.builder() |
| 86 | .model(backendModel) |
| 87 | .instructions("根据任务调用已配置工具并返回清晰结果") |
| 88 | .tools(Collections.emptyList()) |
| 89 | .build()) |
| 90 | .build(); |
| 91 | } |
| 92 | QwenLiveSessionConfig config = |
| 93 | QwenLiveSessionConfig.builder() |
| 94 | .model("qwen-audio-realtime") |
| 95 | .instructions("用简洁中文与用户交流") |
| 96 | .inputAudioFormat("pcm") |
| 97 | .outputAudioFormat("pcm") |
| 98 | .context( |
| 99 | QwenLiveContext.builder() |
| 100 | .compaction( |
| 101 | QwenLiveContextCompaction.builder().enabled(false).mode("local").build()) |
| 102 | .build()) |
| 103 | .delegation(delegation) |
| 104 | .build(); |
| 105 | |
| 106 | ExecutorService agentWorker = Executors.newSingleThreadExecutor(); |
nothing calls this directly
no test coverage detected