docs: 更新协议文档,删除废弃计划文档
- 更新 http-error-codes, user-points-chat-data-protocol - 更新 divination-run-protocol, profile-protocol - 删除废弃的后端和前端设计计划文档
This commit is contained in:
@@ -24,7 +24,7 @@ class DivinationRunService {
|
||||
}) async {
|
||||
final threadId = _uuidV4();
|
||||
final runId = 'run_${DateTime.now().millisecondsSinceEpoch}';
|
||||
await _api.enqueueRun(
|
||||
final accepted = await _api.enqueueRun(
|
||||
params: params,
|
||||
yaoStates: yaoStates,
|
||||
threadId: threadId,
|
||||
@@ -103,6 +103,7 @@ class DivinationRunService {
|
||||
}
|
||||
|
||||
return DivinationRunAggregate(
|
||||
threadId: accepted.threadId,
|
||||
derived: derived,
|
||||
signLevel: signLevel,
|
||||
conclusion: conclusion,
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:record/record.dart';
|
||||
|
||||
abstract class VoiceRecorder {
|
||||
Future<void> start();
|
||||
Future<String?> stop();
|
||||
Future<void> dispose();
|
||||
}
|
||||
|
||||
class RecordVoiceRecorder implements VoiceRecorder {
|
||||
RecordVoiceRecorder({AudioRecorder? recorder})
|
||||
: _recorder = recorder ?? AudioRecorder();
|
||||
|
||||
final AudioRecorder _recorder;
|
||||
String? _currentPath;
|
||||
|
||||
@override
|
||||
Future<void> start() async {
|
||||
bool hasPermission;
|
||||
try {
|
||||
hasPermission = await _recorder.hasPermission();
|
||||
} on MissingPluginException {
|
||||
throw StateError('录音能力不可用');
|
||||
}
|
||||
if (!hasPermission) {
|
||||
throw StateError('录音权限未授权');
|
||||
}
|
||||
|
||||
final fileName =
|
||||
'voice_${DateTime.now().millisecondsSinceEpoch}_${DateTime.now().microsecond}.wav';
|
||||
final path = '${Directory.systemTemp.path}/$fileName';
|
||||
_currentPath = path;
|
||||
|
||||
try {
|
||||
await _recorder.start(
|
||||
const RecordConfig(
|
||||
encoder: AudioEncoder.wav,
|
||||
sampleRate: 16000,
|
||||
numChannels: 1,
|
||||
),
|
||||
path: path,
|
||||
);
|
||||
} on MissingPluginException {
|
||||
throw StateError('录音能力不可用');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> stop() async {
|
||||
try {
|
||||
final stoppedPath = await _recorder.stop();
|
||||
return stoppedPath ?? _currentPath;
|
||||
} on MissingPluginException {
|
||||
throw StateError('录音能力不可用');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> dispose() async {
|
||||
await _recorder.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user