|
@@ -93,20 +93,6 @@
|
|
|
const uploadFileHandler = async (file) => {
|
|
|
console.log(file);
|
|
|
|
|
|
- // Check if the file is an audio file and transcribe/convert it to text file
|
|
|
- if (['audio/mpeg', 'audio/wav'].includes(file['type'])) {
|
|
|
- const res = await transcribeAudio(localStorage.token, file).catch((error) => {
|
|
|
- toast.error(error);
|
|
|
- return null;
|
|
|
- });
|
|
|
-
|
|
|
- if (res) {
|
|
|
- console.log(res);
|
|
|
- const blob = new Blob([res.text], { type: 'text/plain' });
|
|
|
- file = blobToFile(blob, `${file.name}.txt`);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
const fileItem = {
|
|
|
type: 'file',
|
|
|
file: '',
|
|
@@ -120,6 +106,23 @@
|
|
|
};
|
|
|
files = [...files, fileItem];
|
|
|
|
|
|
+ // Check if the file is an audio file and transcribe/convert it to text file
|
|
|
+ if (['audio/mpeg', 'audio/wav', 'audio/ogg'].includes(file['type'])) {
|
|
|
+ const res = await transcribeAudio(localStorage.token, file).catch((error) => {
|
|
|
+ toast.error(error);
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+
|
|
|
+ if (res) {
|
|
|
+ console.log(res);
|
|
|
+ const blob = new Blob([res.text], { type: 'text/plain' });
|
|
|
+ file = blobToFile(blob, `${file.name}.txt`);
|
|
|
+
|
|
|
+ fileItem.name = file.name;
|
|
|
+ fileItem.size = file.size;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
const uploadedFile = await uploadFile(localStorage.token, file);
|
|
|
|