Browse Source

修改聊天

weicu
tanlongsheng 2 years ago
parent
commit
c62ff72ebd
  1. 2
      lib/modules/chat/controllers/chat_controller.dart
  2. 6
      lib/modules/chat/views/animated_gradient_background.dart
  3. 17
      lib/modules/chat/views/chat_view.dart
  4. 11
      local_plugins/opus/example/lib/main.dart

2
lib/modules/chat/controllers/chat_controller.dart

@ -586,6 +586,8 @@ class ChatController extends GetxController {
if (isHoldSpeak.value) return; if (isHoldSpeak.value) return;
_voiceInteractionService.pauseVoiceInteraction(); _voiceInteractionService.pauseVoiceInteraction();
// 中断当前响应
_interruptCurrentResponse("发送新消息,中断当前响应");
try { try {
final recognitionStream = await _asrService.startContinuousRecognition(); final recognitionStream = await _asrService.startContinuousRecognition();

6
lib/modules/chat/views/animated_gradient_background.dart

@ -1,7 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class AnimatedGradientBackground extends StatefulWidget { class AnimatedGradientBackground extends StatefulWidget {
const AnimatedGradientBackground({super.key}); final Widget child;
const AnimatedGradientBackground(this.child, {super.key});
@override @override
State<AnimatedGradientBackground> createState() => State<AnimatedGradientBackground> createState() =>
@ -58,8 +60,10 @@ class _AnimatedGradientBackgroundState extends State<AnimatedGradientBackground>
end: _endAnimation.value!, end: _endAnimation.value!,
), ),
), ),
child: child,
); );
}, },
child: widget.child,
); );
} }
} }

17
lib/modules/chat/views/chat_view.dart

@ -513,18 +513,23 @@ class ChatView extends GetView<ChatController> {
// 构建语音输入面板 // 构建语音输入面板
Widget _buildVoiceInputPanel(bool isDarkMode) { Widget _buildVoiceInputPanel(bool isDarkMode) {
return Container( return AnimatedGradientBackground(
decoration: BoxDecoration( SafeArea(
color: isDarkMode ? AppColors.cardBackground : Colors.white,
),
child: SafeArea(
child: Column( child: Column(
children: [ children: [
Row( Row(
children: [], children: [],
), ),
Expanded( Expanded(
child: AnimatedGradientBackground(), child: Container(
width: 100.w,
height: 100.w,
decoration: BoxDecoration(
color:
isDarkMode ? Colors.white.withOpacity(0.1) : Colors.white,
shape: BoxShape.circle,
),
),
), ),
SizedBox( SizedBox(
height: 80.h, height: 80.h,

11
local_plugins/opus/example/lib/main.dart

@ -1,6 +1,7 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:opus/opus.dart';
import '../../lib/opus.dart';
void main() { void main() {
runApp(const OpusExampleApp()); runApp(const OpusExampleApp());
@ -116,8 +117,7 @@ class _OpusExamplePageState extends State<OpusExamplePage> {
} }
_samplePcmData = Uint8List.fromList( _samplePcmData = Uint8List.fromList(
List.generate(bufferSize, (index) => byteBuffer.getUint8(index)) List.generate(bufferSize, (index) => byteBuffer.getUint8(index)));
);
setState(() { setState(() {
_statusMessage = '已创建${_samplePcmData!.length}字节测试PCM数据'; _statusMessage = '已创建${_samplePcmData!.length}字节测试PCM数据';
@ -272,6 +272,9 @@ class _OpusExamplePageState extends State<OpusExamplePage> {
String _formatBytes(Uint8List data) { String _formatBytes(Uint8List data) {
final length = data.length > 16 ? 16 : data.length; final length = data.length > 16 ? 16 : data.length;
return data.sublist(0, length).map((e) => e.toRadixString(16).padLeft(2, '0')).join(' '); return data
.sublist(0, length)
.map((e) => e.toRadixString(16).padLeft(2, '0'))
.join(' ');
} }
} }
Loading…
Cancel
Save