|
|
|
@ -262,7 +262,8 @@ class VolcanoAsrApiService implements AsrService { |
|
|
|
_hostUrl = dotenv.env['VOLCANO_HOST_URL'] ?? 'ws-api-asr.volces.com'; |
|
|
|
|
|
|
|
if (_appKey.isEmpty || _secretKey.isEmpty || _serviceId.isEmpty) { |
|
|
|
throw Exception('未找到火山语音API配置,请在.env文件中设置VOLCANO_APP_KEY, VOLCANO_SECRET_KEY和VOLCANO_SERVICE_ID'); |
|
|
|
throw Exception( |
|
|
|
'未找到火山语音API配置,请在.env文件中设置VOLCANO_APP_KEY, VOLCANO_SECRET_KEY和VOLCANO_SERVICE_ID'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -379,7 +380,7 @@ class VolcanoAsrApiService implements AsrService { |
|
|
|
|
|
|
|
// 构建请求头 |
|
|
|
final headers = <String, String>{ |
|
|
|
'User-Agent': 'Deep Voice App/1.0.0', |
|
|
|
'User-Agent': 'DeepSound App/1.0.0', |
|
|
|
}; |
|
|
|
|
|
|
|
return (url, kIsWeb ? null : headers); |
|
|
|
@ -649,7 +650,8 @@ class VolcanoAsrApiService implements AsrService { |
|
|
|
/// 处理结果消息 |
|
|
|
void _handleResultMessage(Map<String, dynamic> data) { |
|
|
|
try { |
|
|
|
final Map<String, dynamic>? result = data['result'] as Map<String, dynamic>?; |
|
|
|
final Map<String, dynamic>? result = |
|
|
|
data['result'] as Map<String, dynamic>?; |
|
|
|
if (result == null) return; |
|
|
|
|
|
|
|
final bool isEnd = result['is_end'] as bool? ?? false; |
|
|
|
@ -693,7 +695,8 @@ class VolcanoAsrApiService implements AsrService { |
|
|
|
Logger.error('语音识别开始失败: [$code] $message'); |
|
|
|
|
|
|
|
if (_recognitionController != null && !_recognitionController!.isClosed) { |
|
|
|
_recognitionController!.add(RecognitionEvent.error('开始失败: [$code] $message')); |
|
|
|
_recognitionController! |
|
|
|
.add(RecognitionEvent.error('开始失败: [$code] $message')); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -759,7 +762,9 @@ class VolcanoAsrApiService implements AsrService { |
|
|
|
} |
|
|
|
|
|
|
|
// 通知会话已结束 |
|
|
|
if (_recognitionController != null && !_recognitionController!.isClosed && !_isRecognitionEndRequested) { |
|
|
|
if (_recognitionController != null && |
|
|
|
!_recognitionController!.isClosed && |
|
|
|
!_isRecognitionEndRequested) { |
|
|
|
_recognitionController!.add(RecognitionEvent( |
|
|
|
type: RecognitionEventType.sessionStopped, |
|
|
|
)); |
|
|
|
|