|
|
|
@ -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') |
|
|
|
|
|
|
|
|