diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..21e2fa6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Use an official Python runtime as a parent image +FROM python:3.8-slim + +# Set the working directory in the container +WORKDIR /usr/src/app + +# Install ffmpeg and git +RUN apt-get update && apt-get install -y ffmpeg git + +# Install ffmpeg-python library +RUN pip install ffmpeg-python + +# Clone the repository and install its dependencies +RUN pip install git+https://github.com/m1guelpf/auto-subtitle.git + +# Copy the local code to the container +COPY . . + +# Define environment variable +ENV NAME AutoSubtitle + +# Set the default command for the container +CMD ["auto_subtitle"] diff --git a/autosub.ps1 b/autosub.ps1 new file mode 100644 index 0000000..a5f5726 --- /dev/null +++ b/autosub.ps1 @@ -0,0 +1,46 @@ +param ( + [string]$model = "tiny", + [string]$output_dir = "output", + [bool]$srt_only = $false, + [Parameter(Position=0, Mandatory=$false)] + [string]$videoPath +) + +function Show-Help { + @" +Usage: autosub [-model ] [-output_dir ] [-srt_only ] + autosub --help + +-model : The model to use for subtitling. Available models are {tiny.en,tiny,base.en,base,small.en,small,medium.en,medium,large-v1,large-v2,large-v3,large}. Default is 'tiny'. +-output_dir : The directory where the output file will be stored. Default is 'output'. +-srt_only : If set to $true, only generates SRT file. Default is $false. +-videoPath : Full path to the video file to be processed. +--help: Shows this help message. + +Example: + autosub "C:\path\to\video.mp4" -model tiny -output_dir output_autosub -srt_only $true + Runs the auto-subtitle container on 'video.mp4' using the 'tiny' model, outputs to 'output_autosub', and generates only the SRT file. +"@ +} + +if ($videoPath -eq "--help") { + Show-Help + exit +} + +# Extract the directory path and video file name from the provided path +$videoDirectory = Split-Path -Parent $videoPath +$videoFile = Split-Path -Leaf $videoPath + +# Construct the Docker command +# $dockerCommand = "docker run -it --rm -v ${videoDirectory}:/usr/src/app/data --name my-running-app auto-subtitle auto_subtitle '/usr/src/app/data/$videoFile' --model $model --output_dir /usr/src/app/data/$output_dir" +$dockerCommand = "docker run -it --rm -v ${videoDirectory}:/usr/src/app/data -v my_downloaded_packages:/root/.cache/ --name my-running-app auto-subtitle auto_subtitle '/usr/src/app/data/$videoFile' --model $model --output_dir /usr/src/app/data/$output_dir" + +# Add the srt_only flag if it's true +if ($srt_only -eq $true) { + $dockerCommand += " --srt_only True" +} + +# Run the Docker command +Invoke-Expression $dockerCommand + diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..1ef8d96 --- /dev/null +++ b/install.ps1 @@ -0,0 +1,6 @@ +docker build -t auto-subtitle . +New-Item -Path "C:\autosub" -ItemType Directory -Force +Copy-Item -Path "autosub.ps1" -Destination "C:\autosub" +$UserPath = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User) +$NewPath = "$UserPath;C:\autosub" +[System.Environment]::SetEnvironmentVariable("PATH", $NewPath, [System.EnvironmentVariableTarget]::User)