1
0

ditching ffmpeg, acceptable image size

This commit is contained in:
2021-01-28 16:25:59 +01:00
parent 57249618c0
commit 939692e531
2 changed files with 7 additions and 7 deletions

View File

@ -1,3 +1,4 @@
# building the go program
FROM golang:1.15.6-alpine AS builder
RUN apk add --no-cache git
ENV GO111MODULE=on \
@ -12,12 +13,13 @@ COPY main.go ./
COPY core ./core/
RUN go build -o gogodiscordo
# downloading mbrola voice
FROM alpine as alpine_voices
WORKDIR /tmp
RUN wget --no-check-certificate https://github.com/numediart/MBROLA-voices/archive/master.zip \
&& unzip master.zip && rm master.zip
# final image
FROM ubuntu:focal as ubuntu1
SHELL ["/bin/bash", "-c"]
@ -27,19 +29,17 @@ RUN set -ex;\
apt install -y --no-install-recommends \
mbrola \
espeak-ng \
ffmpeg \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /usr/share/mbrola/
COPY --from=builder /src/gogodiscordo /app/
COPY config.yaml /app/
RUN mkdir -p /usr/share/mbrola/
COPY --from=alpine_voices /tmp/MBROLA-voices-master/data/fr* /usr/share/mbrola/
VOLUME ["/app"]
RUN useradd -d /app appuser
WORKDIR /app
CMD ["./gogodiscordo"]

View File

@ -42,8 +42,8 @@ func playSound(s *discordgo.Session, guildID, channelID string, audioBuffer []by
func getAudioMessage(msg string) (filename string, out []byte) {
curr_time := time.Now().Unix()
filename = fmt.Sprintf("%d.ogg", curr_time)
var cmd_args string = fmt.Sprintf("espeak-ng -s 120 -v mb-fr2 -p 30 '%s' --stdout | ffmpeg -i - -c:a libopus -f ogg pipe:1 2>/dev/null",
filename = fmt.Sprintf("%d.wav", curr_time)
var cmd_args string = fmt.Sprintf("espeak-ng -s 120 -v mb-fr2 -p 30 '%s' --stdout",
maxString(msg, 300))
cmd := exec.Command("sh", "-c", cmd_args)
out, err := cmd.CombinedOutput()