浏览代码

上传代码

master
liwei1dao 3 个月前
父节点
当前提交
b201299ade
共有 8 个文件被更改,包括 576 次插入323 次删除
  1. +1
    -0
      lib/main.dart
  2. +165
    -0
      lib/scenes/ChartScene.dart
  3. +111
    -36
      lib/scenes/SoundRecordScene.dart
  4. +140
    -160
      lib/xunfei/task_trans.dart
  5. +18
    -13
      lib/xunfei/xunfei.dart
  6. +2
    -0
      macos/Flutter/GeneratedPluginRegistrant.swift
  7. +138
    -114
      pubspec.lock
  8. +1
    -0
      pubspec.yaml

+ 1
- 0
lib/main.dart 查看文件

@@ -1,3 +1,4 @@
import 'package:demo001/scenes/ChartScene.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';


import 'scenes/SoundRecordScene.dart'; import 'scenes/SoundRecordScene.dart';


+ 165
- 0
lib/scenes/ChartScene.dart 查看文件

@@ -0,0 +1,165 @@
import 'package:flutter/material.dart';
import 'dart:async';

class ChatScene extends StatefulWidget {
@override
_ChatSceneState createState() => _ChatSceneState();
}

class _ChatSceneState extends State<ChatScene> {
bool _isInCall = false; // 记录是否在通话状态

// 模拟的聊天消息数据,包括语音消息和文字消息
final List<Map<String, dynamic>> _messages = [
{
'type': 'audio',
'audioDuration': 5, // 音频时长 5秒
'audioUrl':
'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3',
'text': '你好,我是一个语音消息'
},
{'type': 'text', 'text': '这是一个文本消息'},
{
'type': 'audio',
'audioDuration': 8, // 音频时长 8秒
'audioUrl':
'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3',
'text': '这是另一条语音消息'
}
];

// 切换按钮状态
void _toggleCallStatus() {
setState(() {
_isInCall = !_isInCall;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Chat Scene")),
body: ListView.builder(
itemCount: _messages.length,
itemBuilder: (context, index) {
var message = _messages[index];
if (message['type'] == 'audio') {
// 语音消息
return _buildAudioMessage(message);
} else {
// 文本消息
return _buildTextMessage(message);
}
},
),
bottomNavigationBar: Padding(
padding: const EdgeInsets.all(20.0),
child: InkWell(
onTap: _toggleCallStatus, // 点击按钮时切换状态
onLongPress: () {
// 按住时切换为通话状态
_toggleCallStatus();
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30), // 圆角按钮
color: _isInCall ? Colors.red : Colors.green, // 通话状态红色,非通话状态绿色
),
padding:
EdgeInsets.symmetric(vertical: 15, horizontal: 40), // 调整按钮大小
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
_isInCall ? Icons.call_end : Icons.mic, // 图标变化
color: Colors.white,
size: 30,
),
SizedBox(width: 10),
Text(
_isInCall ? '挂断' : '开始通话', // 状态文字变化
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
],
),
),
),
),
);
}

// 构建文本消息
Widget _buildTextMessage(Map<String, dynamic> message) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
child: Align(
alignment: Alignment.centerLeft,
child: Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.blue[100],
borderRadius: BorderRadius.circular(10),
),
child: Text(
message['text'],
style: TextStyle(fontSize: 16),
),
),
),
);
}

// 构建语音消息
Widget _buildAudioMessage(Map<String, dynamic> message) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 音频时长显示
Text(
'${message['audioDuration']}秒',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
SizedBox(height: 5),
// 音频播放按钮
GestureDetector(
onTap: () {
// 这里可以实现点击播放音频的功能
print("播放音频: ${message['audioUrl']}");
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(30),
),
child: Row(
children: [
Icon(
Icons.play_arrow,
color: Colors.white,
),
SizedBox(width: 10),
Text(
'播放音频',
style: TextStyle(color: Colors.white),
),
],
),
),
),
SizedBox(height: 5),
// 文字内容
Text(
message['text'],
style: TextStyle(fontSize: 16),
),
],
),
);
}
}

+ 111
- 36
lib/scenes/SoundRecordScene.dart 查看文件

@@ -5,7 +5,7 @@ import 'package:demo001/xunfei/xunfei.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:flutter_sound/flutter_sound.dart'; import 'package:flutter_sound/flutter_sound.dart';
import 'package:audioplayers/audioplayers.dart';
import 'package:just_audio/just_audio.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';


