amanmibra commited on
Commit
3dfc859
1 Parent(s): 77d5702

Remove librosa

Browse files
Files changed (1) hide show
  1. server/preprocess.py +12 -6
server/preprocess.py CHANGED
@@ -7,18 +7,24 @@ import torch
7
  import torchaudio
8
  from scipy.io import wavfile
9
  import wget
 
10
 
11
  DEFAULT_SAMPLE_RATE=48000
12
  DEFAULT_WAVE_LENGTH=3
13
 
14
  def process_from_url(url):
15
  # download UI audio
16
- filename = wget.download(url)
17
- audio, sr = librosa.load(filename)
18
- wavfile.write('temp.wav', DEFAULT_SAMPLE_RATE, audio)
19
 
20
- # remove wget file
21
- os.remove(filename)
 
 
 
 
 
 
 
22
 
23
  # spec
24
  spec = process_from_filename('temp.wav')
@@ -36,7 +42,7 @@ def process_from_filename(filename, target_sample_rate=DEFAULT_SAMPLE_RATE, wav_
36
 
37
  return spec
38
 
39
- def process_raw_wav(wav, sample_rate=DEFAULT_SAMPLE_RATE, target_sample_rate=DEFAULT_SAMPLE_RATE, wav_length=DEFAULT_WAVE_LENGTH):
40
  num_samples = wav_length * target_sample_rate
41
 
42
  wav = _resample(wav, sample_rate, target_sample_rate)
 
7
  import torchaudio
8
  from scipy.io import wavfile
9
  import wget
10
+ import requests
11
 
12
  DEFAULT_SAMPLE_RATE=48000
13
  DEFAULT_WAVE_LENGTH=3
14
 
15
  def process_from_url(url):
16
  # download UI audio
17
+ req_url = requests.get(url)
 
 
18
 
19
+ with open('temp.wav', 'wb') as file:
20
+ file.write(req_url.content)
21
+
22
+
23
+ # filename = 'temp.wav'
24
+ # audio = torchaudio.load(filename)
25
+
26
+ # # remove wget file
27
+ # os.remove(filename)
28
 
29
  # spec
30
  spec = process_from_filename('temp.wav')
 
42
 
43
  return spec
44
 
45
+ def process_raw_wav(wav, sample_rate, target_sample_rate, wav_length):
46
  num_samples = wav_length * target_sample_rate
47
 
48
  wav = _resample(wav, sample_rate, target_sample_rate)