Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -54,9 +54,9 @@ device = torch.device('cuda')
|
|
54 |
#device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
55 |
|
56 |
#@spaces.GPU
|
57 |
-
def transcribe(
|
58 |
|
59 |
-
file = microphone if microphone is not None else
|
60 |
start_time = time.time()
|
61 |
|
62 |
#--------------____________________________________________--------------"
|
@@ -67,6 +67,23 @@ def transcribe(microphone, file_upload, progress=gr.Progress(track_tqdm=True)):
|
|
67 |
|
68 |
with torch.no_grad():
|
69 |
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", device=device)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
|
72 |
text = pipe(file)["text"]
|
|
|
54 |
#device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
55 |
|
56 |
#@spaces.GPU
|
57 |
+
def transcribe(file_upload, progress=gr.Progress(track_tqdm=True)): # microphone
|
58 |
|
59 |
+
file = file_upload # microphone if microphone is not None else
|
60 |
start_time = time.time()
|
61 |
|
62 |
#--------------____________________________________________--------------"
|
|
|
67 |
|
68 |
with torch.no_grad():
|
69 |
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", device=device)
|
70 |
+
|
71 |
+
"""
|
72 |
+
# -- chunking
|
73 |
+
chunks = chunk_audio(file, chunk_length_ms=30000, overlap_length_ms=5000)
|
74 |
+
|
75 |
+
full_transcription = []
|
76 |
+
for chunk in chunks:
|
77 |
+
# -- convert chunk to temporary file-like object
|
78 |
+
temp_audio = chunk.export(format="wav")
|
79 |
+
|
80 |
+
# -- transcribe chunk
|
81 |
+
text = pipe(temp_audio)["text"]
|
82 |
+
full_transcription.append(text)
|
83 |
+
|
84 |
+
# -- join chunk transcriptions
|
85 |
+
full_text = " ".join(full_transcription)
|
86 |
+
"""
|
87 |
|
88 |
|
89 |
text = pipe(file)["text"]
|