github-actions[bot] commited on
Commit ·
db40098
1
Parent(s): af34870
Auto-deploy from GitHub: bcd326a367615cce9b70089a39cef202781d162b
Browse files- .gitattributes +1 -1
- app.py +48 -0
.gitattributes
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 4 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 5 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 1 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 4 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -347,6 +347,54 @@ def get_files():
|
|
| 347 |
|
| 348 |
return jsonify(files)
|
| 349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
@app.route('/api/download/<task_id>', methods=['GET'])
|
| 351 |
def download_file(task_id):
|
| 352 |
conn = sqlite3.connect('tts_tasks.db')
|
|
|
|
| 347 |
|
| 348 |
return jsonify(files)
|
| 349 |
|
| 350 |
+
@app.route('/api/files/<task_id>', methods=['GET'])
|
| 351 |
+
def get_file(task_id):
|
| 352 |
+
conn = sqlite3.connect('tts_tasks.db')
|
| 353 |
+
conn.row_factory = sqlite3.Row
|
| 354 |
+
c = conn.cursor()
|
| 355 |
+
c.execute('SELECT * FROM tasks WHERE id = ?', (task_id,))
|
| 356 |
+
row = c.fetchone()
|
| 357 |
+
|
| 358 |
+
if row is None:
|
| 359 |
+
conn.close()
|
| 360 |
+
return jsonify({'error': 'Task not found'}), 404
|
| 361 |
+
|
| 362 |
+
# Get queue order for not_started tasks (oldest first = position 1)
|
| 363 |
+
c.execute('''SELECT id FROM tasks
|
| 364 |
+
WHERE status = 'not_started'
|
| 365 |
+
ORDER BY created_at ASC''')
|
| 366 |
+
queue_order = [r['id'] for r in c.fetchall()]
|
| 367 |
+
|
| 368 |
+
# Check if any task is currently processing
|
| 369 |
+
c.execute('SELECT COUNT(*) as count FROM tasks WHERE status = "processing"')
|
| 370 |
+
processing_count = c.fetchone()['count']
|
| 371 |
+
|
| 372 |
+
conn.close()
|
| 373 |
+
|
| 374 |
+
# Average processing time in seconds
|
| 375 |
+
AVG_PROCESSING_TIME = 30
|
| 376 |
+
|
| 377 |
+
file_data = {
|
| 378 |
+
'id': row['id'],
|
| 379 |
+
'text': row['text'],
|
| 380 |
+
'status': row['status'],
|
| 381 |
+
'output_file': row['output_file'],
|
| 382 |
+
'created_at': row['created_at'],
|
| 383 |
+
'processed_at': row['processed_at'],
|
| 384 |
+
'error': row['error'],
|
| 385 |
+
'progress': row['progress'] or 0,
|
| 386 |
+
'progress_text': row['progress_text']
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
# Add queue position for not_started tasks
|
| 390 |
+
if row['status'] == 'not_started' and row['id'] in queue_order:
|
| 391 |
+
queue_position = queue_order.index(row['id']) + 1 # 1-indexed
|
| 392 |
+
file_data['queue_position'] = queue_position
|
| 393 |
+
tasks_ahead = queue_position - 1 + processing_count
|
| 394 |
+
file_data['estimated_start_seconds'] = tasks_ahead * AVG_PROCESSING_TIME
|
| 395 |
+
|
| 396 |
+
return jsonify(file_data)
|
| 397 |
+
|
| 398 |
@app.route('/api/download/<task_id>', methods=['GET'])
|
| 399 |
def download_file(task_id):
|
| 400 |
conn = sqlite3.connect('tts_tasks.db')
|