Browse Source

上传播放过滤不播报内容

weicu
liwei1dao 1 year ago
parent
commit
1571d2e8d8
  1. 13
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureTtsHelper.kt

13
local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureTtsHelper.kt

@ -243,7 +243,15 @@ class AzureTtsHelper(private val context: Context) : ITtsService {
))
}
}
//清洗播报语音内容
fun cleanTextForTTS(text: String): String {
return text
.replace(Regex("https?://\\S+"), "") // 移除 URL
.replace(Regex("[\\p{Punct}]"), "") // 可选:移除标点符号(你可能不想全部移除)
.replace(Regex("[\uD83C-\uDBFF\uDC00-\uDFFF]+"), "") // 移除 emoji 表情
.replace(Regex("\\s+"), " ") // 多个空格合并
.trim()
}
/**
* 设置语音参数
*/
@ -372,8 +380,7 @@ class AzureTtsHelper(private val context: Context) : ITtsService {
}
lastSpeakTime = currentTime
val currentText = streamBuffer.toString()
val currentText = cleanTextForTTS(streamBuffer.toString())
// 定义标点符号列表
val punctuationMarks = listOf('.', '。', '!', '!', '?', '?', ';', ';', ',', ',', ':', ':', '\n')

Loading…
Cancel
Save