| 25 | private static final int FRAME_BYTES = INPUT_BYTES_PER_SECOND / 10; |
| 26 | |
| 27 | public static void main(String[] args) throws Exception { |
| 28 | if (args.length < 4 || args.length > 6) { |
| 29 | System.out.println("Usage: QwenLiveQuickStart <workspaceId> <backendModel> <input.pcm> <output.pcm> [idleSeconds=3] [timeoutSeconds=90]"); |
| 30 | System.exit(2); |
| 31 | return; |
| 32 | } |
| 33 | long idleMs = args.length > 4 ? Math.multiplyExact(Long.parseLong(args[4]), 1000) : 3000; |
| 34 | long timeoutMs = args.length > 5 ? Math.multiplyExact(Long.parseLong(args[5]), 1000) : 90000; |
| 35 | QwenLiveConnectionParam param = QwenLiveConnectionParam.builder().model("qwen-live").workspaceId(args[0]).build(); |
| 36 | try { |
| 37 | run(param, args[1], Paths.get(args[2]), Paths.get(args[3]), idleMs, timeoutMs); |
| 38 | System.out.println("Saved raw PCM: " + args[3] + " (stopped by audio idle window, not a server done event)"); |
| 39 | } catch (Exception failure) { |
| 40 | failure.printStackTrace(); |
| 41 | System.exit(1); |
| 42 | } |
| 43 | System.exit(0); |
| 44 | } |
| 45 | |
| 46 | static void run(QwenLiveConnectionParam param, String backendModel, Path input, Path output, |
| 47 | long idleMs, long timeoutMs) throws Exception { |