将调用麦克风进行录音功能放在java后端。在自己电脑上开启服务后,在别的电脑上访问的时候,调用的却是我自己电脑的麦克风,这是为什么?


            AudioFormat audioFormat = new AudioFormat(16000.0F, 16, 1, true, false);
            System.out.println("You can speak now! hahahahaha111111111111");
            DataLine.Info info = new DataLine.Info(TargetDataLine.class, audioFormat);
            System.out.println("info:"+info);
//            System.out.println("You can speak now! hahahahaha2222222222");
            TargetDataLine targetDataLine = (TargetDataLine)AudioSystem.getLine(info);
            System.out.println("You can speak now! hahahahaha2222222222");
            targetDataLine.open(audioFormat);
            System.out.println("You can speak now! hahahahaha333333333");
            targetDataLine.start();
            System.out.println("You can speak now!");
            int nByte = 0;
            final int bufSize = 3200;
            byte[] buffer = new byte[bufSize];
            while ((nByte = targetDataLine.read(buffer, 0, bufSize)) > 0) {
                // 直接发送麦克风数据流
                transcriber.send(buffer);
            }

因为服务是在你电脑上,其他电脑通过你电脑的ip访问服务时,访问的麦克风肯定也就是你电脑上的麦克风资源了。

调用麦克风必须要放在客户端,也就是别人的电脑,你放在java后端,别人调用的时候,后端调用的是服务端的麦克风,当然是你的电脑麦克风被访问了。

你应该是采用了内网穿透吧 别人通过公网访问你项目时,实际上就是通过你暴露的端口操作你的电脑。你可以把项目部署到云服务器上