File size: 1,526 Bytes
a03bb33
e989cbd
 
a03bb33
 
 
f777ef6
a03bb33
 
e989cbd
 
 
 
 
 
a03bb33
 
 
 
 
 
 
fefabc8
a03bb33
 
e989cbd
 
 
 
 
 
 
a03bb33
192a0e6
a03bb33
3713b6e
e989cbd
 
 
 
3713b6e
e989cbd
 
 
 
a03bb33
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import time
from core.state import state
from core.database import db_manager
from services.audio_service import process_audio_file


def run_audio_processing(task_id: str, file_path: str, isolate_vocals: bool, enhance_speech: bool, lyric_sync: bool, user_email: str):
    try:
        def progress_callback(progress_percent, message, **kwargs):
            update_data = {
                "progress": progress_percent,
                "message": message
            }
            update_data.update(kwargs)
            db_manager.upsert_task(task_id, update_data)
            
        zip_path = process_audio_file(
            file_path, 
            task_id, 
            progress_callback,
            isolate_vocals=isolate_vocals,
            enhance_speech=enhance_speech,
            lyric_sync=lyric_sync
        )
        
        db_manager.upsert_task(task_id, {
            "status": "completed",
            "progress": 100,
            "message": "Processing complete! Ready to download.",
            "result_path": zip_path,
            "completed_time": time.time()
        })
        

    except Exception as e:
        if str(e) == "Task cancelled by user":
            db_manager.upsert_task(task_id, {
                "status": "cancelled",
                "message": "Task cancelled by user"
            })
        else:
            db_manager.upsert_task(task_id, {
                "status": "failed",
                "message": str(e)
            })
        print(f"Error processing {task_id}: {e}")