class SoundRecordScene extends StatefulWidget { class SoundRecordScene extends StatefulWidget {
@@ -37,16 +37,15 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
Codec _audiocodec = Codec.pcm16; Codec _audiocodec = Codec.pcm16;
final int _sampleRate = 16000; // 16kHz 采样率 final int _sampleRate = 16000; // 16kHz 采样率
final int _numChannels = 1; // 单声道 final int _numChannels = 1; // 单声道
StreamController<Uint8List> _audioDataStreamController = StreamController<Uint8List>.broadcast();
//暴露音频数据流
Stream<Uint8List> get audioDataStream => _audioDataStreamController.stream;
StreamController<Uint8List> _audioDataStreamController =
StreamController<Uint8List>.broadcast();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_sdk = Xunfei(
appId: "137dc132",
apiKey: "1c1891a475e71250ecd1320303ad6545",
apiSecret: "MjZhNDA1NTI1NWZkZDQxOTMxYzMyN2Yw");
_sdk = Xunfei(
appId: "137dc132",
apiKey: "1c1891a475e71250ecd1320303ad6545",
apiSecret: "MjZhNDA1NTI1NWZkZDQxOTMxYzMyN2Yw");
_audioPlayer = AudioPlayer(); _audioPlayer = AudioPlayer();
_requestPermissions(); _requestPermissions();
_initRecorder(); _initRecorder();
@@ -55,9 +54,10 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
// 初始化录音器 // 初始化录音器
void _initRecorder() async { void _initRecorder() async {
try { try {
_soundRecorder = FlutterSoundRecorder();
_soundRecorder = FlutterSoundRecorder();
await _soundRecorder?.openRecorder(); await _soundRecorder?.openRecorder();
await _soundRecorder?.setSubscriptionDuration(const Duration(milliseconds: 100));
await _soundRecorder
?.setSubscriptionDuration(const Duration(milliseconds: 100));
//检查编解码器是否支持 //检查编解码器是否支持
if (!await _soundRecorder!.isEncoderSupported(Codec.pcm16)) { if (!await _soundRecorder!.isEncoderSupported(Codec.pcm16)) {
_log("PCM16 codec is not supported on this device."); _log("PCM16 codec is not supported on this device.");
@@ -123,10 +123,7 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
}); });
// 监听音频数据流 // 监听音频数据流
_audioDataStreamController.stream.listen((Uint8List audioData) { _audioDataStreamController.stream.listen((Uint8List audioData) {
if (_isSpeaking){
// _log('Received audio data: ${audioData.length} bytes');
_lasttran.addAudioData(List.from(audioData));
}
_processAudioData(audioData);
// 这里可以进一步处理音频数据,例如保存到文件或上传到服务器 // 这里可以进一步处理音频数据,例如保存到文件或上传到服务器
}); });
setState(() { setState(() {
@@ -139,13 +136,37 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
} }
} }


// 处理音频数据的方法
Uint8List _audioBuffer = Uint8List(0); // 缓存音频数据
void _processAudioData(Uint8List newData) {
// 将新数据追加到缓存中
_audioBuffer = Uint8List.fromList([..._audioBuffer, ...newData]);

// 每次处理一帧数据(1280 字节)
int frameSize = 1280; // 每帧的大小
while (_isSpeaking && _audioBuffer.length >= frameSize) {
// 取出一帧数据
Uint8List frame = _audioBuffer.sublist(0, frameSize);
_audioBuffer = _audioBuffer.sublist(frameSize); // 移除已处理的数据

// 将帧数据传递给任务
_lasttran.addAudioData(frame);
}

// 如果录音结束且缓存中还有剩余数据,则作为最后一帧发送
if (!_isRecording && _audioBuffer.isNotEmpty) {
_lasttran.addAudioData(_audioBuffer);
_audioBuffer = Uint8List(0); // 清空缓存
}
}

// 停止录音 // 停止录音
void _stopRecording() async { void _stopRecording() async {
try { try {
if (!_isRecording) return; // 防止重复调用 if (!_isRecording) return; // 防止重复调用
await _soundRecorder?.stopRecorder();
await _soundRecorder?.closeRecorder();
await _lasttran.close();
_lasttran.endpuish();
await _soundRecorder?.stopRecorder();
await _soundRecorder?.closeRecorder();
setState(() { setState(() {
_isRecording = false; _isRecording = false;
_volumeLevel = 0.0; //重置音量值 _volumeLevel = 0.0; //重置音量值
@@ -177,7 +198,8 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
}); });
_log('开始说话'); _log('开始说话');
_stateSpeak = 1; _stateSpeak = 1;
_lasttran = _sdk.createTransTask();
_lasttran = _sdk.createTransTask(_taskchange);
_trans.add(_lasttran);
} else if (_volumeLevel < _silenceThreshold) { } else if (_volumeLevel < _silenceThreshold) {
// 音量低于阈值 // 音量低于阈值
if (_lastBelowThresholdTime == null) { if (_lastBelowThresholdTime == null) {
@@ -192,7 +214,7 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
}); });
_log('结束说话'); _log('结束说话');
_stateSpeak = 3; _stateSpeak = 3;
_lasttran.close();
_lasttran.endpuish();
} }
} }
} else { } else {
@@ -202,6 +224,11 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
_stateSpeak = 2; _stateSpeak = 2;
} }


//任务状态变化
void _taskchange(ITaskTrans task) {
if (task.state() == 2) {}
}

// 添加日志信息并自动滚动 // 添加日志信息并自动滚动
void _log(String message) { void _log(String message) {
print("输出日志:${message}"); print("输出日志:${message}");
@@ -224,6 +251,19 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
}); });
} }


// 播放音频流
void playAudioStream(Stream<Uint8List> audioStream) async {
try {
await for (var chunk in audioStream) {
// 每次接收到音频数据块后,播放它
await _audioPlayer?.setUrl(Uri.dataFromBytes(chunk).toString());
await _audioPlayer?.play();
}
} catch (e) {
print("音频流播放错误: $e");
}
}

@override @override
void dispose() { void dispose() {
_soundRecorder?.closeRecorder(); _soundRecorder?.closeRecorder();
@@ -249,15 +289,10 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
), ),
child: ListView.builder( child: ListView.builder(
controller: _scrollController, controller: _scrollController,
itemCount: _logs.length,
itemCount: _trans.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 0.0), // 设置日志项间的垂直间距
child: ListTile(
title: Text(_logs[index]),
),
);
// 语音消息
return _buildAudioMessage(_trans[index]);
}, },
), ),
), ),
@@ -313,14 +348,54 @@ class _SoundRecordSceneState extends State<SoundRecordScene> {
); );
} }


