mirix commited on
Commit
519bb97
1 Parent(s): a6db41a

Upload 2 files

Browse files
Files changed (2) hide show
  1. parquet2csv_wav.py +38 -0
  2. sqe_messai_nowav.csv +0 -0
parquet2csv_wav.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # REQUIREMENTS
2
+ # $ pip install scipy
3
+ # $ pip install "polars[all]"
4
+ # You may need to install snappy in order to run this script:
5
+ # $ sudo pacman -S snappy
6
+ # $ pip install python-snappy
7
+
8
+ import polars as pl
9
+ import numpy as np
10
+ from scipy.io.wavfile import write
11
+
12
+ import os
13
+ n_cores = str(os.cpu_count())
14
+ os.environ['OMP_NUM_THREADS'] = n_cores
15
+ os.environ['MKL_NUM_THREADS'] = n_cores
16
+
17
+ if not os.path.isdir('wavs'):
18
+ os.makedirs('wavs')
19
+
20
+ columns = ['ytid', 'ytid_seg', 'start', 'end', 'sentiment', 'happiness', 'sadness', 'anger', 'fear', 'disgust', 'surprise']
21
+
22
+ df = pl.read_parquet('sqe_messai.parquet', columns = columns)
23
+
24
+ df.write_csv('sqe_messai_nowav.csv')
25
+
26
+ print(df)
27
+
28
+ columns2 = ['ytid_seg', 'wav2numpy']
29
+
30
+ df2 = pl.read_parquet('sqe_messai.parquet', use_pyarrow=False, columns = columns2)
31
+
32
+ def numpy2wav(row):
33
+ segment = os.path.splitext(os.path.basename(os.path.normpath(row[0])))[0]
34
+ print('PROCESSED:', segment)
35
+ write('wavs/' + segment + '.wav', 16000, np.array(row[1]))
36
+ return segment
37
+
38
+ df2.apply(lambda x: numpy2wav(x))
sqe_messai_nowav.csv ADDED
The diff for this file is too large to render. See raw diff