base video creator
This commit is contained in:
parent
00953b3a19
commit
84618389e6
|
|
@ -0,0 +1,5 @@
|
||||||
|
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M0 24C0 12.6863 0 7.02944 3.51472 3.51472C7.02944 0 12.6863 0 24 0C35.3137 0 40.9706 0 44.4853 3.51472C48 7.02944 48 12.6863 48 24C48 35.3137 48 40.9706 44.4853 44.4853C40.9706 48 35.3137 48 24 48C12.6863 48 7.02944 48 3.51472 44.4853C0 40.9706 0 35.3137 0 24Z" fill="#B0D7E4"/>
|
||||||
|
<path d="M12.2614 18.4973H35.7387M29.076 18.4973V11.8359M18.924 18.4973V11.8359M21.52 23.9039V30.4666C21.52 30.6013 21.5627 30.7333 21.6414 30.8479C21.7214 30.9613 21.8347 31.0533 21.9694 31.1133C22.1051 31.1727 22.2536 31.1968 22.4011 31.1836C22.5486 31.1703 22.6904 31.12 22.8134 31.0373L27.8774 27.5039C27.9757 27.4356 28.0562 27.3446 28.112 27.2386C28.1646 27.1363 28.1897 27.022 28.185 26.9071C28.1804 26.7921 28.146 26.6804 28.0854 26.5826C28.0198 26.4817 27.9322 26.397 27.8294 26.3346L22.7654 23.3053C22.6415 23.2333 22.5019 23.1926 22.3588 23.1868C22.2157 23.181 22.0733 23.2102 21.944 23.2719C21.8199 23.3318 21.7133 23.4228 21.6347 23.5359C21.5611 23.6446 21.5212 23.7727 21.52 23.9039Z" stroke="#007EA7" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<path d="M28.3334 11.667H19.6667C15.2484 11.667 11.6667 15.2487 11.6667 19.667V28.3337C11.6667 32.7519 15.2484 36.3337 19.6667 36.3337H28.3334C32.7516 36.3337 36.3334 32.7519 36.3334 28.3337V19.667C36.3334 15.2487 32.7516 11.667 28.3334 11.667Z" stroke="#007EA7" stroke-width="1.5"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
|
|
@ -117,6 +117,7 @@ class Prompts {
|
||||||
bool? finished;
|
bool? finished;
|
||||||
bool? error;
|
bool? error;
|
||||||
bool? audio;
|
bool? audio;
|
||||||
|
bool? video;
|
||||||
int? duration;
|
int? duration;
|
||||||
FilesModel? fileLocal;
|
FilesModel? fileLocal;
|
||||||
|
|
||||||
|
|
@ -131,6 +132,7 @@ class Prompts {
|
||||||
this.finished,
|
this.finished,
|
||||||
this.error,
|
this.error,
|
||||||
this.audio,
|
this.audio,
|
||||||
|
this.video,
|
||||||
this.fileLocal,
|
this.fileLocal,
|
||||||
this.duration});
|
this.duration});
|
||||||
|
|
||||||
|
|
@ -143,6 +145,7 @@ class Prompts {
|
||||||
role = json['role'];
|
role = json['role'];
|
||||||
createdAt = json['createdAt'];
|
createdAt = json['createdAt'];
|
||||||
audio = json['audio'];
|
audio = json['audio'];
|
||||||
|
video = json['video'];
|
||||||
duration = json['duration'];
|
duration = json['duration'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,6 +159,7 @@ class Prompts {
|
||||||
data['role'] = role;
|
data['role'] = role;
|
||||||
data['createdAt'] = createdAt;
|
data['createdAt'] = createdAt;
|
||||||
data['audio'] = audio;
|
data['audio'] = audio;
|
||||||
|
data['video'] = video;
|
||||||
data['duration'] = duration;
|
data['duration'] = duration;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
@ -172,6 +176,7 @@ class Prompts {
|
||||||
bool? finished,
|
bool? finished,
|
||||||
bool? error,
|
bool? error,
|
||||||
bool? audio,
|
bool? audio,
|
||||||
|
bool? video,
|
||||||
int? duration,
|
int? duration,
|
||||||
}) {
|
}) {
|
||||||
return Prompts(
|
return Prompts(
|
||||||
|
|
@ -186,6 +191,7 @@ class Prompts {
|
||||||
finished: finished ?? this.finished,
|
finished: finished ?? this.finished,
|
||||||
error: error ?? this.error,
|
error: error ?? this.error,
|
||||||
audio: audio ?? this.audio,
|
audio: audio ?? this.audio,
|
||||||
|
video: video ?? this.video,
|
||||||
duration: duration ?? this.duration,
|
duration: duration ?? this.duration,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,7 @@ class RequestHelper {
|
||||||
static String aiSummery() => '$baseUrl/ai/aisummery';
|
static String aiSummery() => '$baseUrl/ai/aisummery';
|
||||||
static String aiAudio() => '$baseUrl/ai/101/aiaudio';
|
static String aiAudio() => '$baseUrl/ai/101/aiaudio';
|
||||||
static String chartAnalysis() => '$baseUrl/ai/27/chart-analysis';
|
static String chartAnalysis() => '$baseUrl/ai/27/chart-analysis';
|
||||||
|
static String aiVideo() => '$baseUrl/ai/102/aivideo';
|
||||||
static String tools() => '$baseUrl/ai/tool';
|
static String tools() => '$baseUrl/ai/tool';
|
||||||
static String info() => '$baseUrl/ai/video';
|
static String info() => '$baseUrl/ai/video';
|
||||||
static String usersAssistants({final bool personal = false}) =>
|
static String usersAssistants({final bool personal = false}) =>
|
||||||
|
|
|
||||||
|
|
@ -755,7 +755,9 @@ class _AiChatPageState extends State<AiChatPage> with TickerProviderStateMixin {
|
||||||
: FilesModel(message.file.toString().replaceAll(' ', ''),
|
: FilesModel(message.file.toString().replaceAll(' ', ''),
|
||||||
duration: message.duration != null
|
duration: message.duration != null
|
||||||
? Duration(seconds: message.duration!)
|
? Duration(seconds: message.duration!)
|
||||||
: null));
|
: null,
|
||||||
|
audio: message.audio,
|
||||||
|
video: message.video));
|
||||||
|
|
||||||
final isUser = message.role.toString().contains('user');
|
final isUser = message.role.toString().contains('user');
|
||||||
|
|
||||||
|
|
@ -865,14 +867,28 @@ class _AiChatPageState extends State<AiChatPage> with TickerProviderStateMixin {
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(
|
padding: const EdgeInsets.fromLTRB(
|
||||||
16, 16, 16, 0),
|
16, 16, 16, 0),
|
||||||
child: ClipRRect(
|
child: Column(
|
||||||
borderRadius:
|
children: [
|
||||||
DesignConfig.lowBorderRadius,
|
Container(
|
||||||
child: ChatVideoPlayer(
|
height: 50,
|
||||||
src: RequestHelper.baseUrl +
|
color: Colors.green,
|
||||||
file.path,
|
child: Center(
|
||||||
custome: const CustomControls(),
|
child: Text(
|
||||||
),
|
'VIDEO PLAYER TEST',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius:
|
||||||
|
DesignConfig.lowBorderRadius,
|
||||||
|
child: ChatVideoPlayer(
|
||||||
|
src: RequestHelper.baseUrl +
|
||||||
|
file.path,
|
||||||
|
custome: const CustomControls(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: file.isImage()
|
: file.isImage()
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,8 @@ class AiChatState extends CoreProvier {
|
||||||
url = '/101/aiaudio';
|
url = '/101/aiaudio';
|
||||||
} else if (bot.id == 27) {
|
} else if (bot.id == 27) {
|
||||||
url = '/27/chart-analysis';
|
url = '/27/chart-analysis';
|
||||||
|
} else if (bot.id == 102) {
|
||||||
|
url = '/102/aivideo';
|
||||||
} else {
|
} else {
|
||||||
url =
|
url =
|
||||||
'${isAssistants ? '/user/${bot.responseType}' : ''}/${bot.id}/${bot.name}'
|
'${isAssistants ? '/user/${bot.responseType}' : ''}/${bot.id}/${bot.name}'
|
||||||
|
|
@ -227,9 +229,12 @@ class AiChatState extends CoreProvier {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bot.id == 101) {
|
if (bot.id == 101) {
|
||||||
print('🎵 TTS Stream - Raw data: $str');
|
|
||||||
responseMessgae += str;
|
responseMessgae += str;
|
||||||
print('🎵 TTS Stream - Full responseMessgae: $responseMessgae');
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bot.id == 102) {
|
||||||
|
responseMessgae += str;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,34 +283,41 @@ class AiChatState extends CoreProvier {
|
||||||
int? humanMessageId;
|
int? humanMessageId;
|
||||||
int? aiMessageId;
|
int? aiMessageId;
|
||||||
String? audioUrl;
|
String? audioUrl;
|
||||||
|
String? videoUrl;
|
||||||
if (bot.id == 101) {
|
|
||||||
print('🎵 TTS onDone - responseMessgae: $responseMessgae');
|
|
||||||
print('🎵 TTS onDone - dataMessgae: $dataMessgae');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bot.id == 101) {
|
if (bot.id == 101) {
|
||||||
try {
|
try {
|
||||||
print('🎵 TTS - Parsing responseMessgae directly...');
|
|
||||||
String jsonString = responseMessgae;
|
String jsonString = responseMessgae;
|
||||||
|
|
||||||
if (jsonString.contains('}{')) {
|
if (jsonString.contains('}{')) {
|
||||||
jsonString =
|
jsonString =
|
||||||
jsonString.substring(0, jsonString.indexOf('}{') + 1);
|
jsonString.substring(0, jsonString.indexOf('}{') + 1);
|
||||||
print('🎵 TTS - Extracted first JSON: $jsonString');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final jsonData = json.decode(jsonString);
|
final jsonData = json.decode(jsonString);
|
||||||
print('🎵 TTS - Parsed JSON: $jsonData');
|
|
||||||
|
|
||||||
audioUrl = jsonData['url']?.toString();
|
audioUrl = jsonData['url']?.toString();
|
||||||
humanMessageId = jsonData['HUMAN_MESSAGE_ID'];
|
humanMessageId = jsonData['HUMAN_MESSAGE_ID'];
|
||||||
aiMessageId = jsonData['AI_MESSAGE_ID'];
|
aiMessageId = jsonData['AI_MESSAGE_ID'];
|
||||||
print('🎵 TTS - audioUrl: $audioUrl');
|
|
||||||
print(
|
|
||||||
'🎵 TTS - humanMessageId: $humanMessageId, aiMessageId: $aiMessageId');
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('🎵 TTS - ERROR parsing: $e');
|
e.printError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (bot.id == 102) {
|
||||||
|
try {
|
||||||
|
String jsonString = responseMessgae;
|
||||||
|
|
||||||
|
if (jsonString.contains('}{')) {
|
||||||
|
jsonString =
|
||||||
|
jsonString.substring(0, jsonString.indexOf('}{') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
final jsonData = json.decode(jsonString);
|
||||||
|
|
||||||
|
videoUrl = jsonData['url']?.toString();
|
||||||
|
humanMessageId = jsonData['HUMAN_MESSAGE_ID'];
|
||||||
|
aiMessageId = jsonData['AI_MESSAGE_ID'];
|
||||||
|
} catch (e) {
|
||||||
e.printError();
|
e.printError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -320,21 +332,18 @@ class AiChatState extends CoreProvier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bot.id == 101) {
|
|
||||||
print('🎵 TTS - Saving message:');
|
|
||||||
print('🎵 TTS - text: ${bot.id == 101 ? null : responseMessgae}');
|
|
||||||
print('🎵 TTS - file: ${bot.id == 101 ? audioUrl : responseMessgae}');
|
|
||||||
print('🎵 TTS - bot.responseType: ${bot.responseType}');
|
|
||||||
}
|
|
||||||
|
|
||||||
messages.last.prompts.last = messages.last.prompts.last.copyWith(
|
messages.last.prompts.last = messages.last.prompts.last.copyWith(
|
||||||
finished: true,
|
finished: true,
|
||||||
text: bot.responseType != 'text' && bot.id != 101
|
text: bot.responseType != 'text' && bot.id != 101 && bot.id != 102
|
||||||
? null
|
? null
|
||||||
: (bot.id == 101 ? null : responseMessgae),
|
: (bot.id == 101 || bot.id == 102 ? null : responseMessgae),
|
||||||
file: bot.responseType != 'text' || bot.id == 101
|
file: bot.responseType != 'text' || bot.id == 101 || bot.id == 102
|
||||||
? (bot.id == 101 ? audioUrl : responseMessgae)
|
? (bot.id == 101
|
||||||
|
? audioUrl
|
||||||
|
: (bot.id == 102 ? videoUrl : responseMessgae))
|
||||||
: null,
|
: null,
|
||||||
|
audio: bot.id == 101 ? true : null,
|
||||||
|
video: bot.id == 102 ? true : null,
|
||||||
id: aiMessageId);
|
id: aiMessageId);
|
||||||
if (messages.last.prompts.length > 2) {
|
if (messages.last.prompts.length > 2) {
|
||||||
messages.last.prompts[messages.last.prompts.length - 2] = messages
|
messages.last.prompts[messages.last.prompts.length - 2] = messages
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,25 @@ class _AiSectionPageState extends State<AiSectionPage> with TickerProviderStateM
|
||||||
aiState.startChat(AiChatArgs(bot: chartAnalysisBot));
|
aiState.startChat(AiChatArgs(bot: chartAnalysisBot));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
_AiSectionGridItem(
|
||||||
|
title: 'ساخت ویدیو',
|
||||||
|
description: 'تولید ویدیو با هوش مصنوعی',
|
||||||
|
iconPath: 'lib/assets/icons/video creator.svg',
|
||||||
|
onTap: (context) {
|
||||||
|
final aiState = context.read<AiState>();
|
||||||
|
aiState.endChat();
|
||||||
|
|
||||||
|
final aiVideoBot = BotsModel(
|
||||||
|
id: 102,
|
||||||
|
name: 'aivideo',
|
||||||
|
responseType: 'video',
|
||||||
|
attachmentType: [],
|
||||||
|
attachment: 0,
|
||||||
|
);
|
||||||
|
|
||||||
|
aiState.startChat(AiChatArgs(bot: aiVideoBot));
|
||||||
|
},
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,16 @@ class _ChatVideoPlayerState extends State<ChatVideoPlayer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _handleVideoPlayback() async {
|
Future<void> _handleVideoPlayback() async {
|
||||||
_videoPlayerController = VideoPlayerController.network(
|
final videoUrl = '${widget.src}?accessToken=${RequestService.token}';
|
||||||
'${widget.src}?accessToken=${RequestService.token}');
|
print('🎬 ChatVideoPlayer - Initializing video...');
|
||||||
|
print('🎬 ChatVideoPlayer - URL: $videoUrl');
|
||||||
|
|
||||||
|
_videoPlayerController = VideoPlayerController.network(videoUrl);
|
||||||
|
|
||||||
await _videoPlayerController.initialize().then((_) {
|
await _videoPlayerController.initialize().then((_) {
|
||||||
|
print('🎬 ChatVideoPlayer - Video initialized successfully!');
|
||||||
|
print('🎬 ChatVideoPlayer - Duration: ${_videoPlayerController.value.duration}');
|
||||||
|
print('🎬 ChatVideoPlayer - Size: ${_videoPlayerController.value.size}');
|
||||||
setState(() {
|
setState(() {
|
||||||
_chewieController = ChewieController(
|
_chewieController = ChewieController(
|
||||||
customControls: widget.custome,
|
customControls: widget.custome,
|
||||||
|
|
@ -50,6 +56,7 @@ class _ChatVideoPlayerState extends State<ChatVideoPlayer> {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
|
print('🎬 ChatVideoPlayer - ERROR: $e');
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +65,7 @@ class _ChatVideoPlayerState extends State<ChatVideoPlayer> {
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_videoPlayerController.pause();
|
_videoPlayerController.pause();
|
||||||
_videoPlayerController.dispose();
|
_videoPlayerController.dispose();
|
||||||
_chewieController?.dispose(); // Dispose of the ChewieController
|
_chewieController?.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue