Я хочу записать голос во время распознавания бесконечной потоковой передачи, используя java
Я пытался записать голос из другого потока, но дублирующаяся звуковая строка вызывает серьезную ошибку
это мой код записи голоса
Runnable r = new Runnable() {
@Override
public void run() {
try {
AudioFormat format = getAudioFormat();
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
// checks if system supports the data line
if (!AudioSystem.isLineSupported(info)) {
System.out.println("Line not supported");
System.exit(0);
}
line = (TargetDataLine) AudioSystem.getLine(info);
line.open(format);
line.start(); // start capturing
System.out.println("Start capturing...");
AudioInputStream ais = new AudioInputStream(line);
System.out.println("Start recording...");
// start recording
AudioSystem.write(ais, fileType, wavFile);
} catch (LineUnavailableException ex) {
ex.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
};
и это мой код настройки голосовой записи
AudioFormat getAudioFormat() {
float sampleRate = 16000;
int sampleSizeInBits = 16;
int channels = 1;
boolean signed = true;
boolean bigEndian = false;
AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits, channels, signed, bigEndian);
return format;
}
javax.sound.sampled.LineUnavailableException: строка с форматом PCM_SIGNED 16000,0 Гц, 16 бит, моно, 2 байта / кадр, младший порядок байтов не поддерживается. 11 월 10, 2019 1:44:31 오전 io.grpc.internal.ManagedChannelImpl $ 1 uncaughtException 심각: [io.grpc.internal.ManagedChannelImpl-1] Uncaught исключение в SynchronizationContext. Panic! java.util.concurrent.RejectedExecutionException: Задача java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@40f280a9 отклонено из java.util.concurrent.ScheduledThreadPoolExecutor@743ef0f [завершенные задачи 0, размер завершенных пулов = 0, размер завершенного пула = 0, размер завершенного пула 0 = размер завершенных пулов = 0, размер завершенного пула 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов 0 = размер завершенных пулов = 0tasks = 0] в java.util.concurrent.ThreadPoolExecutor $ AbortPolicy.rejectedExecution (ThreadPoolExecutor.java:2063) в java.util.concurrent.ThreadPoolExecutor.reject (ThreadPoolExecutor.java:830) в java.ExlayedExec. (ScheduledThreadPoolExecutor.java:326) в java.util.concurrent.ScheduledThreadPoolExecutor.schedule (ScheduledThreadPoolExecutor.java:533) в java.util.concurrent.ScheduledThreadPoolExecutor.execute (Scheduled.Exe.Text). reprocess (DelayedClientTransport.java:302) по адресу io.grpc.internal.ManagedChannelImpl.updateSubchannelPicker (ManagedChannelImpl.java:742) по адресу io.grpc.internal.ManagedChannelImpl.access $ 5200(ManagedChannelImpl.java! InternalSubchannel $ TransportListener.transportReady (InternalSubchannel.java:574) по адресу io.grpc.netty.shaded.io.grpc.netty.ClientTransportLifecycleManager.notifyReady (ClientTransportLifecycleManager.java:43) по адресу io.grpc.ior. netty.NettyClientHandler $ FrameListener.onSettingsRead (NettyClientHandler.java:759) по адресу io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder $ FrameReadListener.onSettingp2.jp.jpnetty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder $ PrefaceFrameListener.onSettingsRead (DefaultHttp2ConnectionDecoder.java:637) в io.grpc.netty.shaded.io.netty.handler.codec.2etogtg.http:Http2InboundFrameLogger.java:93) на io.grpc.netty.shaded.io.netty. .java: 263) по адресу io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame (DefaultHttp2FrameReader.java:160) по адресу io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger.readFrame (Http2InboundFrameLogger.java:41) при io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame (DefaultHttp2ConnectionDecoder.java:118) при io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler $ FrameDecoder.decode (Http2ConnectionHandler.java:390) по адресу io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler $ PrefaceDexth2Java: 254) в io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler.decode (Http2ConnectionHandler.java:450) в io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection (ByteToMessageDecoder.java:502) в io. grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode (ByteToMessageDecoder.java:441) в io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelMessageecodecoDeco.dedetetetete. ) в io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead (AbstractChannelHandlerContext.java:340) в io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler.unwrap (SslHH: 1429) по адресу io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler.decodeJdkCompatible (SslHandler.java:1199) по адресу io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1243) на io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection (ByteToMessageDecoder.java:502) вio.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode (ByteToMessageDecoder.java:441) по адресу io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.teeTecoDelcoMo: 278) по адресу io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead (AbstractChannelHandlerContext.java:362) по адресу io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContehan.RetaCanReteContej.in348,.java: 348) на io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead (DefaultChannelPipeline.java:965) по адресу io.grpc.netty.shaded.io.netty.channel.nio.AbstractNioByteChannel $ NioByteUnsafe.read (AbstractNioBjte 16) at.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey (NioEventLoop.java:644) в io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized.java:579) по адресу io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys (NioEventLoop.java:496) по адресу io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run (NioEventLoop.java:458) на io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor $ 5.run (SingleThreadEventExecutor.java:897) на io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run (FastThreadLocalRunnable.java:30) в java.lang.Thread.run (Thread.java:748)