2 changed files with 33 additions and 4 deletions
@ -1,5 +1,36 @@ |
|||||
import 'package:get/get.dart'; |
import 'package:get/get.dart'; |
||||
|
import 'package:get_storage/get_storage.dart'; |
||||
|
import 'package:record/record.dart'; |
||||
|
|
||||
class VoiceReplicationController extends GetxController { |
class VoiceReplicationController extends GetxController { |
||||
|
final GetStorage _storage = GetStorage(); |
||||
|
final _record = AudioRecorder(); |
||||
|
|
||||
|
RxBool isReplicating = false.obs; |
||||
|
|
||||
RxString speakerProfileId = ''.obs; |
RxString speakerProfileId = ''.obs; |
||||
|
|
||||
|
@override |
||||
|
void onInit() { |
||||
|
super.onInit(); |
||||
|
_getDefaultData(); |
||||
|
} |
||||
|
|
||||
|
@override |
||||
|
void onClose() { |
||||
|
_record.dispose(); |
||||
|
super.onClose(); |
||||
|
} |
||||
|
|
||||
|
void _getDefaultData() { |
||||
|
isReplicating.value = _storage.read('open_voice_replication') ?? false; |
||||
|
speakerProfileId.value = _storage.read('speakerProfileId') ?? ''; |
||||
|
} |
||||
|
|
||||
|
void switchChange(bool value) { |
||||
|
isReplicating.value = value; |
||||
|
if (speakerProfileId.value.isNotEmpty) { |
||||
|
_storage.write('open_voice_replication', value); |
||||
|
} |
||||
|
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue