Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mp3 converter #147

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compose/local/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg2 dependencies
libpq-dev
libpq-dev \
# Install pydub dependencies
ffmpeg libavcodec-extra

# Requirements are installed here to ensure they will be cached.
COPY ./requirements .
Expand Down
6 changes: 4 additions & 2 deletions compose/production/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg2 dependencies
libpq-dev
libpq-dev \
# Install pydub dependencies
ffmpeg libavcodec-extra

# Requirements are installed here to ensure they will be cached.
COPY ./requirements .
Expand All @@ -35,7 +37,7 @@ ENV BUILD_ENV ${BUILD_ENVIRONMENT}
WORKDIR ${APP_HOME}

RUN addgroup --system django \
&& adduser --system --ingroup django django
&& adduser --system --ingroup django django


# Install required system dependencies
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ hiredis==2.3.2 # https://github.com/redis/hiredis-py
celery==5.3.6 # pyup: < 6.0 # https://github.com/celery/celery
django-celery-beat==2.6.0 # https://github.com/celery/django-celery-beat
flower==2.0.1 # https://github.com/mher/flower
pydub==0.25.1 # https://github.com/jiaaro/pydub

# Django
# ------------------------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions rocket_connect/plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
import urllib.parse
from io import BytesIO
from pydub import AudioSegment

import qrcode
import requests
Expand Down Expand Up @@ -177,6 +178,16 @@ def outcome_file(self, base64_data, room_id, mime, filename=None, description=No
if mime == "image/webp":
extension = ".webp"

# Convert ogg audio to mp3 (To play on iPhone)
if mime == "audio/ogg; codecs=opus":
ogg_io = BytesIO(filedata)
ogg_audio = AudioSegment.from_file(ogg_io, format='ogg')
mp3_data = ogg_audio.export(format="mp3").read()
mp3_b64 = base64.b64encode(mp3_data)
filedata = base64.b64decode(mp3_b64)
mime = "audio/mpeg"
extension = ".mp3"

if not filename:
# random filename
filename = (
Expand Down
Loading