camparchimedes commited on
Commit
f8b8cd5
·
verified ·
1 Parent(s): 69c8040

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -32,6 +32,7 @@ from pathlib import Path
32
 
33
  import numpy as np
34
  import soundfile as sf
 
35
  import torch
36
  from transformers import pipeline
37
 
@@ -60,9 +61,9 @@ def transcribe(file_upload, progress=gr.Progress(track_tqdm=True)):
60
  file = file_upload # microphone if microphone is not None else
61
  start_time = time.time()
62
 
63
- # -- ex subrosa ad sf
64
- audio, sr = sf.load(file_upload, sr=None)
65
- duration = sf.get_duration(y=audio, sr=sr)
66
 
67
  # -- asr pipeline
68
  with torch.no_grad():
@@ -78,8 +79,14 @@ def transcribe(file_upload, progress=gr.Progress(track_tqdm=True)):
78
  # -- convert audio chunk to format for pipeline
79
  chunk_file = "temp_chunk.wav"
80
  sf.write(chunk_file, chunk, sr)
81
-
82
-
 
 
 
 
 
 
83
  # -- chnk ad transcriptrauma
84
  chunk_text = pipe(chunk_file)["text"]
85
  text += chunk_text + " "
 
32
 
33
  import numpy as np
34
  import soundfile as sf
35
+ import librosa
36
  import torch
37
  from transformers import pipeline
38
 
 
61
  file = file_upload # microphone if microphone is not None else
62
  start_time = time.time()
63
 
64
+ # -- ex subrosa
65
+ audio, sr = librosa.load(file_upload, sr=None)
66
+ duration = librosa.get_duration(y=audio, sr=sr)
67
 
68
  # -- asr pipeline
69
  with torch.no_grad():
 
79
  # -- convert audio chunk to format for pipeline
80
  chunk_file = "temp_chunk.wav"
81
  sf.write(chunk_file, chunk, sr)
82
+
83
+
84
+
85
+ import librosa
86
+
87
+
88
+
89
+
90
  # -- chnk ad transcriptrauma
91
  chunk_text = pipe(chunk_file)["text"]
92
  text += chunk_text + " "