|
|
@ -14,7 +14,6 @@ import kotlinx.coroutines.Dispatchers.IO |
|
|
|
import kotlinx.coroutines.Job |
|
|
|
import kotlinx.coroutines.Job |
|
|
|
import kotlinx.coroutines.isActive |
|
|
|
import kotlinx.coroutines.isActive |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import org.jetbrains.anko.toast |
|
|
|
|
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
|
import java.io.FileDescriptor |
|
|
|
import java.io.FileDescriptor |
|
|
|
import java.io.FileInputStream |
|
|
|
import java.io.FileInputStream |
|
|
@ -85,14 +84,12 @@ class HttpReadAloudService : BaseReadAloudService(), |
|
|
|
if (isActive) { |
|
|
|
if (isActive) { |
|
|
|
val bytes = HttpHelper.getByteRetrofit("http://tts.baidu.com") |
|
|
|
val bytes = HttpHelper.getByteRetrofit("http://tts.baidu.com") |
|
|
|
.create(IHttpPostApi::class.java) |
|
|
|
.create(IHttpPostApi::class.java) |
|
|
|
.postMapByte( |
|
|
|
.postMapByteAsync( |
|
|
|
"http://tts.baidu.com/text2audio", |
|
|
|
"http://tts.baidu.com/text2audio", |
|
|
|
getAudioBody(contentList[index]), mapOf() |
|
|
|
getAudioBody(contentList[index]), mapOf() |
|
|
|
) |
|
|
|
).await() |
|
|
|
.execute().body() |
|
|
|
.body() |
|
|
|
if (bytes == null) { |
|
|
|
if (bytes != null && isActive) { |
|
|
|
toast("访问失败") |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val file = getSpeakFile(index) |
|
|
|
val file = getSpeakFile(index) |
|
|
|
file.writeBytes(bytes) |
|
|
|
file.writeBytes(bytes) |
|
|
|
if (index == nowSpeak) { |
|
|
|
if (index == nowSpeak) { |
|
|
|