// 根据音量值动态调整图标颜色
Color _getVolumeColor() {
if (_volumeLevel < -40) {
return Colors.green; // 低音量
} else if (_volumeLevel < -20) {
return Colors.yellow; // 中音量
} else {
return Colors.red; // 高音量
}
// 构建语音消息
Widget _buildAudioMessage(ITaskTrans msg) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 音频时长显示
Text(
'2秒',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
SizedBox(height: 5),
// 音频播放按钮
GestureDetector(
onTap: () {
// 这里可以实现点击播放音频的功能
// print("播放音频: ${message['audioUrl']}");
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(30),
),
child: Row(
children: [
Icon(
Icons.play_arrow,
color: Colors.white,
),
SizedBox(width: 10),
Text(
'播放音频',
style: TextStyle(color: Colors.white),
),
],
),
),
),
SizedBox(height: 5),
// 文字内容
Text(
msg.originalText(),
style: TextStyle(fontSize: 16),
),
],
),
);
} }
} }

+ 140
- 160
lib/xunfei/task_trans.dart 查看文件

@@ -3,13 +3,13 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:ffi'; import 'dart:ffi';
import 'dart:typed_data'; import 'dart:typed_data';

import 'package:audioplayers/audioplayers.dart';
import 'package:demo001/xunfei/utils.dart'; import 'package:demo001/xunfei/utils.dart';
import 'package:demo001/xunfei/xunfei.dart'; import 'package:demo001/xunfei/xunfei.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:web_socket_channel/web_socket_channel.dart'; import 'package:web_socket_channel/web_socket_channel.dart';


typedef TaskStateChangeEvent = void Function(ITaskTrans task); // 定义回调函数类型

