feat: upload audio file in chat

This commit is contained in:
jialin
2025-06-03 19:58:08 +08:00
parent ed28bcdfb0
commit 471e1ae96f
8 changed files with 187 additions and 52 deletions
+13 -2
View File
@@ -9,7 +9,16 @@ export const convertFileToBase64 = (file: File): Promise<string> => {
});
};
export const loadAudioData = async (data: any, type: string) => {
export const loadAudioData = async (
data: any,
type: string
): Promise<{
data: Blob;
size: number | string;
type: string;
duration: number;
url: string;
}> => {
return new Promise((resolve, reject) => {
try {
const audioBlob = new Blob([data], { type: type });
@@ -40,7 +49,9 @@ export const loadAudioData = async (data: any, type: string) => {
});
};
export const readAudioFile = async (file: File) => {
export const readAudioFile = async (
file: File
): Promise<{ url: string; name: string; duration: number }> => {
console.log('file====', file);
return new Promise((resolve, reject) => {
const reader = new FileReader();