Update run.py
Browse files
run.py
CHANGED
|
@@ -7,8 +7,6 @@ import torch
|
|
| 7 |
import re
|
| 8 |
from werkzeug.utils import secure_filename
|
| 9 |
import uuid
|
| 10 |
-
|
| 11 |
-
import os
|
| 12 |
import platform
|
| 13 |
|
| 14 |
# Set Transformers Cache Directory
|
|
@@ -35,7 +33,7 @@ print(f"Environment variable TRANSFORMERS_CACHE set to '{transformers_cache_dire
|
|
| 35 |
|
| 36 |
|
| 37 |
class Config:
|
| 38 |
-
UPLOAD_FOLDER = os.path.join(os.path.dirname(__file__), 'uploads') # Correct path
|
| 39 |
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB max file size
|
| 40 |
CORS_HEADERS = 'Content-Type'
|
| 41 |
|
|
@@ -148,10 +146,12 @@ def analyze_sentiment(file_path: str):
|
|
| 148 |
return [{'label': 'Error', 'score': 0.5}]
|
| 149 |
|
| 150 |
|
|
|
|
| 151 |
def create_app():
|
| 152 |
app = Flask(__name__)
|
| 153 |
app.config.from_object(Config)
|
| 154 |
-
|
|
|
|
| 155 |
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
| 156 |
|
| 157 |
@app.route('/upload', methods=['POST'])
|
|
@@ -162,7 +162,7 @@ def create_app():
|
|
| 162 |
return jsonify({'error': 'No transcript received'}), 400
|
| 163 |
|
| 164 |
# Save the transcript in the current folder
|
| 165 |
-
file_path = os.path.join(
|
| 166 |
with open(file_path, 'w') as file:
|
| 167 |
file.write(transcript)
|
| 168 |
|
|
@@ -180,6 +180,7 @@ def create_app():
|
|
| 180 |
|
| 181 |
|
| 182 |
|
|
|
|
| 183 |
if __name__ == '__main__':
|
| 184 |
app = create_app()
|
| 185 |
app.run(host="0.0.0.0", port=5000)
|
|
|
|
| 7 |
import re
|
| 8 |
from werkzeug.utils import secure_filename
|
| 9 |
import uuid
|
|
|
|
|
|
|
| 10 |
import platform
|
| 11 |
|
| 12 |
# Set Transformers Cache Directory
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
class Config:
|
| 36 |
+
UPLOAD_FOLDER = os.path.join(os.path.dirname(__file__), '/tmp/uploads') # Correct path
|
| 37 |
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB max file size
|
| 38 |
CORS_HEADERS = 'Content-Type'
|
| 39 |
|
|
|
|
| 146 |
return [{'label': 'Error', 'score': 0.5}]
|
| 147 |
|
| 148 |
|
| 149 |
+
|
| 150 |
def create_app():
|
| 151 |
app = Flask(__name__)
|
| 152 |
app.config.from_object(Config)
|
| 153 |
+
|
| 154 |
+
# Ensure the uploads directory exists
|
| 155 |
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
| 156 |
|
| 157 |
@app.route('/upload', methods=['POST'])
|
|
|
|
| 162 |
return jsonify({'error': 'No transcript received'}), 400
|
| 163 |
|
| 164 |
# Save the transcript in the current folder
|
| 165 |
+
file_path = os.path.join(os.getcwd(), 'transcript.txt')
|
| 166 |
with open(file_path, 'w') as file:
|
| 167 |
file.write(transcript)
|
| 168 |
|
|
|
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
+
|
| 184 |
if __name__ == '__main__':
|
| 185 |
app = create_app()
|
| 186 |
app.run(host="0.0.0.0", port=5000)
|