Daniel Tse
commited on
Commit
•
bf628b5
1
Parent(s):
36688d2
Use whisper
Browse files
app.py
CHANGED
@@ -25,15 +25,16 @@ def transcribe_audio(audiofile):
|
|
25 |
podcast_chunks = podcast[::chunk_length_five_minutes]
|
26 |
|
27 |
st.info('Transcribing...')
|
|
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
transcription =
|
37 |
|
38 |
st.session_state['transcription'] = transcription
|
39 |
print(f"transcription: {transcription}")
|
|
|
25 |
podcast_chunks = podcast[::chunk_length_five_minutes]
|
26 |
|
27 |
st.info('Transcribing...')
|
28 |
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
29 |
|
30 |
+
pipe = pipeline(
|
31 |
+
"automatic-speech-recognition",
|
32 |
+
model="openai/whisper-large-v2",
|
33 |
+
chunk_length_s=30,
|
34 |
+
device=device,
|
35 |
+
)
|
36 |
+
|
37 |
+
transcription = pipe(audiofile, batch_size=8)["text"]
|
38 |
|
39 |
st.session_state['transcription'] = transcription
|
40 |
print(f"transcription: {transcription}")
|