faster-whisper-webui-pv / run_colab.py
jolnar's picture
Update run_colab.py
ba28d8f verified
import os
import sys
import subprocess
def setup_environment():
# Install dependencies
subprocess.run([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'], check=True)
# Install json5 separately
subprocess.run([sys.executable, '-m', 'pip', 'install', 'json5'], check=True)
# Call setup_environment before any other imports
setup_environment()
# Now import the required modules
from app import create_ui
from src.config import ApplicationConfig
if __name__ == "__main__":
# Colab-specific settings
app_config = ApplicationConfig.create_default(
input_audio_max_duration=-1,
server_name="0.0.0.0",
server_port=int(os.environ.get("PORT", 7860)),
share=True,
output_dir='/content/output' # Set output directory to an accessible location
)
# Print output directory
print("Output directory:", app_config.output_dir)
# Create and launch the UI
demo = create_ui(app_config)
# Launch the app with Colab settings
demo.launch(
share=True,
server_name="0.0.0.0",
server_port=int(os.environ.get("PORT", 7860))
)
# Print generated files after processing
print("Generated files:")
for root, dirs, files in os.walk(app_config.output_dir):
for file in files:
print(os.path.join(root, file))