• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 13 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Django-Audiofield is a simple app that allows Audio files upload, management and conversion to different audio format (mp3, wav & ogg), which also makes it easy to play audio files into your Django application.

Django-Audiofield

Description:Django Audio Management Tools
Maintainer:Areski
Contributors:list of contributors
Latest Version Downloads Supported Python versions License

Django-Audiofield is a simple app that allows Audio files upload, management and conversion to different audio format (mp3, wav & ogg), which also makes it easy to play audio files into your Django application.

We are using the HTML5 and Flash audio player SoundManager2

https://github.com/Star2Billing/django-audiofield/raw/master/docs/source/_static/django-admin-audiofield.png

https://github.com/Star2Billing/django-audiofield/raw/master/docs/source/_static/django-admin-audiofield-upload.png

Installation

Install Django-Audiofield:

python setup.py install

Dependencies

Install dependencies on Debian:

apt-get -y install libsox-fmt-mp3 libsox-fmt-all mpg321 dir2ogg ffmpeg

Note: For Debian version 7 (Wheezy) and older, replace ffmpeg with libav-tools

Install dependencies on Redhat/CentOS:

yum -y install python-setuptools libsox-fmt-mp3 libsox-fmt-all mpg321 dir2ogg

Install avconv on Redhat/CentOS:

git clone git://git.libav.org/libav.git
cd libav
sudo ./configure --disable-yasm
sudo make
sudo make install

Settings

in your settings.py file:

# Set Following variable
MEDIA_ROOT = ''
MEDIA_URL = ''

In MIDDLEWARE_CLASSES add 'audiofield.middleware.threadlocals.ThreadLocals'

In INSTALLED_APPS add 'audiofield'

# Frontend widget values
# 0-Keep original, 1-Mono, 2-Stereo
CHANNEL_TYPE_VALUE = 0

# 0-Keep original, 8000-8000Hz, 16000-16000Hz, 22050-22050Hz,
# 44100-44100Hz, 48000-48000Hz, 96000-96000Hz
FREQ_TYPE_VALUE = 8000

# 0-Keep original, 1-Convert to MP3, 2-Convert to WAV, 3-Convert to OGG
CONVERT_TYPE_VALUE = 0

Usage

Add the following lines in your models.py file:

from django.conf import settings
from audiofield.fields import AudioField
import os.path

# Add the audio field to your model
audio_file = AudioField(upload_to='your/upload/dir', blank=True,
                        ext_whitelist=(".mp3", ".wav", ".ogg"),
                        help_text=("Allowed type - .mp3, .wav, .ogg"))

# Add this method to your model
def audio_file_player(self):
    """audio player tag for admin"""
    if self.audio_file:
        file_url = settings.MEDIA_URL + str(self.audio_file)
        player_string = '<audio src="%s" controls>Your browser does not support the audio element.</audio>' % (file_url)
        return player_string

audio_file_player.allow_tags = True
audio_file_player.short_description = ('Audio file player')

Add the following lines in your admin.py:

from your_app.models import your_model_name

# add 'audio_file_player' tag to your admin view
list_display = (..., 'audio_file_player', ...)
actions = ['custom_delete_selected']

def custom_delete_selected(self, request, queryset):
    #custom delete code
    n = queryset.count()
    for i in queryset:
        if i.audio_file:
            if os.path.exists(i.audio_file.path):
                os.remove(i.audio_file.path)
        i.delete()
    self.message_user(request, ("Successfully deleted %d audio files.") % n)
custom_delete_selected.short_description = "Delete selected items"

def get_actions(self, request):
    actions = super(AudioFileAdmin, self).get_actions(request)
    del actions['delete_selected']
    return actions

Then perform following commands to create the table and collect the static files:

./manage.py syncdb
./manage.py collectstatic

Create audiofield.log file:

touch /var/log/audio-field.log

Contributing

If you've found a bug, implemented a feature or customized the template and think it is useful then please consider contributing. Patches, pull requests or just suggestions are welcome!

Source code: http://github.com/Star2Billing/django-audiofield

Bug tracker: https://github.com/Star2Billing/django-audiofield/issues

Documentation

Documentation is available on 'Read the Docs': http://django-audiofield.readthedocs.org

Credit

Django-audiofield is a Star2Billing-Sponsored Community Project, for more information visit http://www.star2billing.com or email us at [email protected]

License

Django-Audiofield is licensed under MIT, see MIT-LICENSE.txt.

TODO

More Repositories

1

python-nvd3

Python Wrapper for NVD3 - It's time for beautiful charts
Python
658
star
2

django-nvd3

Django wrapper for nvd3 - It's time for beautiful charts
Python
415
star
3

django-admin-tools-stats

Django-admin-tools-stats is a Django admin module that allow you to create easily charts on your dashboard based on specific models and criterias
Python
284
star
4

django-frontend-notification

Django application to display on the frontend the list of notifications and run some basic actions such as "view all notifications", "delete notifications", it also provides helpers to display notifications
Python
30
star
5

a2billing-flask-api

Restful A2Billing APIs in Flask
Python
20
star
6

ansible-golang-stack

Ansible Playbook for setting up a Golang app with Supervisor & PostgreSQL,
16
star
7

cdr-pusher

CDR-Pusher is a Go Application that push CDRs to PostgreSQL or Riak
Go
16
star
8

freeswitch_realtime

Push FreeSWITCH Realtime info to InfluxDB & PostgreSQL
Elixir
14
star
9

freeswitch-telegraf-plugin

Telegraf plugin for FreeSWITCH
Python
12
star
10

django-sms-gateway

Send (and receive) SMS through a web gateway. Requires an account with a gateway company. Fork from https://bitbucket.org/schinckel/django-sms-gateway/
Python
10
star
11

wikipbx

WikiPBX is an open source PBX web interface for FreeSWITCH. WikiPBX is written in python and uses the Django web application framework. Clone from https://launchpad.net/wikipbx
JavaScript
8
star
12

a2b-cust

A2Billing Customer interface
JavaScript
6
star
13

django-lets-go

Django mix of goodies, common snippets, templatetags and more
Python
6
star
14

sms-khomp-api

HTTP API Gateway for KHOMP SMS
Python
4
star
15

fs_channels_influxdb

Collect and push channels information from FreeSWITCH Sqlite to InfluxDB
Elixir
3
star
16

go-pinguino

Go daemon/service that performs a list of actions based on the result of Http Get or Ping
Go
3
star
17

newfies-dialer-docs

Documentation for Newfies-Dailer Project
JavaScript
3
star
18

excdr-pusher

CDR-Pusher collect CDRs from SQLite & push them to PostgreSQL
Elixir
3
star
19

django-dilla

django model content generator [clone of http://gitweb.codeendeavor.com/?p=dilla.git;a=summary]
Python
2
star
20

cookiecutter-lua

Cookiecutter template for a Lua package
Lua
2
star
21

erlplay

Play around with Erlang
Erlang
2
star
22

gotelium

Distributed cloud Telecom data storage
Go
1
star
23

wow-goodies

Misc of things mixed with stuff and with more things
PHP
1
star
24

ex-chitchat

Chitchat Phoenix application
Elixir
1
star
25

lua-lfs-cache

Easily power a caching system based on Filesystem with Lua
Lua
1
star
26

graphql-crud-auth

ReactJS/Apollo/GraphQL Application to demonstrate how to create CRUD with filters and authentication
JavaScript
1
star
27

asterisk-stats

Asterisk-Stats - Old code added for archive (Don't use this project check replacement CDR-Stats.org)
PHP
1
star
28

echo-server-elixir

playground to test deployment
Elixir
1
star