Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTSService ts做close()后都会有抛出这个异常:TTSService - onFailurenull #6

Open
yzygenuine opened this issue Feb 17, 2025 · 6 comments

Comments

@yzygenuine
Copy link

`SSML ssml3 = SSML.builder().outputFormat(OutputFormat.audio_24khz_48kbitrate_mono_mp3)
.rate("-10%")
.synthesisText(content)
.outputFileName(fileName+"_3")
.voice(voice)
.build();
ts.sendText(ssml3);
//TODO 是否是每次都关,然后才会触发落地文件

	ts.close();
`

每次执行完TTS,TTSService ts做close()后都会有抛出这个异常,请问是什么原因导致,还是使用方式问题?

17:44:15.650 [OkHttp https://speech.platform.bing.com/...] DEBUG io.ikfly.service.TTSService - onFailurenull
java.io.EOFException: null
at okio.RealBufferedSource.require(RealBufferedSource.kt:202)
at okio.RealBufferedSource.readByte(RealBufferedSource.kt:212)
at okhttp3.internal.ws.WebSocketReader.readHeader(WebSocketReader.kt:119)
at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:102)
at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:293)
at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)
finish......

@ikfly
Copy link
Owner

ikfly commented Feb 17, 2025

这异常确实是关闭方法引起的,关闭ws太急,一些后续回调未能成功处理引发的问题,刚刚加了个循环判断,等待ws onClosed 回调成功后再结束close方法,请查看最新提交,如有更好的方法请指出,谢谢

@yzygenuine
Copy link
Author

这异常确实是关闭方法引起的,关闭ws太急,一些后续回调未能成功处理引发的问题,刚刚加了个循环判断,等待ws onClosed 回调成功后再结束close方法,请查看最新提交,如有更好的方法请指出,谢谢

感谢!
还有如果我是在线服务使用,是每次new一个TTSService ts对象,使用完再close吗?
因为我试过,如果长时间不close也是会有异常出现

@yzygenuine
Copy link
Author

这异常确实是关闭方法引起的,关闭ws太急,一些后续回调未能成功处理引发的问题,刚刚加了个循环判断,等待ws onClosed 回调成功后再结束close方法,请查看最新提交,如有更好的方法请指出,谢谢

刚测试还是最后抛了异常

20:48:56.577 [main] INFO io.ikfly.service.TTSService - 空转等待语音合成...
20:48:57.582 [main] INFO io.ikfly.service.TTSService - 空转等待语音合成...
20:48:58.588 [main] INFO io.ikfly.service.TTSService - 空转等待语音合成...
20:48:59.593 [main] INFO io.ikfly.service.TTSService - 空转等待语音合成...
20:49:00.598 [main] INFO io.ikfly.service.TTSService - 空转等待语音合成...
20:49:01.602 [main] INFO io.ikfly.service.TTSService - ws closing...
20:49:02.677 [OkHttp https://speech.platform.bing.com/...] DEBUG io.ikfly.service.TTSService - onFailure:null - null
java.io.EOFException: null
at okio.RealBufferedSource.require(RealBufferedSource.kt:202)
at okio.RealBufferedSource.readByte(RealBufferedSource.kt:212)
at okhttp3.internal.ws.WebSocketReader.readHeader(WebSocketReader.kt:119)
at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:102)
at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:293)
at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)

@ikfly
Copy link
Owner

ikfly commented Feb 18, 2025

你好,本地做了多次测试,并没有复现这个异常 onFailure:null - null
java.io.EOFException: null
我测试中会出现的异常是在循环中多次调用的时候极少概率会出现连接重置的异常:onFailure:Connection reset,没遇见过onFailure:null 的情况,有空再接着看吧,基本都是ws连接问题

@yzygenuine
Copy link
Author

你好,本地做了多次测试,并没有复现这个异常 onFailure:null - null java.io.EOFException: null 我测试中会出现的异常是在循环中多次调用的时候极少概率会出现连接重置的异常:onFailure:Connection reset,没遇见过onFailure:null 的情况,有空再接着看吧,基本都是ws连接问题

应该是我用了VPN,网络不稳定也导致了这个问题。网好的情况下是没有抛出异常

@yzygenuine
Copy link
Author

你好,本地做了多次测试,并没有复现这个异常 onFailure:null - null java.io.EOFException: null 我测试中会出现的异常是在循环中多次调用的时候极少概率会出现连接重置的异常:onFailure:Connection reset,没遇见过onFailure:null 的情况,有空再接着看吧,基本都是ws连接问题

发现还有另一个问题,抛出异常后,没法捕捉,整个进程就卡住了。

19:48:59.799 [main] INFO io.ikfly.service.TTSService - ws closing...
19:49:00.960 [OkHttp https://speech.platform.bing.com/...] DEBUG io.ikfly.service.TTSService - onFailure:null - null
java.io.EOFException: null
at okio.RealBufferedSource.require(RealBufferedSource.kt:202)
at okio.RealBufferedSource.readByte(RealBufferedSource.kt:212)
at okhttp3.internal.ws.WebSocketReader.readHeader(WebSocketReader.kt:119)
at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:102)
at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:293)
at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)

然后就卡了,进程没退出,但也没继续往后执行。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants