Spaces:
Sleeping
Sleeping
repo-type + rss
Browse files- rss.xml +38 -0
- run_job.py +32 -29
rss.xml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<rss version="2.0"
|
3 |
+
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
|
4 |
+
xmlns:media="http://search.yahoo.com/mrss/">
|
5 |
+
|
6 |
+
<channel>
|
7 |
+
<title>Daily Papers – Hugging Face</title>
|
8 |
+
<link>https://huggingface.co/papers</link>
|
9 |
+
<description>Listen to an AI-generated conversation about the most upvoted research paper on Hugging Face each day.</description>
|
10 |
+
<language>en-us</language>
|
11 |
+
<itunes:author>Hugging Face</itunes:author>
|
12 |
+
<itunes:summary>Each day, this podcast dives into the top trending ML paper on Hugging Face. Discussions are AI-generated — verify facts before citing.</itunes:summary>
|
13 |
+
<itunes:explicit>false</itunes:explicit>
|
14 |
+
<itunes:category text="Technology"/>
|
15 |
+
<itunes:owner>
|
16 |
+
<itunes:name>HF</itunes:name>
|
17 |
+
<itunes:email>[email protected]</itunes:email> <!-- Replace with your email -->
|
18 |
+
</itunes:owner>
|
19 |
+
<itunes:image href="https://huggingface.co/spaces/fdaudens/podcast-jobs/resolve/main/images/cover.png"/>
|
20 |
+
<image>
|
21 |
+
<url>https://huggingface.co/spaces/fdaudens/podcast-jobs/resolve/main/images/cover.png</url>
|
22 |
+
<title>Daily Papers – Hugging Face</title>
|
23 |
+
<link>https://huggingface.co/papers</link>
|
24 |
+
</image>
|
25 |
+
<lastBuildDate>Tue, 13 May 2025 10:00:00 +0000</lastBuildDate>
|
26 |
+
|
27 |
+
<!-- Example Episode -->
|
28 |
+
<item>
|
29 |
+
<title>Ep 1 – “Title of the Most Upvoted Paper”</title>
|
30 |
+
<description>Today’s top paper on Hugging Face is: “XYZ.” Listen to an AI discuss the ideas, findings, and questions it raises. (Warning: AI may hallucinate)</description>
|
31 |
+
<pubDate>Tue, 13 May 2025 10:00:00 +0000</pubDate>
|
32 |
+
<enclosure url="https://yourpodcastwebsite.com/audio/episode1.mp3" length="12345678" type="audio/mpeg"/>
|
33 |
+
<guid>https://yourpodcastwebsite.com/audio/episode1.mp3</guid>
|
34 |
+
<itunes:explicit>false</itunes:explicit>
|
35 |
+
</item>
|
36 |
+
|
37 |
+
</channel>
|
38 |
+
</rss>
|
run_job.py
CHANGED
@@ -8,21 +8,7 @@ import requests
|
|
8 |
import json
|
9 |
from datetime import datetime
|
10 |
import os
|
11 |
-
|
12 |
-
# Scan for existing podcasts in the space
|
13 |
-
def scan_podcasts():
|
14 |
-
podcast_dir = "podcasts"
|
15 |
-
|
16 |
-
if not os.path.exists(podcast_dir):
|
17 |
-
os.makedirs(podcast_dir, exist_ok=True)
|
18 |
-
return []
|
19 |
-
|
20 |
-
# Get all WAV files in the podcasts directory
|
21 |
-
podcasts = sorted([f.replace(".wav", "")
|
22 |
-
for f in os.listdir(podcast_dir)
|
23 |
-
if f.endswith(".wav")], reverse=True)
|
24 |
-
|
25 |
-
return podcasts
|
26 |
|
27 |
def submit_job(
|
28 |
inference_provider: str,
|
@@ -107,27 +93,44 @@ def main():
|
|
107 |
if audio_segments:
|
108 |
full_audio = np.concatenate(audio_segments)
|
109 |
|
110 |
-
#
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
-
#
|
|
|
116 |
today = datetime.now().strftime("%Y-%m-%d")
|
117 |
base_name = args.name
|
118 |
podcast_filename = f"{base_name}-{today}.wav"
|
119 |
-
podcast_path = os.path.join(podcast_dir, podcast_filename)
|
120 |
|
121 |
-
#
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
-
#
|
126 |
-
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
print("Temporary copy saved as podcast.wav")
|
131 |
else:
|
132 |
print("No audio generated.")
|
133 |
|
|
|
8 |
import json
|
9 |
from datetime import datetime
|
10 |
import os
|
11 |
+
import tempfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def submit_job(
|
14 |
inference_provider: str,
|
|
|
93 |
if audio_segments:
|
94 |
full_audio = np.concatenate(audio_segments)
|
95 |
|
96 |
+
# Create a temporary file
|
97 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file:
|
98 |
+
temp_path = temp_file.name
|
99 |
+
sf.write(temp_path, full_audio, sr)
|
100 |
+
|
101 |
+
# Get API token from environment
|
102 |
+
hf_token = os.environ.get("HF_TOKEN") or os.environ.get("HF_API_KEY")
|
103 |
+
if hf_token is None:
|
104 |
+
print("No Hugging Face token found in environment. Cannot upload to Space.")
|
105 |
+
return
|
106 |
+
|
107 |
+
# Initialize the Hugging Face API
|
108 |
+
api = HfApi(token=hf_token)
|
109 |
|
110 |
+
# Set up Space path info
|
111 |
+
space_id = "fdaudens/podcast-jobs" # Your Space ID
|
112 |
today = datetime.now().strftime("%Y-%m-%d")
|
113 |
base_name = args.name
|
114 |
podcast_filename = f"{base_name}-{today}.wav"
|
|
|
115 |
|
116 |
+
# Path in the Space repository
|
117 |
+
space_path = f"podcasts/{podcast_filename}"
|
118 |
+
|
119 |
+
# Upload directly to the Space (crucial: repo_type="space")
|
120 |
+
print(f"Uploading podcast to Space {space_id} at path {space_path}...")
|
121 |
+
api.upload_file(
|
122 |
+
path_or_fileobj=temp_path,
|
123 |
+
path_in_repo=space_path,
|
124 |
+
repo_id=space_id,
|
125 |
+
repo_type="space",
|
126 |
+
token=hf_token
|
127 |
+
)
|
128 |
|
129 |
+
# Clean up temporary file
|
130 |
+
os.unlink(temp_path)
|
131 |
|
132 |
+
print(f"Podcast audio uploaded to Space at {space_path}")
|
133 |
+
print(f"Access URL: https://huggingface.co/spaces/{space_id}/blob/main/{space_path}")
|
|
|
134 |
else:
|
135 |
print("No audio generated.")
|
136 |
|