|
|
@ -128,7 +128,6 @@ class AzureAsrHelper(private val context: Context) { |
|
|
speechRecognitionLanguage = currentLanguage |
|
|
speechRecognitionLanguage = currentLanguage |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 优化:大幅减少静音超时时间(从800ms到300ms) |
|
|
|
|
|
setProperty("SpeechServiceConnection_EndSilenceTimeoutMs", "300") |
|
|
setProperty("SpeechServiceConnection_EndSilenceTimeoutMs", "300") |
|
|
setProperty("Speech_SegmentationSilenceTimeoutMs", "300") |
|
|
setProperty("Speech_SegmentationSilenceTimeoutMs", "300") |
|
|
|
|
|
|
|
|
@ -256,14 +255,6 @@ class AzureAsrHelper(private val context: Context) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 强制设置单一语言(优化语言检测逻辑) |
|
|
|
|
|
*/ |
|
|
|
|
|
fun setForceLanguage(language: String) { |
|
|
|
|
|
this.currentLanguage = language |
|
|
|
|
|
this.isAutoDetectLanguage = false |
|
|
|
|
|
speechConfig?.speechRecognitionLanguage = language |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 设置外部音频流 - 使用拉流方式 |
|
|
* 设置外部音频流 - 使用拉流方式 |
|
|
@ -796,7 +787,6 @@ class AzureAsrHelper(private val context: Context) { |
|
|
*/ |
|
|
*/ |
|
|
override fun read(buffer: ByteArray): Int { |
|
|
override fun read(buffer: ByteArray): Int { |
|
|
try { |
|
|
try { |
|
|
// 修复:恢复阻塞等待,确保外部音频数据完整性 |
|
|
|
|
|
val chunk = queue.take() |
|
|
val chunk = queue.take() |
|
|
|
|
|
|
|
|
// 检查是否是结束标志(空数组) |
|
|
// 检查是否是结束标志(空数组) |
|
|
@ -806,7 +796,6 @@ class AzureAsrHelper(private val context: Context) { |
|
|
|
|
|
|
|
|
val toCopy = minOf(chunk.size, buffer.size) |
|
|
val toCopy = minOf(chunk.size, buffer.size) |
|
|
System.arraycopy(chunk, 0, buffer, 0, toCopy) |
|
|
System.arraycopy(chunk, 0, buffer, 0, toCopy) |
|
|
Log.i(tag, "外部音频:") |
|
|
|
|
|
return toCopy |
|
|
return toCopy |
|
|
} catch (e: InterruptedException) { |
|
|
} catch (e: InterruptedException) { |
|
|
Thread.currentThread().interrupt() |
|
|
Thread.currentThread().interrupt() |
|
|
|