class XunferTask_Result_Text_Item { class XunferTask_Result_Text_Item {
final int sn; final int sn;
final String pgs; final String pgs;
@@ -36,30 +36,29 @@ class XunferTaskTrans implements ITaskTrans {
final String requestUri = "/v1/private/simult_interpretation"; final String requestUri = "/v1/private/simult_interpretation";
late String url; late String url;
late WebSocketChannel? _channel; late WebSocketChannel? _channel;
final TaskStateChangeEvent onEvent; // 回调函数类型

bool isconnected = false; bool isconnected = false;
// 数据流控制器
final StreamController<List<int>> _streamController =
StreamController<List<int>>();
// 数据流
Stream<List<int>> get stream => _streamController.stream;
// 是否正在运行
bool _isRunning = false;
// 是否流已关闭
bool _isStreamClosed = false;
// 上传任务的 Future
Future<void>? _uploadTask;
int _state = 0; //未连接 1上传语音 2结束语音 3完成任务

//识别数据
final Map<int, XunferTask_Result_Text_Item> tests = {}; final Map<int, XunferTask_Result_Text_Item> tests = {};
final StreamController<Uint8List> _transtreamController =
// 输入音频流
final StreamController<Uint8List> _inputaudioStream =
StreamController<Uint8List>(); StreamController<Uint8List>();
bool _isPlaying = false;
//输出音频流
final StreamController<Uint8List> _outputaudioStream =
StreamController<Uint8List>();

XunferTaskTrans({ XunferTaskTrans({
required this.appId, required this.appId,
required this.apiKey, required this.apiKey,
required this.apiSecret, required this.apiSecret,
required this.onEvent,
}) { }) {
url = _geturl(); url = _geturl();
_connect(); _connect();
_startUploadTask();
_startpush();
} }


//获取链接地址 //获取链接地址
@@ -88,51 +87,10 @@ class XunferTaskTrans implements ITaskTrans {
return wsUri; return wsUri;
} }


//创建参数
Map<String, dynamic> _createParams(
String appId, int status, List<int> audio) {
final param = {
"header": {
"app_id": appId,
"status": status,
},
"parameter": {
"ist": {
"accent": "mandarin",
"domain": "ist_ed_open",
"language": "zh_cn",
"vto": 15000,
"eos": 150000
},
"streamtrans": {"from": "cn", "to": "en"},
"tts": {
"vcn": "x2_catherine",
"tts_results": {
"encoding": "raw",
"sample_rate": 16000,
"channels": 1,
"bit_depth": 16,
"frame_size": 0
}
}
},
"payload": {
"data": {
"audio": base64.encode(audio),
"encoding": "raw",
"sample_rate": 16000,
"seq": 1,
"status": status
}
}
};

return param;
}

// 创建WebSocket连接 // 创建WebSocket连接
Future<void> _connect() async { Future<void> _connect() async {
_channel = WebSocketChannel.connect(Uri.parse(url)); _channel = WebSocketChannel.connect(Uri.parse(url));
_channel?.stream.timeout(Duration(seconds: 10)); //设置超时时间
_channel?.stream.listen( _channel?.stream.listen(
(message) { (message) {
onMessage(message); onMessage(message);
@@ -144,134 +102,158 @@ class XunferTaskTrans implements ITaskTrans {
onDone: () { onDone: () {
isconnected = false; isconnected = false;
print('WebSocket 连接已关闭'); print('WebSocket 连接已关闭');
print('Close code: ${_channel?.closeCode}');
print('Close reason: ${_channel?.closeReason}');
}, },
cancelOnError: true, cancelOnError: true,
); );
isconnected = true; isconnected = true;
} }


// 启动上传任务
void _startUploadTask() {
_isRunning = true;
_uploadTask = _pushaudio();
}

// 上传音频 // 上传音频
Future<void> _pushaudio() async {
Future<void> _startpush() async {
_state = 1;
int frameSize = 1280; // 每一帧的音频大小 int frameSize = 1280; // 每一帧的音频大小
double interval = 0.04; // 发送音频间隔(单位:s) double interval = 0.04; // 发送音频间隔(单位:s)
int status = STATUS_FIRST_FRAME; // 音频的状态信息,标识音频是第一帧,还是中间帧、最后一帧 int status = STATUS_FIRST_FRAME; // 音频的状态信息,标识音频是第一帧,还是中间帧、最后一帧
int index = 0;
List<int> buffer = [];
Uint8List buffer = Uint8List(0);
try { try {
await for (List<int> frame in stream) {
// 将音频数据添加到 buffer
buffer.addAll(frame);
while (buffer.length >= frameSize) {
List<int> sendFrame = buffer.sublist(0, frameSize);
buffer = buffer.sublist(frameSize);
await for (Uint8List chunk in _inputaudioStream.stream) {
// 将新数据追加到缓存中
buffer = Uint8List.fromList([...buffer, ...chunk]);


// 判断是否读取到足够的帧
if (index + frameSize <= buffer.length) {
frame = buffer.sublist(index, index + frameSize);
index += frameSize;
} else {
frame = buffer.sublist(index);
index = buffer.length; // 结束
}
// 当缓存中的数据足够一帧时,处理并发送
while (buffer.length >= frameSize) {
Uint8List frame = buffer.sublist(0, frameSize); // 取出一帧数据
buffer = buffer.sublist(frameSize); // 移除已处理的数据


// 第一帧处理 // 第一帧处理
if (status == STATUS_FIRST_FRAME) { if (status == STATUS_FIRST_FRAME) {
String data = json.encode(_createParams(appId, status, sendFrame));
String data = json.encode(_createParams(appId, status, frame));
_channel?.sink.add(data); _channel?.sink.add(data);
print('第一帧已发送...$data');
print('第一帧已发送... $data');
status = STATUS_CONTINUE_FRAME; status = STATUS_CONTINUE_FRAME;
} }
// 中间帧处理 // 中间帧处理
else if (status == STATUS_CONTINUE_FRAME) { else if (status == STATUS_CONTINUE_FRAME) {
String data = json.encode(_createParams(appId, status, sendFrame));
_channel?.sink.add(data);
// print('中间帧已发送...');
}
// 最后一帧处理
else if (status == STATUS_LAST_FRAME) {
print('最后一帧已发送...');
String data = json.encode(_createParams(appId, status, sendFrame));
String data = json.encode(_createParams(appId, status, frame));
_channel?.sink.add(data); _channel?.sink.add(data);
break;
print('中间帧已发送... $data');
} }

// 模拟音频采样间隔 // 模拟音频采样间隔
await Future.delayed( await Future.delayed(
Duration(milliseconds: (interval * 1000).toInt()));
Duration(milliseconds: (interval * 1000).round()));
} }
} }
print('最后一帧已发送...');
status = STATUS_LAST_FRAME; status = STATUS_LAST_FRAME;
String data = json.encode(_createParams(appId, status, []));
String data = json.encode(_createParams(appId, status, buffer));
_channel?.sink.add(data); _channel?.sink.add(data);
print('最后一帧已发送... $data');
_state = 2;
} catch (e) { } catch (e) {
print("push msg: $e");
print("上传音频数据异常: $e");
} }
print('音频处理完成'); print('音频处理完成');
} }


//创建参数
Map<String, dynamic> _createParams(
String appId, int status, Uint8List audio) {
final param = {
"header": {
"app_id": appId,
"status": status,
},
"parameter": {
"ist": {
"accent": "mandarin",
"domain": "ist_ed_open",
"language": "zh_cn",
"vto": 15000,
"eos": 150000
},
"streamtrans": {"from": "cn", "to": "en"},
"tts": {
"vcn": "x2_catherine",
"tts_results": {
"encoding": "raw",
"sample_rate": 16000,
"channels": 1,
"bit_depth": 16,
"frame_size": 0
}
}
},
"payload": {
"data": {
"audio": base64.encode(audio),
"encoding": "raw",
"sample_rate": 16000,
"seq": 1,
"status": status
}
}
};

return param;
}

// 向流中添加音频数据 // 向流中添加音频数据
void addAudioData(List<int> data) {
if (!_isStreamClosed) {
_streamController.add(data);
} else {
print("Stream is closed. Cannot add more data.");
}
void addAudioData(Uint8List data) {
_inputaudioStream.add(data);
} }


//接收到翻译结果 //接收到翻译结果
Future<void> onMessage(String message) async { Future<void> onMessage(String message) async {
// try {
// print("收到的消息:$message");
// } catch (e) {
// print("receive msg, but parse exception: $e");
// }
// 对结果进行解析
var messageMap = json.decode(message);
var status = messageMap["header"]["status"];
var sid = messageMap["header"]["sid"];
// 接收到的识别结果写到文本
if (messageMap.containsKey('payload') &&
messageMap['payload'].containsKey('recognition_results')) {
var result = messageMap['payload']['recognition_results']['text'];
var asrresult = utf8.decode(base64.decode(result));
addtext(asrresult);
print("收到识别回应..${text()}");
}
if (messageMap.containsKey('payload') &&
messageMap['payload'].containsKey('tts_results')) {
var audio = messageMap['payload']['tts_results']['audio'];
var audioData = base64.decode(audio);
_transtreamController.add(audioData);
// curraudio.addAudioData(audioData);
// var file = File('output/audio/trans.pcm');
// await file.writeAsBytes(audioData, mode: FileMode.append);
}
if (status == 2) {
print("数据处理完毕,等待实时转译结束!同传后的音频文件请到output/audio/目录查看...");
await Future.delayed(Duration(seconds: 3));
close();
try {
print("收到的消息:$message");

// 对结果进行解析
var messageMap = json.decode(message);
var status = messageMap["header"]["status"];
var sid = messageMap["header"]["sid"];
// 接收到的识别结果写到文本
if (messageMap.containsKey('payload') &&
messageMap['payload'].containsKey('recognition_results')) {
var result = messageMap['payload']['recognition_results']['text'];
var asrresult = utf8.decode(base64.decode(result));
addtext(asrresult);
print("收到识别回应:${originalText()}");
}
//接收到的翻译结果写到文本
if (messageMap.containsKey('payload') &&
messageMap['payload'].containsKey('streamtrans_results')) {
var result = messageMap['payload']['streamtrans_results']['text'];
var transresult = utf8.decode(base64.decode(result));
print("收到翻译结果:$transresult");
}
if (messageMap.containsKey('payload') &&
messageMap['payload'].containsKey('tts_results')) {
var audio = messageMap['payload']['tts_results']['audio'];
var audioData = base64.decode(audio);
_outputaudioStream.add(audioData);
print("收到音频结果:${audioData.length}");
}
if (status == 2) {
print("任务已结束!");
_state = 3;
onEvent(this);
await Future.delayed(Duration(seconds: 1));
_channel?.sink.close();
}
} catch (e) {
print("接受结果异常: $e");
} }
} }


// 关闭流并停止上传任务 // 关闭流并停止上传任务
Future<void> close() async {
if (!_isStreamClosed) {
_isStreamClosed = true;
_isRunning = false; // 停止上传任务
await _streamController.close(); // 关闭流
await _uploadTask; // 等待上传任务完成
print("Stream and upload task closed.");
}
void endpuish() {
_inputaudioStream.close(); // 关闭流
} }


void addtext(String result) { void addtext(String result) {
print("添加文本结果:$result");
var resultMap = json.decode(result); var resultMap = json.decode(result);
int sn = resultMap["sn"] as int; int sn = resultMap["sn"] as int;
String pgs = resultMap["pgs"] as String; String pgs = resultMap["pgs"] as String;
@@ -283,7 +265,12 @@ class XunferTaskTrans implements ITaskTrans {
tests[sn] = item; tests[sn] = item;
} }


String text() {
int state() {
return this._state;
}

//文字
String originalText() {
if (tests.isNotEmpty) { if (tests.isNotEmpty) {
String resultStr = ""; String resultStr = "";
Map<int, XunferTask_Result_Text_Item> _results = {}; Map<int, XunferTask_Result_Text_Item> _results = {};
@@ -319,23 +306,16 @@ class XunferTaskTrans implements ITaskTrans {
return ""; return "";
} }


Future<void> audio(AudioPlayer _audioPlayer) async {
_streamController.stream.listen((List<int> data) async {
// 转换为 Uint8List
Uint8List audioBytes = Uint8List.fromList(data);
if (!_isPlaying) {
// 第一次播放
await _audioPlayer.play(BytesSource(audioBytes));
setState(() {
_isPlaying = true;
});
} else {
// 追加数据(需确认插件是否支持动态追加)
// 注意:audioplayers 插件可能不支持此操作!
await _audioPlayer.add(BytesSource(audioBytes));
}
}, onError: (error) {
print("Error in audio stream: $error");
});
String translateText() {
return "";
}

Stream<Uint8List> originalAudio() {
return _inputaudioStream.stream;
}

//音频
Stream<Uint8List> translateAudio() {
return _outputaudioStream.stream;
} }
} }

+ 18
- 13
lib/xunfei/xunfei.dart 查看文件

@@ -1,20 +1,24 @@
import 'dart:ffi';
import 'dart:async';
import 'dart:typed_data';


import 'package:demo001/xunfei/task_trans.dart'; import 'package:demo001/xunfei/task_trans.dart';
import 'package:intl/intl.dart';


abstract class ISDK { abstract class ISDK {
//创建翻译任务 //创建翻译任务
ITaskTrans createTransTask();
ITaskTrans createTransTask(TaskStateChangeEvent onEvent);
} }


abstract class ITaskTrans { abstract class ITaskTrans {
//添加音频数据
void addAudioData(List<int> data);
Future<void> close();
int state();
String originalText();
String translateText();
Stream<Uint8List> originalAudio();
Stream<Uint8List> translateAudio();
void addAudioData(Uint8List data);
void endpuish();
} }


class Xunfei implements ISDK{
class Xunfei implements ISDK {
final String appId; final String appId;
final String apiKey; final String apiKey;
final String apiSecret; final String apiSecret;
@@ -41,11 +45,12 @@ class Xunfei implements ISDK{
return _instance!; return _instance!;
} }



ITaskTrans createTransTask(){
var task = XunferTaskTrans(appId:this.appId,apiKey:this.apiKey,apiSecret:this.apiSecret);
ITaskTrans createTransTask(TaskStateChangeEvent onEvent) {
var task = XunferTaskTrans(
appId: this.appId,
apiKey: this.apiKey,
apiSecret: this.apiSecret,
onEvent: onEvent);
return task; return task;
} }


}
}

+ 2
- 0
macos/Flutter/GeneratedPluginRegistrant.swift 查看文件

@@ -7,10 +7,12 @@ import Foundation


import audio_session import audio_session
import audioplayers_darwin import audioplayers_darwin
import just_audio
import path_provider_foundation import path_provider_foundation


func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
} }

+ 138
- 114
pubspec.lock 查看文件

@@ -6,55 +6,55 @@ packages:
description: description:
name: async name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.11.0" version: "2.11.0"
audio_session: audio_session:
dependency: transitive dependency: transitive
description: description:
name: audio_session name: audio_session
sha256: b2a26ba8b7efa1790d6460e82971fde3e398cfbe2295df9dea22f3499d2c12a7
url: "https://pub.dev"
sha256: a92eed06a93721bcc8a8b57d0a623e3fb9d2e4e11cef0a08ed448c73886700b7
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.1.23"
version: "0.1.24"
audioplayers: audioplayers:
dependency: "direct main" dependency: "direct main"
description: description:
name: audioplayers name: audioplayers
sha256: c346ba5a39dc208f1bab55fc239855f573d69b0e832402114bf0b793622adc4d
url: "https://pub.dev"
sha256: "4ca57fd24594af04e93b9b9f1b1739ffb9204dbab7ce8d9b28a02f464456dcca"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "6.1.0"
version: "6.1.1"
audioplayers_android: audioplayers_android:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_android name: audioplayers_android
sha256: de576b890befe27175c2f511ba8b742bec83765fa97c3ce4282bba46212f58e4
url: "https://pub.dev"
sha256: "6c9443ce0a99b29a840f14bc2d0f7b25eb0fd946dc592a1b8a697807d5b195f3"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "5.0.0"
version: "5.0.1"
audioplayers_darwin: audioplayers_darwin:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_darwin name: audioplayers_darwin
sha256: e507887f3ff18d8e5a10a668d7bedc28206b12e10b98347797257c6ae1019c3b sha256: e507887f3ff18d8e5a10a668d7bedc28206b12e10b98347797257c6ae1019c3b
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "6.0.0" version: "6.0.0"
audioplayers_linux: audioplayers_linux:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_linux name: audioplayers_linux
sha256: "3d3d244c90436115417f170426ce768856d8fe4dfc5ed66a049d2890acfa82f9"
url: "https://pub.dev"
sha256: "9d3cb4e9533a12a462821e3f18bd282e0fa52f67ff96a06301d48dd48b82c2d1"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "4.0.0"
version: "4.0.1"
audioplayers_platform_interface: audioplayers_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_platform_interface name: audioplayers_platform_interface
sha256: "6834dd48dfb7bc6c2404998ebdd161f79cd3774a7e6779e1348d54a3bfdcfaa5" sha256: "6834dd48dfb7bc6c2404998ebdd161f79cd3774a7e6779e1348d54a3bfdcfaa5"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "7.0.0" version: "7.0.0"
audioplayers_web: audioplayers_web:
@@ -62,7 +62,7 @@ packages:
description: description:
name: audioplayers_web name: audioplayers_web
sha256: "3609bdf0e05e66a3d9750ee40b1e37f2a622c4edb796cc600b53a90a30a2ace4" sha256: "3609bdf0e05e66a3d9750ee40b1e37f2a622c4edb796cc600b53a90a30a2ace4"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "5.0.1" version: "5.0.1"
audioplayers_windows: audioplayers_windows:
@@ -70,7 +70,7 @@ packages:
description: description:
name: audioplayers_windows name: audioplayers_windows
sha256: "8605762dddba992138d476f6a0c3afd9df30ac5b96039929063eceed416795c2" sha256: "8605762dddba992138d476f6a0c3afd9df30ac5b96039929063eceed416795c2"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
boolean_selector: boolean_selector:
@@ -78,7 +78,7 @@ packages:
description: description:
name: boolean_selector name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
characters: characters:
@@ -86,7 +86,7 @@ packages:
description: description:
name: characters name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
clock: clock:
@@ -94,23 +94,23 @@ packages:
description: description:
name: clock name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev"
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.19.0"
version: "1.18.0"
crypto: crypto:
dependency: "direct main" dependency: "direct main"
description: description:
name: crypto name: crypto
sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "3.0.6" version: "3.0.6"
cupertino_icons: cupertino_icons:
@@ -118,7 +118,7 @@ packages:
description: description:
name: cupertino_icons name: cupertino_icons
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.0.8" version: "1.0.8"
etau: etau:
@@ -126,7 +126,7 @@ packages:
description: description:
name: etau name: etau
sha256: "4b43a615ecceb1de7c5a35f0a159920b4fdb8ce5a33d71d3828a31efedc67572" sha256: "4b43a615ecceb1de7c5a35f0a159920b4fdb8ce5a33d71d3828a31efedc67572"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.0.14-alpha.4" version: "0.0.14-alpha.4"
fake_async: fake_async:
@@ -134,7 +134,7 @@ packages:
description: description:
name: fake_async name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
ffi: ffi:
@@ -142,7 +142,7 @@ packages:
description: description:
name: ffi name: ffi
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.1.3" version: "2.1.3"
file: file:
@@ -150,7 +150,7 @@ packages:
description: description:
name: file name: file
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "7.0.1" version: "7.0.1"
fixnum: fixnum:
@@ -158,7 +158,7 @@ packages:
description: description:
name: fixnum name: fixnum
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
flutter: flutter:
@@ -171,33 +171,33 @@ packages:
description: description:
name: flutter_lints name: flutter_lints
sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "5.0.0" version: "5.0.0"
flutter_sound: flutter_sound:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_sound name: flutter_sound
sha256: "08e375d699d85e1a823e250d4c01596eadd92ddf8918b6825e4f23e4dd97cddb"
url: "https://pub.dev"
sha256: "223949653433bfc22749e9a9725c802733ed24e6dd51c53775716c340631dcae"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "9.19.1"
version: "9.20.5"
flutter_sound_platform_interface: flutter_sound_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: flutter_sound_platform_interface name: flutter_sound_platform_interface
sha256: "07d11ca22b1c2e3ffc7c26f0bb6d869c67cef802ff9832e91c9c5e95a3355f6d"
url: "https://pub.dev"
sha256: b85ac6eb1a482329c560e189fca75d596091c291a7d1756e0a3c9536ae87af1b
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "9.19.1"
version: "9.20.5"
flutter_sound_web: flutter_sound_web:
dependency: transitive dependency: transitive
description: description:
name: flutter_sound_web name: flutter_sound_web
sha256: "6f7a954947c18a5b2c2294ecea639c38c266430f6e30b19473191eebc7ab66bd"
url: "https://pub.dev"
sha256: dccae5647cdcac368723ff90a3fb2ec0d77b2e871ceb47b3de628806b0ca325c
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "9.19.1"
version: "9.20.5"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@@ -212,80 +212,104 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: go_router name: go_router
sha256: "7c2d40b59890a929824f30d442e810116caf5088482629c894b9e4478c67472d"
url: "https://pub.dev"
sha256: "9b736a9fa879d8ad6df7932cbdcc58237c173ab004ef90d8377923d7ad731eaa"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "14.6.3"
version: "14.7.2"
http: http:
dependency: transitive dependency: transitive
description: description:
name: http name: http
sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
name: http_parser name: http_parser
sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
url: "https://pub.dev"
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "4.1.2"
version: "4.0.2"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
name: intl name: intl
sha256: "00f33b908655e606b86d2ade4710a231b802eec6f11e87e4ea3783fd72077a50"
url: "https://pub.dev"
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.20.1"
version: "0.20.2"
js: js:
dependency: transitive dependency: transitive
description: description:
name: js name: js
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.7.1" version: "0.7.1"
just_audio:
dependency: "direct main"
description:
name: just_audio
sha256: "50ed9f0ba88012eabdef7519ba6040bdbcf6c6667ebd77736fb25c196c98c0f3"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted
version: "0.9.44"
just_audio_platform_interface:
dependency: transitive
description:
name: just_audio_platform_interface
sha256: "0243828cce503c8366cc2090cefb2b3c871aa8ed2f520670d76fd47aa1ab2790"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted
version: "4.3.0"
just_audio_web:
dependency: transitive
description:
name: just_audio_web
sha256: "9a98035b8b24b40749507687520ec5ab404e291d2b0937823ff45d92cb18d448"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted
version: "0.4.13"
leak_tracker: leak_tracker:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
url: "https://pub.dev"
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "10.0.7"
version: "10.0.5"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
url: "https://pub.dev"
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "3.0.8"
version: "3.0.5"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "3.0.1" version: "3.0.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
url: "https://pub.dev"
sha256: "3315600f3fb3b135be672bf4a178c55f274bebe368325ae18462c89ac1e3b413"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "5.1.1"
version: "5.0.0"
logger: logger:
dependency: transitive dependency: transitive
description: description:
name: logger name: logger
sha256: be4b23575aac7ebf01f225a241eb7f6b5641eeaf43c6a8613510fc2f8cf187d1 sha256: be4b23575aac7ebf01f225a241eb7f6b5641eeaf43c6a8613510fc2f8cf187d1
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.5.0" version: "2.5.0"
logging: logging:
@@ -293,7 +317,7 @@ packages:
description: description:
name: logging name: logging
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
matcher: matcher:
@@ -301,7 +325,7 @@ packages:
description: description:
name: matcher name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.12.16+1" version: "0.12.16+1"
material_color_utilities: material_color_utilities:
@@ -309,7 +333,7 @@ packages:
description: description:
name: material_color_utilities name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.11.1" version: "0.11.1"
meta: meta:
@@ -317,7 +341,7 @@ packages:
description: description:
name: meta name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0"
nested: nested:
@@ -325,7 +349,7 @@ packages:
description: description:
name: nested name: nested
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
path: path:
@@ -333,7 +357,7 @@ packages:
description: description:
name: path name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.9.0" version: "1.9.0"
path_provider: path_provider:
@@ -341,7 +365,7 @@ packages:
description: description:
name: path_provider name: path_provider
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.1.5" version: "2.1.5"
path_provider_android: path_provider_android:
@@ -349,7 +373,7 @@ packages:
description: description:
name: path_provider_android name: path_provider_android
sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2" sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.2.15" version: "2.2.15"
path_provider_foundation: path_provider_foundation:
@@ -357,7 +381,7 @@ packages:
description: description:
name: path_provider_foundation name: path_provider_foundation
sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942" sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.4.1" version: "2.4.1"
path_provider_linux: path_provider_linux:
@@ -365,7 +389,7 @@ packages:
description: description:
name: path_provider_linux name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
path_provider_platform_interface: path_provider_platform_interface:
@@ -373,7 +397,7 @@ packages:
description: description:
name: path_provider_platform_interface name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.1.2" version: "2.1.2"
path_provider_windows: path_provider_windows:
@@ -381,7 +405,7 @@ packages:
description: description:
name: path_provider_windows name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.3.0" version: "2.3.0"
permission_handler: permission_handler:
@@ -389,7 +413,7 @@ packages:
description: description:
name: permission_handler name: permission_handler
sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb" sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "11.3.1" version: "11.3.1"
permission_handler_android: permission_handler_android:
@@ -397,7 +421,7 @@ packages:
description: description:
name: permission_handler_android name: permission_handler_android
sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1" sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "12.0.13" version: "12.0.13"
permission_handler_apple: permission_handler_apple:
@@ -405,7 +429,7 @@ packages:
description: description:
name: permission_handler_apple name: permission_handler_apple
sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0 sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "9.4.5" version: "9.4.5"
permission_handler_html: permission_handler_html:
@@ -413,7 +437,7 @@ packages:
description: description:
name: permission_handler_html name: permission_handler_html
sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24" sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.1.3+5" version: "0.1.3+5"
permission_handler_platform_interface: permission_handler_platform_interface:
@@ -421,7 +445,7 @@ packages:
description: description:
name: permission_handler_platform_interface name: permission_handler_platform_interface
sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9 sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "4.2.3" version: "4.2.3"
permission_handler_windows: permission_handler_windows:
@@ -429,7 +453,7 @@ packages:
description: description:
name: permission_handler_windows name: permission_handler_windows
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e" sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.2.1" version: "0.2.1"
platform: platform:
@@ -437,7 +461,7 @@ packages:
description: description:
name: platform name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "3.1.6" version: "3.1.6"
plugin_platform_interface: plugin_platform_interface:
@@ -445,7 +469,7 @@ packages:
description: description:
name: plugin_platform_interface name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.1.8" version: "2.1.8"
provider: provider:
@@ -453,7 +477,7 @@ packages:
description: description:
name: provider name: provider
sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "6.1.2" version: "6.1.2"
recase: recase:
@@ -461,7 +485,7 @@ packages:
description: description:
name: recase name: recase
sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "4.1.0" version: "4.1.0"
rxdart: rxdart:
@@ -469,20 +493,20 @@ packages:
description: description:
name: rxdart name: rxdart
sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.28.0" version: "0.28.0"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0"
version: "0.0.99"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
sprintf: sprintf:
@@ -490,39 +514,39 @@ packages:
description: description:
name: sprintf name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "7.0.0" version: "7.0.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
url: "https://pub.dev"
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.12.0"
version: "1.11.1"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.1.2" version: "2.1.2"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
url: "https://pub.dev"
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.3.0"
version: "1.2.0"
synchronized: synchronized:
dependency: transitive dependency: transitive
description: description:
name: synchronized name: synchronized
sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225" sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "3.3.0+3" version: "3.3.0+3"
tau_web: tau_web:
@@ -530,7 +554,7 @@ packages:
description: description:
name: tau_web name: tau_web
sha256: c612cd3dcd9b7aa3472c0272bf3531fc232cd80e53ed7d7388b77dd541720cd6 sha256: c612cd3dcd9b7aa3472c0272bf3531fc232cd80e53ed7d7388b77dd541720cd6
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.0.14-alpha.4" version: "0.0.14-alpha.4"
term_glyph: term_glyph:
@@ -538,23 +562,23 @@ packages:
description: description:
name: term_glyph name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.2.1" version: "1.2.1"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
url: "https://pub.dev"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.7.3"
version: "0.7.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.4.0" version: "1.4.0"
uuid: uuid:
@@ -562,7 +586,7 @@ packages:
description: description:
name: uuid name: uuid
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "4.5.1" version: "4.5.1"
vector_math: vector_math:
@@ -570,23 +594,23 @@ packages:
description: description:
name: vector_math name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "2.1.4" version: "2.1.4"
vm_service: vm_service:
dependency: transitive dependency: transitive
description: description:
name: vm_service name: vm_service
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
url: "https://pub.dev"
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "14.3.0"
version: "14.2.5"
web: web:
dependency: transitive dependency: transitive
description: description:
name: web name: web
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
web_socket: web_socket:
@@ -594,25 +618,25 @@ packages:
description: description:
name: web_socket name: web_socket
sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83" sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "0.1.6" version: "0.1.6"
web_socket_channel: web_socket_channel:
dependency: "direct main" dependency: "direct main"
description: description:
name: web_socket_channel name: web_socket_channel
sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f"
url: "https://pub.dev"
sha256: "0b8e2457400d8a859b7b2030786835a28a8e80836ef64402abef392ff4f1d0e5"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "3.0.1"
version: "3.0.2"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
name: xdg_directories name: xdg_directories
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
sdks: sdks:
dart: ">=3.6.0 <4.0.0"
dart: ">=3.5.4 <4.0.0"
flutter: ">=3.24.0" flutter: ">=3.24.0"

+ 1
- 0
pubspec.yaml 查看文件

@@ -43,6 +43,7 @@ dependencies:
path_provider: ^2.1.5 path_provider: ^2.1.5
flutter_sound: ^9.19.1 flutter_sound: ^9.19.1
permission_handler: ^11.3.1 permission_handler: ^11.3.1
just_audio: ^0.9.44


dev_dependencies: dev_dependencies:
flutter_test: flutter_test:


正在加载...
取消
保存