diff --git a/lib/data/services/asr_service.dart b/lib/data/services/asr_service.dart index 9cc9a2f0e..75c2457c6 100644 --- a/lib/data/services/asr_service.dart +++ b/lib/data/services/asr_service.dart @@ -29,12 +29,6 @@ abstract class AsrService { /// 检查连续识别是否活跃 bool isContinuousRecognitionActive(); - /// 开启录音 - Future enableRecord(); - - /// 停止录音 - Future stopRecord(); - /// 释放资源 Future dispose(); } diff --git a/lib/modules/translation/controllers/translation_controller.dart b/lib/modules/translation/controllers/translation_controller.dart index 52503548f..47bfbd1b6 100644 --- a/lib/modules/translation/controllers/translation_controller.dart +++ b/lib/modules/translation/controllers/translation_controller.dart @@ -196,11 +196,11 @@ class TranslationController extends GetxController { // 切换录音功能 Future toggleisRecord() async { isRecording.toggle(); - if (isRecording.value) { - await _asrService.enableRecord(); - } else { - await _asrService.stopRecord(); - } + // if (isRecording.value) { + // await _asrService.enableRecord(); + // } else { + // await _asrService.stopRecord(); + // } } // 开始语音识别 diff --git a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt index a5db177bc..48c10d5bc 100644 --- a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt +++ b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt @@ -128,7 +128,6 @@ class AzureAsrHelper(private val context: Context) { speechRecognitionLanguage = currentLanguage } - // 优化:大幅减少静音超时时间(从800ms到300ms) setProperty("SpeechServiceConnection_EndSilenceTimeoutMs", "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 { try { - // 修复:恢复阻塞等待,确保外部音频数据完整性 val chunk = queue.take() // 检查是否是结束标志(空数组) @@ -806,7 +796,6 @@ class AzureAsrHelper(private val context: Context) { val toCopy = minOf(chunk.size, buffer.size) System.arraycopy(chunk, 0, buffer, 0, toCopy) - Log.i(tag, "外部音频:") return toCopy } catch (e: InterruptedException) { Thread.currentThread().interrupt()