CineAI commited on
Commit
6b2a0ad
1 Parent(s): cbd5d1a

Update audio2text/a2t.py

Browse files
Files changed (1) hide show
  1. audio2text/a2t.py +6 -5
audio2text/a2t.py CHANGED
@@ -19,6 +19,12 @@ class A2T:
19
  return transcribed_text
20
 
21
  def __preprocces(self, raw: np.ndarray, sampling_rate: int):
 
 
 
 
 
 
22
  chunk = raw.astype(np.float32, order='C') / 32768.0
23
 
24
  print(f"Chunk : {chunk} max chunk : {np.max(chunk)}")
@@ -26,11 +32,6 @@ class A2T:
26
  if len(chunk.shape) > 1:
27
  chunk = librosa.to_mono(chunk.T)
28
 
29
- if sampling_rate != SAMPLING_RATE:
30
- chunk = librosa.resample(chunk, orig_sr=sampling_rate, target_sr=SAMPLING_RATE)
31
-
32
- print(f"Sampling rate : {chunk} max chunk : {np.max(chunk)}")
33
-
34
  chunk = chunk[:SAMPLING_RATE*LIMIT]
35
 
36
  print(f"Chunk cut : {chunk} max chunk : {np.max(chunk)}")
 
19
  return transcribed_text
20
 
21
  def __preprocces(self, raw: np.ndarray, sampling_rate: int):
22
+
23
+ if sampling_rate != SAMPLING_RATE:
24
+ raw = librosa.resample(raw, orig_sr=sampling_rate, target_sr=SAMPLING_RATE)
25
+
26
+ print(f"Sampling rate : {raw} max chunk : {np.max(raw)}")
27
+
28
  chunk = raw.astype(np.float32, order='C') / 32768.0
29
 
30
  print(f"Chunk : {chunk} max chunk : {np.max(chunk)}")
 
32
  if len(chunk.shape) > 1:
33
  chunk = librosa.to_mono(chunk.T)
34
 
 
 
 
 
 
35
  chunk = chunk[:SAMPLING_RATE*LIMIT]
36
 
37
  print(f"Chunk cut : {chunk} max chunk : {np.max(chunk)}")