diff --git a/Dockerfile b/Dockerfile index 35fc1b6..057a70a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/core/audio.go b/core/audio.go index 96d96b9..cac0c87 100644 --- a/core/audio.go +++ b/core/audio.go @@ -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()