Spaces:
Runtime error
Runtime error
Update functions.py
Browse files- functions.py +9 -9
functions.py
CHANGED
|
@@ -31,15 +31,15 @@ def load_whisper_api(audio):
|
|
| 31 |
return transcript
|
| 32 |
|
| 33 |
@st.cache_data
|
| 34 |
-
def get_transcribe_podcast(rss_url, local_path='
|
| 35 |
|
| 36 |
st.info("Starting Podcast Transcription Function...")
|
| 37 |
print("Feed URL: ", rss_url)
|
| 38 |
-
|
| 39 |
|
| 40 |
|
| 41 |
# Download the podcast episode by parsing the RSS feed
|
| 42 |
-
|
| 43 |
# p.mkdir(exist_ok=True)
|
| 44 |
|
| 45 |
st.info("Downloading the podcast episode...")
|
|
@@ -48,10 +48,10 @@ def get_transcribe_podcast(rss_url, local_path='podcast/'):
|
|
| 48 |
|
| 49 |
with requests.get(rss_url, stream=True) as r:
|
| 50 |
r.raise_for_status()
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
-
with open(
|
| 55 |
for chunk in r.iter_content(chunk_size=8192):
|
| 56 |
f.write(chunk.getbuffer())
|
| 57 |
|
|
@@ -60,7 +60,7 @@ def get_transcribe_podcast(rss_url, local_path='podcast/'):
|
|
| 60 |
# Perform the transcription
|
| 61 |
st.info("Starting podcast transcription")
|
| 62 |
|
| 63 |
-
audio_file =
|
| 64 |
|
| 65 |
|
| 66 |
#Get size of audio file
|
|
@@ -89,7 +89,7 @@ def get_transcribe_podcast(rss_url, local_path='podcast/'):
|
|
| 89 |
|
| 90 |
for i, chunk in enumerate(chunks):
|
| 91 |
chunk.export(f'chunk_{i}.mp3', format='mp3')
|
| 92 |
-
transcriptions.append(load_whisper_api(f'chunk_{i}.mp3')
|
| 93 |
|
| 94 |
results = ','.join(transcriptions)
|
| 95 |
|
|
@@ -192,7 +192,7 @@ def get_podcast_highlights(podcast_transcript):
|
|
| 192 |
return podcastHighlights
|
| 193 |
|
| 194 |
@st.cache_data
|
| 195 |
-
def process_podcast(url, path='
|
| 196 |
|
| 197 |
'''Get podcast transcription into json'''
|
| 198 |
|
|
|
|
| 31 |
return transcript
|
| 32 |
|
| 33 |
@st.cache_data
|
| 34 |
+
def get_transcribe_podcast(rss_url, local_path='/data/'):
|
| 35 |
|
| 36 |
st.info("Starting Podcast Transcription Function...")
|
| 37 |
print("Feed URL: ", rss_url)
|
| 38 |
+
print("Local Path:", local_path)
|
| 39 |
|
| 40 |
|
| 41 |
# Download the podcast episode by parsing the RSS feed
|
| 42 |
+
p = Path(local_path)
|
| 43 |
# p.mkdir(exist_ok=True)
|
| 44 |
|
| 45 |
st.info("Downloading the podcast episode...")
|
|
|
|
| 48 |
|
| 49 |
with requests.get(rss_url, stream=True) as r:
|
| 50 |
r.raise_for_status()
|
| 51 |
+
episode_path = p.joinpath(episode_name)
|
| 52 |
+
print(f'episode path {episode_path}')
|
| 53 |
|
| 54 |
+
with open(episode_path, 'wb') as f:
|
| 55 |
for chunk in r.iter_content(chunk_size=8192):
|
| 56 |
f.write(chunk.getbuffer())
|
| 57 |
|
|
|
|
| 60 |
# Perform the transcription
|
| 61 |
st.info("Starting podcast transcription")
|
| 62 |
|
| 63 |
+
audio_file = episode_path
|
| 64 |
|
| 65 |
|
| 66 |
#Get size of audio file
|
|
|
|
| 89 |
|
| 90 |
for i, chunk in enumerate(chunks):
|
| 91 |
chunk.export(f'chunk_{i}.mp3', format='mp3')
|
| 92 |
+
transcriptions.append(load_whisper_api(f'chunk_{i}.mp3'))
|
| 93 |
|
| 94 |
results = ','.join(transcriptions)
|
| 95 |
|
|
|
|
| 192 |
return podcastHighlights
|
| 193 |
|
| 194 |
@st.cache_data
|
| 195 |
+
def process_podcast(url, path='/data/'):
|
| 196 |
|
| 197 |
'''Get podcast transcription into json'''
|
| 198 |
|