Go PGS subtitle converter
go-pgs-converter
needs Tesseract to be installed on the machine.
An easy way to do it, is to run go-pgs-converter
on Docker. See Docker
import pgs "github.com/mbiamont/go-pgs-converter"
subs, err := pgs.ConvertToSubtitles("input.sup", &pgs.ConversionOptions{
InputLanguage: "eng",
})
subs, err := pgs.ConvertToSubtitles("input.sup", &pgs.ConversionOptions{
InputLanguage: "eng",
TextCorrection: func(s string) string {
output := s
strings.ReplaceAll(output, "|", "I")
return output
},
})
subs, err := pgs.ConvertToSubtitles("input.sup", nil)
if err != nil {
panic(err)
}
f, err := os.Create("output.srt")
if err != nil {
panic(err)
}
err = subs.WriteToSRT(f)
Example of a Dockerfile to run go-pgs-converter
FROM golang:1.20 as builder
WORKDIR /app
RUN apt-get update -qq
RUN apt-get install -y -qq libtesseract-dev libleptonica-dev
COPY go.* ./
RUN go mod download
COPY . ./
RUN GOOS=linux go build -o YOUR_PROJECT_NAME_HERE
FROM debian:11.6
RUN apt-get update -qq
RUN apt-get install -y -qq ca-certificates tesseract-ocr tesseract-ocr-eng tesseract-ocr-fra ## Add as many languages you need
COPY --from=builder /app/YOUR_PROJECT_NAME_HERE /YOUR_PROJECT_NAME_HERE
CMD ["/YOUR_PROJECT_NAME_HERE"]