Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

cleanup

Murtaza Nasir46cfeb1e277e
diff --git a/.gitignore b/.gitignore
index 0f703189..1d204bff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,4 @@ __pycache__/
*.log
.env
.migrate/
-project_files.md
+project_files.md
\ No newline at end of file
diff --git a/app.ipynb b/app.ipynb
deleted file mode 100644
index b1b26aab..00000000
--- a/app.ipynb
+++ /dev/null
@@ -1,243 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "I'll continue with the remaining JavaScript code and add the deployment instructions.\n",
- "\n",
- "\n",
- "\n",
- "```html\n",
- "alert('Save failed: ' + error)\n",
- " }\n",
- " },\n",
- " async loadRecordings() {\n",
- " try {\n",
- " const response = await fetch('/recordings')\n",
- " const data = await response.json()\n",
- " this.recordings = data\n",
- " } catch (error) {\n",
- " alert('Failed to load recordings: ' + error)\n",
- " }\n",
- " },\n",
- " selectRecording(recording) {\n",
- " this.selectedRecording = recording\n",
- " }\n",
- " },\n",
- " mounted() {\n",
- " this.loadRecordings()\n",
- " }\n",
- " }).mount('#app')\n",
- " </script>\n",
- "</body>\n",
- "</html>\n",
- "\n",
- "```\n",
- "\n",
- "Now, let's create a deployment script and requirements file for easy setup on Ubuntu:\n",
- "\n",
- "```text\n",
- "# requirements.txt\n",
- "flask==2.3.3\n",
- "flask-sqlalchemy==3.1.1\n",
- "openai==1.3.0\n",
- "werkzeug==2.3.7\n",
- "gunicorn==21.2.0\n",
- "\n",
- "# deployment/setup.sh\n",
- "#!/bin/bash\n",
- "\n",
- "# Update system\n",
- "sudo apt-get update\n",
- "sudo apt-get upgrade -y\n",
- "\n",
- "# Install Python and pip if not already installed\n",
- "sudo apt-get install -y python3 python3-pip python3-venv\n",
- "\n",
- "# Create directory for the application\n",
- "sudo mkdir -p /opt/transcription-app\n",
- "sudo chown $USER:$USER /opt/transcription-app\n",
- "\n",
- "# Create and activate virtual environment\n",
- "python3 -m venv /opt/transcription-app/venv\n",
- "source /opt/transcription-app/venv/bin/activate\n",
- "\n",
- "# Install requirements\n",
- "pip install -r requirements.txt\n",
- "\n",
- "# Create systemd service file\n",
- "sudo tee /etc/systemd/system/transcription.service << EOF\n",
- "[Unit]\n",
- "Description=Transcription Web Application\n",
- "After=network.target\n",
- "\n",
- "[Service]\n",
- "User=$USER\n",
- "WorkingDirectory=/opt/transcription-app\n",
- "Environment=\"PATH=/opt/transcription-app/venv/bin\"\n",
- "ExecStart=/opt/transcription-app/venv/bin/gunicorn --workers 3 --bind 0.0.0.0:5000 app:app\n",
- "\n",
- "[Install]\n",
- "WantedBy=multi-user.target\n",
- "EOF\n",
- "\n",
- "# Create directories for uploads and database\n",
- "mkdir -p /opt/transcription-app/uploads\n",
- "mkdir -p /opt/transcription-app/instance\n",
- "\n",
- "# Reload systemd and start service\n",
- "sudo systemctl daemon-reload\n",
- "sudo systemctl start transcription\n",
- "sudo systemctl enable transcription\n",
- "\n",
- "echo \"Installation complete! The application should be running on port 5000.\"\n",
- "\n",
- "```\n",
- "\n",
- "To deploy this application on Ubuntu:\n",
- "\n",
- "1. First, create a new directory for your project and copy all the files into it:\n",
- " ```bash\n",
- " mkdir transcription-app\n",
- " cd transcription-app\n",
- " ```\n",
- "\n",
- "2. Create the following directory structure:\n",
- " ```\n",
- " transcription-app/\n",
- " ├── app.py\n",
- " ├── requirements.txt\n",
- " ├── deployment/\n",
- " │ └── setup.sh\n",
- " └── templates/\n",
- " └── index.html\n",
- " ```\n",
- "\n",
- "3. Make the setup script executable and run it:\n",
- " ```bash\n",
- " chmod +x deployment/setup.sh\n",
- " ./deployment/setup.sh\n",
- " ```\n",
- "\n",
- "The application will be installed as a system service and will:\n",
- "- Run on port 5000\n",
- "- Auto-start on system boot\n",
- "- Use gunicorn for production-grade serving\n",
- "- Store uploads in `/opt/transcription-app/uploads`\n",
- "- Store the SQLite database in `/opt/transcription-app/instance`\n",
- "\n",
- "Key features of the application:\n",
- "\n",
- "1. Upload Page:\n",
- " - Drag and drop interface for audio files\n",
- " - Visual feedback during drag operations\n",
- " - Automatic transition to input page after upload\n",
- "\n",
- "2. Input Page:\n",
- " - Split view with transcription and metadata\n",
- " - Auto-save functionality (saves 1 second after last edit)\n",
- " - Manual save button for peace of mind\n",
- " - Clean, modern interface\n",
- "\n",
- "3. Gallery Page:\n",
- " - Time-based grouping (This Week, Last Week, Older)\n",
- " - Audio playback functionality\n",
- " - Detailed view of selected recording\n",
- " - Easy navigation between recordings\n",
- "\n",
- "4. Database:\n",
- " - SQLite for simplicity and portability\n",
- " - Stores all metadata and file paths\n",
- " - Automatic timestamps\n",
- "\n",
- "5. Security Features:\n",
- " - Secure filename handling\n",
- " - File size limits\n",
- " - File type validation\n",
- "\n",
- "To customize the application, you can:\n",
- "1. Modify the upload folder location in `app.py`\n",
- "2. Adjust the maximum file size (currently 16MB)\n",
- "3. Add additional metadata fields by updating both the database model and the frontend form\n",
- "4. Customize the styling using Tailwind classes\n",
- "5. Add user authentication if needed\n",
- "\n",
- "Would you like me to explain any particular part in more detail or make any modifications to the application?"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Here's how to run the app directly using Python:\n",
- "\n",
- "\n",
- "\n",
- "1. First, activate the virtual environment. If you used the setup script, it would be:\n",
- "```bash\n",
- "source /opt/transcription-app/venv/bin/activate\n",
- "```\n",
- "\n",
- "You'll know the virtual environment is activated when you see `(venv)` at the start of your command prompt.\n",
- "\n",
- "2. Navigate to the application directory:\n",
- "```bash\n",
- "cd /opt/transcription-app\n",
- "```\n",
- "\n",
- "3. Run the application directly with Python:\n",
- "```bash\n",
- "python app.py\n",
- "```\n",
- "\n",
- "If you want to run it in development mode but on a different port:\n",
- "```bash\n",
- "export FLASK_ENV=development\n",
- "export FLASK_DEBUG=1\n",
- "python app.py\n",
- "```\n",
- "\n",
- "Alternative way using Flask CLI:\n",
- "```bash\n",
- "export FLASK_APP=app.py\n",
- "flask run --host=0.0.0.0 --port=8080\n",
- "```\n",
- "\n",
- "To stop the application, press `Ctrl+C`.\n",
- "\n",
- "Some useful commands for virtual environment management:\n",
- "```bash\n",
- "# Deactivate the virtual environment when you're done\n",
- "deactivate\n",
- "\n",
- "# If you need to install additional packages\n",
- "pip install package_name\n",
- "\n",
- "# To see all installed packages\n",
- "pip list\n",
- "\n",
- "# To update requirements.txt after installing new packages\n",
- "pip freeze > requirements.txt\n",
- "```\n",
- "\n",
- "If you're developing and want to see the logs in real-time:\n",
- "```bash\n",
- "# In development mode, logs will show directly in the terminal\n",
- "# If you want to see more detailed logs, you can add this to app.py:\n",
- "import logging\n",
- "logging.basicConfig(level=logging.DEBUG)\n",
- "```\n",
- "\n",
- "Would you like me to help you set up any specific development configuration?"
- ]
- }
- ],
- "metadata": {
- "language_info": {
- "name": "python"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
diff --git a/project_files.md b/project_files.md
index 0bbee7e1..918f9e29 100644
--- a/project_files.md
+++ b/project_files.md
@@ -3,68 +3,6 @@
Generated documentation of all project files.
-## migrate_is_admin.py
-
-```python
-
-#!/usr/bin/env python3
-
-import os
-import sys
-from flask import Flask
-from flask_sqlalchemy import SQLAlchemy
-from sqlalchemy import Column, Boolean
-
-# Try to import from app context
-try:
- from flask import current_app
- app = current_app._get_current_object()
- with app.app_context():
- db = app.extensions['sqlalchemy'].db
- User = app.extensions['sqlalchemy'].db.metadata.tables['user']
-except (RuntimeError, AttributeError, KeyError):
- # If not in app context, import directly
- try:
- from app import app, db, User
- except ImportError as e:
- print(f"Error: Could not import required modules: {e}")
- print("Make sure migrate_is_admin.py is runnable and PYTHONPATH is set.")
- sys.exit(1)
-
-def migrate_is_admin_field():
- """
- Add is_admin field to User model if it doesn't exist
- """
- print("Migrating database to add is_admin field to User model")
- print("=====================================================")
-
- with app.app_context():
- # Check if is_admin column exists
- inspector = db.inspect(db.engine)
- columns = [column['name'] for column in inspector.get_columns('user')]
-
- if 'is_admin' in columns:
- print("is_admin column already exists in User table.")
- return
-
- # Add is_admin column
- print("Adding is_admin column to User table...")
- try:
- db.engine.execute('ALTER TABLE user ADD COLUMN is_admin BOOLEAN DEFAULT 0')
- print("Column added successfully.")
- except Exception as e:
- print(f"Error adding column: {e}")
- sys.exit(1)
-
- print("\nMigration completed successfully!")
- print("You can now use the create_admin.py script to create admin users.")
-
-if __name__ == "__main__":
- migrate_is_admin_field()
-
-```
-
-
## reset_db.py
```python
@@ -203,115 +141,6 @@ if __name__ == "__main__":
```
-## migrate_original_filename.py
-
-```python
-
-#!/usr/bin/env python3
-
-import os
-import sys
-from sqlalchemy import inspect
-from sqlalchemy.exc import OperationalError
-
-# Try to import from app context
-try:
- from flask import current_app
- app = current_app._get_current_object()
- with app.app_context():
- db = app.extensions['sqlalchemy'].db
-except (RuntimeError, AttributeError, KeyError):
- # If not in app context, import directly
- try:
- from app import app, db, Recording
- except ImportError as e:
- print(f"Error: Could not import 'app' and 'db': {e}")
- print("Make sure migrate_original_filename.py is runnable and PYTHONPATH is set.")
- sys.exit(1)
-
-def migrate_database():
- """
- Migrate the database schema to add original_filename column without losing data
- """
- print("Starting database migration for original_filename column...")
-
- with app.app_context():
- inspector = inspect(db.engine)
-
- # Check if Recording.original_filename column exists
- recording_columns = [column['name'] for column in inspector.get_columns('recording')]
- if 'original_filename' not in recording_columns:
- print("Adding original_filename column to Recording table...")
- try:
- # Add original_filename column to Recording table
- with db.engine.begin() as conn:
- conn.execute(db.text("ALTER TABLE recording ADD COLUMN original_filename VARCHAR(500)"))
- print("original_filename column added successfully!")
- except OperationalError as e:
- print(f"Error adding original_filename column: {e}")
- print("Attempting alternative approach...")
- try:
- # SQLite doesn't support ALTER TABLE ADD COLUMN with foreign keys
- # So we need to create a new table, copy data, drop old table, rename new table
-
- # 1. Create temporary table with new schema
- with db.engine.begin() as conn:
- conn.execute(db.text("""
- CREATE TABLE recording_new (
- id INTEGER PRIMARY KEY,
- title VARCHAR(200),
- participants VARCHAR(500),
- notes TEXT,
- transcription TEXT,
- summary TEXT,
- status VARCHAR(50),
- audio_path VARCHAR(500),
- created_at DATETIME,
- meeting_date DATE,
- file_size INTEGER,
- user_id INTEGER REFERENCES user(id),
- original_filename VARCHAR(500)
- )
- """))
-
- # 2. Copy data from old table to new table
- with db.engine.begin() as conn:
- conn.execute(db.text("""
- INSERT INTO recording_new (
- id, title, participants, notes, transcription, summary,
- status, audio_path, created_at, meeting_date, file_size, user_id
- )
- SELECT
- id, title, participants, notes, transcription, summary,
- status, audio_path, created_at, meeting_date, file_size, user_id
- FROM recording
- """))
-
- # 3. Drop old table
- with db.engine.begin() as conn:
- conn.execute(db.text("DROP TABLE recording"))
-
- # 4. Rename new table
- with db.engine.begin() as conn:
- conn.execute(db.text("ALTER TABLE recording_new RENAME TO recording"))
-
- print("original_filename column added successfully using table recreation!")
- except Exception as e2:
- print(f"Error during table recreation: {e2}")
- sys.exit(1)
- else:
- print("original_filename column already exists in Recording table.")
-
- print("Database migration completed successfully!")
-
-if __name__ == "__main__":
- print("Attempting to migrate the database to add original_filename column...")
- migrate_database()
- print("Database migration process finished.")
-
-```
-
-
## create_admin.py
```python
@@ -586,8 +415,8 @@ else:
app.logger.error(f"Failed to initialize OpenRouter client: {client_init_e}", exc_info=True)
# Store details for the transcription client (potentially different)
-transcription_api_key = os.environ.get("OPENAI_API_KEY", "cant-be-empty")
-transcription_base_url = os.environ.get("OPENAI_BASE_URL", "http://192.168.68.85:1611/v1/")
+transcription_api_key = os.environ.get("TRANSCRIPTION_API_KEY", "cant-be-empty")
+transcription_base_url = os.environ.get("TRANSCRIPTION_BASE_URL", "https://openrouter.ai/api/v1")
app.logger.info(f"Using OpenRouter model for summaries: {openrouter_model_name}")
@@ -618,8 +447,10 @@ def transcribe_audio_task(app_context, recording_id, filepath, original_filename
base_url=transcription_base_url,
http_client=http_client_no_proxy # Reuse the same client configuration
)
+ # Get the Whisper model name from environment variables
+ whisper_model = os.environ.get("WHISPER_MODEL", "Systran/faster-distil-whisper-large-v3")
transcript = transcription_client.audio.transcriptions.create(
- model="Systran/faster-distil-whisper-large-v3", # Your Whisper model
+ model=whisper_model, # Use model from environment variables
file=audio_file,
language="en" # Specify language if known
)
@@ -1326,36 +1157,300 @@ def delete_recording(recording_id):
if recording.user_id and recording.user_id != current_user.id:
return jsonify({'error': 'You do not have permission to delete this recording'}), 403
- # Delete the audio file first
+ # Delete the audio file first
+ try:
+ if recording.audio_path and os.path.exists(recording.audio_path):
+ os.remove(recording.audio_path)
+ app.logger.info(f"Deleted audio file: {recording.audio_path}")
+ except Exception as e:
+ app.logger.error(f"Error deleting audio file {recording.audio_path}: {e}")
+
+ # Delete the database record
+ db.session.delete(recording)
+ db.session.commit()
+ app.logger.info(f"Deleted recording record ID: {recording_id}")
+
+ return jsonify({'success': True})
+ except Exception as e:
+ db.session.rollback()
+ app.logger.error(f"Error deleting recording {recording_id}: {e}")
+ return jsonify({'error': str(e)}), 500
+
+
+if __name__ == '__main__':
+ # Consider using waitress or gunicorn for production
+ # waitress-serve --host 0.0.0.0 --port 8899 app:app
+ # For development:
+ app.run(host='0.0.0.0', port=8899, debug=True) # Set debug=False if thread issues arise
+
+```
+
+
+## create_docs.py
+
+```python
+
+import os
+from pathlib import Path
+
+def create_markdown_doc(base_dir):
+ output = []
+
+ # Add header
+ output.append("# Project Files\n")
+ output.append("Generated documentation of all project files.\n")
+
+ # Function to read and format file content
+ def add_file_content(filepath, relative_path):
+ output.append(f"\n## {relative_path}\n")
+ output.append("```" + get_file_extension(filepath) + "\n")
+ try:
+ with open(filepath, 'r', encoding='utf-8') as f:
+ output.append(f.read())
+ except Exception as e:
+ output.append(f"Error reading file: {e}")
+ output.append("```\n")
+
+ def get_file_extension(filepath):
+ ext = os.path.splitext(filepath)[1][1:].lower()
+ # Map file extensions to markdown code block languages
+ extension_map = {
+ 'py': 'python',
+ 'html': 'html',
+ 'js': 'javascript',
+ 'css': 'css',
+ 'sh': 'bash',
+ 'md': 'markdown',
+ 'txt': 'text'
+ }
+ return extension_map.get(ext, '')
+
+ # List of important file patterns to include
+ patterns = [
+ '*.py',
+ '*.html',
+ '*.js',
+ '*.css',
+ '*.sh',
+ 'requirements.txt'
+ ]
+
+ # Walk through directory and add files
+ for root, _, _ in os.walk(base_dir):
+ for pattern in patterns:
+ for filepath in Path(root).glob(pattern):
+ if 'venv' not in str(filepath) and '__pycache__' not in str(filepath):
+ relative_path = os.path.relpath(filepath, base_dir)
+ add_file_content(filepath, relative_path)
+
+ # Write to output file
+ output_path = os.path.join(base_dir, 'project_files.md')
+ with open(output_path, 'w', encoding='utf-8') as f:
+ f.write('\n'.join(output))
+
+ return output_path
+
+if __name__ == "__main__":
+ # Get the current directory
+ current_dir = os.getcwd()
+
+ # Create the markdown file
+ output_file = create_markdown_doc(current_dir)
+ print(f"Created markdown documentation at: {output_file}")
+```
+
+
+## requirements.txt
+
+```text
+
+flask==2.3.3
+flask-sqlalchemy==3.1.1
+flask-login==0.6.3
+flask-wtf==1.2.2
+flask-bcrypt==1.0.1
+email-validator==2.2.0
+openai==1.3.0
+werkzeug==2.3.7
+gunicorn==21.2.0
+python-dotenv==1.0.0
+markdown==3.5.1
+
+```
+
+
+## .migrate/migrate_is_admin.py
+
+```python
+
+#!/usr/bin/env python3
+
+import os
+import sys
+from flask import Flask
+from flask_sqlalchemy import SQLAlchemy
+from sqlalchemy import Column, Boolean
+
+# Try to import from app context
+try:
+ from flask import current_app
+ app = current_app._get_current_object()
+ with app.app_context():
+ db = app.extensions['sqlalchemy'].db
+ User = app.extensions['sqlalchemy'].db.metadata.tables['user']
+except (RuntimeError, AttributeError, KeyError):
+ # If not in app context, import directly
+ try:
+ from app import app, db, User
+ except ImportError as e:
+ print(f"Error: Could not import required modules: {e}")
+ print("Make sure migrate_is_admin.py is runnable and PYTHONPATH is set.")
+ sys.exit(1)
+
+def migrate_is_admin_field():
+ """
+ Add is_admin field to User model if it doesn't exist
+ """
+ print("Migrating database to add is_admin field to User model")
+ print("=====================================================")
+
+ with app.app_context():
+ # Check if is_admin column exists
+ inspector = db.inspect(db.engine)
+ columns = [column['name'] for column in inspector.get_columns('user')]
+
+ if 'is_admin' in columns:
+ print("is_admin column already exists in User table.")
+ return
+
+ # Add is_admin column
+ print("Adding is_admin column to User table...")
try:
- if recording.audio_path and os.path.exists(recording.audio_path):
- os.remove(recording.audio_path)
- app.logger.info(f"Deleted audio file: {recording.audio_path}")
+ db.engine.execute('ALTER TABLE user ADD COLUMN is_admin BOOLEAN DEFAULT 0')
+ print("Column added successfully.")
except Exception as e:
- app.logger.error(f"Error deleting audio file {recording.audio_path}: {e}")
+ print(f"Error adding column: {e}")
+ sys.exit(1)
+
+ print("\nMigration completed successfully!")
+ print("You can now use the create_admin.py script to create admin users.")
- # Delete the database record
- db.session.delete(recording)
- db.session.commit()
- app.logger.info(f"Deleted recording record ID: {recording_id}")
+if __name__ == "__main__":
+ migrate_is_admin_field()
- return jsonify({'success': True})
- except Exception as e:
- db.session.rollback()
- app.logger.error(f"Error deleting recording {recording_id}: {e}")
- return jsonify({'error': str(e)}), 500
+```
-if __name__ == '__main__':
- # Consider using waitress or gunicorn for production
- # waitress-serve --host 0.0.0.0 --port 8899 app:app
- # For development:
- app.run(host='0.0.0.0', port=8899, debug=True) # Set debug=False if thread issues arise
+## .migrate/migrate_original_filename.py
+
+```python
+
+#!/usr/bin/env python3
+
+import os
+import sys
+from sqlalchemy import inspect
+from sqlalchemy.exc import OperationalError
+
+# Try to import from app context
+try:
+ from flask import current_app
+ app = current_app._get_current_object()
+ with app.app_context():
+ db = app.extensions['sqlalchemy'].db
+except (RuntimeError, AttributeError, KeyError):
+ # If not in app context, import directly
+ try:
+ from app import app, db, Recording
+ except ImportError as e:
+ print(f"Error: Could not import 'app' and 'db': {e}")
+ print("Make sure migrate_original_filename.py is runnable and PYTHONPATH is set.")
+ sys.exit(1)
+
+def migrate_database():
+ """
+ Migrate the database schema to add original_filename column without losing data
+ """
+ print("Starting database migration for original_filename column...")
+
+ with app.app_context():
+ inspector = inspect(db.engine)
+
+ # Check if Recording.original_filename column exists
+ recording_columns = [column['name'] for column in inspector.get_columns('recording')]
+ if 'original_filename' not in recording_columns:
+ print("Adding original_filename column to Recording table...")
+ try:
+ # Add original_filename column to Recording table
+ with db.engine.begin() as conn:
+ conn.execute(db.text("ALTER TABLE recording ADD COLUMN original_filename VARCHAR(500)"))
+ print("original_filename column added successfully!")
+ except OperationalError as e:
+ print(f"Error adding original_filename column: {e}")
+ print("Attempting alternative approach...")
+ try:
+ # SQLite doesn't support ALTER TABLE ADD COLUMN with foreign keys
+ # So we need to create a new table, copy data, drop old table, rename new table
+
+ # 1. Create temporary table with new schema
+ with db.engine.begin() as conn:
+ conn.execute(db.text("""
+ CREATE TABLE recording_new (
+ id INTEGER PRIMARY KEY,
+ title VARCHAR(200),
+ participants VARCHAR(500),
+ notes TEXT,
+ transcription TEXT,
+ summary TEXT,
+ status VARCHAR(50),
+ audio_path VARCHAR(500),
+ created_at DATETIME,
+ meeting_date DATE,
+ file_size INTEGER,
+ user_id INTEGER REFERENCES user(id),
+ original_filename VARCHAR(500)
+ )
+ """))
+
+ # 2. Copy data from old table to new table
+ with db.engine.begin() as conn:
+ conn.execute(db.text("""
+ INSERT INTO recording_new (
+ id, title, participants, notes, transcription, summary,
+ status, audio_path, created_at, meeting_date, file_size, user_id
+ )
+ SELECT
+ id, title, participants, notes, transcription, summary,
+ status, audio_path, created_at, meeting_date, file_size, user_id
+ FROM recording
+ """))
+
+ # 3. Drop old table
+ with db.engine.begin() as conn:
+ conn.execute(db.text("DROP TABLE recording"))
+
+ # 4. Rename new table
+ with db.engine.begin() as conn:
+ conn.execute(db.text("ALTER TABLE recording_new RENAME TO recording"))
+
+ print("original_filename column added successfully using table recreation!")
+ except Exception as e2:
+ print(f"Error during table recreation: {e2}")
+ sys.exit(1)
+ else:
+ print("original_filename column already exists in Recording table.")
+
+ print("Database migration completed successfully!")
+
+if __name__ == "__main__":
+ print("Attempting to migrate the database to add original_filename column...")
+ migrate_database()
+ print("Database migration process finished.")
```
-## migrate_db.py
+## .migrate/migrate_db.py
```python
@@ -1483,99 +1578,6 @@ if __name__ == "__main__":
```
-## create_docs.py
-
-```python
-
-import os
-from pathlib import Path
-
-def create_markdown_doc(base_dir):
- output = []
-
- # Add header
- output.append("# Project Files\n")
- output.append("Generated documentation of all project files.\n")
-
- # Function to read and format file content
- def add_file_content(filepath, relative_path):
- output.append(f"\n## {relative_path}\n")
- output.append("```" + get_file_extension(filepath) + "\n")
- try:
- with open(filepath, 'r', encoding='utf-8') as f:
- output.append(f.read())
- except Exception as e:
- output.append(f"Error reading file: {e}")
- output.append("```\n")
-
- def get_file_extension(filepath):
- ext = os.path.splitext(filepath)[1][1:].lower()
- # Map file extensions to markdown code block languages
- extension_map = {
- 'py': 'python',
- 'html': 'html',
- 'js': 'javascript',
- 'css': 'css',
- 'sh': 'bash',
- 'md': 'markdown',
- 'txt': 'text'
- }
- return extension_map.get(ext, '')
-
- # List of important file patterns to include
- patterns = [
- '*.py',
- '*.html',
- '*.js',
- '*.css',
- '*.sh',
- 'requirements.txt'
- ]
-
- # Walk through directory and add files
- for root, _, _ in os.walk(base_dir):
- for pattern in patterns:
- for filepath in Path(root).glob(pattern):
- if 'venv' not in str(filepath) and '__pycache__' not in str(filepath):
- relative_path = os.path.relpath(filepath, base_dir)
- add_file_content(filepath, relative_path)
-
- # Write to output file
- output_path = os.path.join(base_dir, 'project_files.md')
- with open(output_path, 'w', encoding='utf-8') as f:
- f.write('\n'.join(output))
-
- return output_path
-
-if __name__ == "__main__":
- # Get the current directory
- current_dir = os.getcwd()
-
- # Create the markdown file
- output_file = create_markdown_doc(current_dir)
- print(f"Created markdown documentation at: {output_file}")
-```
-
-
-## requirements.txt
-
-```text
-
-flask==2.3.3
-flask-sqlalchemy==3.1.1
-flask-login==0.6.3
-flask-wtf==1.2.2
-flask-bcrypt==1.0.1
-email-validator==2.2.0
-openai==1.3.0
-werkzeug==2.3.7
-gunicorn==21.2.0
-python-dotenv==1.0.0
-markdown==3.5.1
-
-```
-
-
## templates/account.html
```html
@@ -3651,6 +3653,7 @@ markdown==3.5.1
const isProcessingActive = ref(false);
const pollInterval = ref(null);
const progressPopupMinimized = ref(false);
+ const progressPopupClosed = ref(false);
const showEditModal = ref(false);
const showDeleteModal = ref(false);
@@ -3846,6 +3849,7 @@ markdown==3.5.1
if(filesAdded > 0) {
console.log(`Added ${filesAdded} file(s) to the queue.`);
progressPopupMinimized.value = false; // Show popup
+ progressPopupClosed.value = false; // Reset closed state to make popup reappear
if (!isProcessingActive.value) {
startProcessingQueue();
}
@@ -4345,8 +4349,14 @@ markdown==3.5.1
watch(uploadQueue, (newQueue, oldQueue) => {
if (newQueue.length === 0 && oldQueue.length > 0 && !isProcessingActive.value) {
console.log("Upload queue processing finished.");
- // Optional: Auto-minimize after delay
- // setTimeout(() => progressPopupMinimized.value = true, 3000);
+ // Auto-minimize after delay
+ setTimeout(() => progressPopupMinimized.value = true, 1000);
+ // Auto-hide popup after all uploads are complete
+ setTimeout(() => {
+ if (completedInQueue.value === totalInQueue.value && !isProcessingActive.value) {
+ progressPopupClosed.value = true;
+ }
+ }, 5000);
}
}, { deep: true });
@@ -4564,7 +4574,7 @@ markdown==3.5.1
isLoadingRecordings, globalError, maxFileSizeMB, isDarkMode, // <-- Added isDarkMode
// Multi-upload State
uploadQueue, currentlyProcessingFile, processingProgress, processingMessage,
- isProcessingActive, progressPopupMinimized,
+ isProcessingActive, progressPopupMinimized, progressPopupClosed,
// Chat State
showChat, chatMessages, chatInput, isChatLoading, chatMessagesRef, // <-- Added chatMessagesRef
// Computed
@@ -4990,6 +5000,8 @@ markdown==3.5.1
#!/bin/bash
# Create directory for the application
+sudo systemctl stop transcription
+
sudo mkdir -p /opt/transcription-app
sudo chown $USER:$USER /opt/transcription-app
@@ -4998,7 +5010,6 @@ cp app.py /opt/transcription-app/
cp -r templates /opt/transcription-app/
cp requirements.txt /opt/transcription-app/
cp reset_db.py /opt/transcription-app/
-cp migrate_db.py /opt/transcription-app/
cp create_admin.py /opt/transcription-app/
cp .env /opt/transcription-app/ # Copy the .env file with API keys