Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-panik-emissions
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
django-panik-emissions
Commits
9427cf0f
Commit
9427cf0f
authored
Oct 10, 2019
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create-sound-waveforms: adapt to python3
parent
fd797ec8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
emissions/management/commands/create-sound-waveforms.py
emissions/management/commands/create-sound-waveforms.py
+6
-2
No files found.
emissions/management/commands/create-sound-waveforms.py
View file @
9427cf0f
...
...
@@ -4,6 +4,7 @@ import subprocess
import
numpy
as
np
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.utils
import
six
from
...models
import
SoundFile
...
...
@@ -52,5 +53,8 @@ class Command(BaseCommand):
'-e'
'unsigned-integer'
,
'-b'
,
'8'
,
'-'
]
wave_array
=
subprocess
.
check_output
(
cmd
)
# reduce to 200 samples of max positive value
wave_reduced
=
[
max
(
x
)
for
x
in
np
.
array_split
(
np
.
array
([
max
(
0
,
ord
(
x
)
-
128
)
for
x
in
wave_array
]),
200
)]
json
.
dump
(
wave_reduced
,
file
(
file_path
,
'w'
))
if
six
.
PY3
:
wave_reduced
=
[
int
(
max
(
x
))
for
x
in
np
.
array_split
(
np
.
array
([
max
(
0
,
x
-
128
)
for
x
in
wave_array
]),
200
)]
else
:
wave_reduced
=
[
max
(
x
)
for
x
in
np
.
array_split
(
np
.
array
([
max
(
0
,
ord
(
x
)
-
128
)
for
x
in
wave_array
]),
200
)]
json
.
dump
(
wave_reduced
,
open
(
file_path
,
'w'
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment