Daniel Tse
commited on
Commit
·
3e7fc84
1
Parent(s):
866ffb3
Use ASR transcription method
Browse files
app.py
CHANGED
@@ -19,6 +19,24 @@ def transcribe_audio(audiofile):
|
|
19 |
podcast_duration = podcast.duration_seconds
|
20 |
print(f"Audio Duration: {podcast_duration}")
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
return podcast_duration
|
23 |
|
24 |
st.markdown("# Podcast Q&A")
|
|
|
19 |
podcast_duration = podcast.duration_seconds
|
20 |
print(f"Audio Duration: {podcast_duration}")
|
21 |
|
22 |
+
st.info('Breaking podcast into 5 minute chunks.')
|
23 |
+
#break into 5 minute chunks
|
24 |
+
chunk_length_five_minutes = 5 * 60 * 1000
|
25 |
+
podcast_chunks = podcast[::chunk_length_five_minutes]
|
26 |
+
|
27 |
+
st.info('Transcribe')
|
28 |
+
|
29 |
+
#transcriptions = []
|
30 |
+
|
31 |
+
#for i, chunk in enumerate(podcast_chunks):
|
32 |
+
# chunk.export(f'output/chunk_{i}.mp4', format='mp4')
|
33 |
+
|
34 |
+
# following blogpost here: https://huggingface.co/blog/asr-chunking
|
35 |
+
transcribe_pipe = pipeline(model="facebook/wav2vec2-base-960h")
|
36 |
+
transcription = transcribe_pipe(audiofile, chunk_length_s=10, stride_length_s=(4, 2))
|
37 |
+
|
38 |
+
print(f"transcription: {transcription}")
|
39 |
+
|
40 |
return podcast_duration
|
41 |
|
42 |
st.markdown("# Podcast Q&A")
|