File tree Expand file tree Collapse file tree 3 files changed +34
-10
lines changed Expand file tree Collapse file tree 3 files changed +34
-10
lines changed Original file line number Diff line number Diff line change @@ -424,23 +424,24 @@ def w(x): file.write(x)
424
424
for channel in channels :
425
425
if channel :
426
426
os .environ ['DLAL_PAN_FLIP' ] = channel
427
- p = subprocess .Popen (invocation , shell = True )
428
- signal .signal (signal .SIGINT , lambda * args : p .send_signal (signal .SIGINT ))
429
- p .wait ()
427
+ subprocess .run (invocation , shell = True , check = True )
430
428
if args .stereo :
431
429
name = Path (args .run [0 ]).stem
432
430
l = Path (name + 'l.flac' )
433
431
r = Path (name + 'r.flac' )
434
432
if l .exists () and r .exists ():
435
433
o = name + '.flac'
436
434
print (f'combining into { o } ' )
437
- subprocess .run ([
438
- 'python3' ,
439
- 'systems/lr_combine.py' ,
440
- l ,
441
- r ,
442
- o ,
443
- ])
435
+ subprocess .run (
436
+ [
437
+ 'python3' ,
438
+ 'systems/lr_combine.py' ,
439
+ l ,
440
+ r ,
441
+ o ,
442
+ ],
443
+ check = True ,
444
+ )
444
445
445
446
# ===== deploy ===== #
446
447
if args .deploy :
Original file line number Diff line number Diff line change @@ -22,6 +22,18 @@ def to_i16le(self, file_path='out.i16le'):
22
22
def to_flac (self , file_path = 'out.flac' ):
23
23
sf .write (file_path , self .samples , self .sample_rate , format = 'FLAC' )
24
24
25
+ def to_ogg (self , file_path = 'out.ogg' ):
26
+ # soundfile crashes!
27
+ # https://github.com/bastibe/python-soundfile/issues/233
28
+ # https://github.com/bastibe/python-soundfile/issues/266
29
+ # https://github.com/bastibe/python-soundfile/issues/396
30
+ # https://github.com/bastibe/python-soundfile/issues/426
31
+ # sf.write(file_path, self.samples, self.sample_rate, format='OGG')
32
+ self .to_flac ('tmp.flac' )
33
+ p = _subprocess .run (f'ffmpeg -y -i tmp.flac { file_path } ' .split (), stderr = _subprocess .PIPE )
34
+ if p .returncode :
35
+ raise Exception (f'ffmpeg returned non-zero exit status { p .returncode } \n stderr:\n { p .stderr .decode ()} ' )
36
+
25
37
def normalize (self ):
26
38
m = 1 / max (abs (i ) for i in self .samples )
27
39
self .samples = [i * m for i in self .samples ]
Original file line number Diff line number Diff line change
1
+ import dlal
2
+
3
+ import argparse
4
+ from pathlib import Path
5
+
6
+ parser = argparse .ArgumentParser ()
7
+ parser .add_argument ('in_path' , type = Path )
8
+ args = parser .parse_args ()
9
+
10
+ sound = dlal .sound .read (args .in_path )
11
+ sound .to_ogg (args .in_path .with_suffix ('.ogg' ))
You can’t perform that action at this time.
0 commit comments