nihalaninihal commited on
Commit
4ba56a4
·
verified ·
1 Parent(s): 1cb3f1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -9,6 +9,9 @@ import asyncio
9
  from google import genai
10
  from google.genai import types
11
 
 
 
 
12
 
13
  def save_binary_file(file_name, data):
14
  """Save binary data to a file."""
@@ -75,11 +78,10 @@ def fetch_web_content(url, progress=gr.Progress()):
75
  """Fetch and analyze web content using Gemini with tools."""
76
  progress(0.1, desc="Initializing Gemini client...")
77
 
78
- api_key = os.environ.get("GEMINI_API_KEY")
79
- if not api_key:
80
- raise ValueError("GEMINI_API_KEY environment variable is not set")
81
 
82
- client = genai.Client(api_key=api_key)
83
 
84
  progress(0.2, desc="Fetching web content...")
85
 
@@ -126,11 +128,10 @@ def generate_podcast_from_content(content_text, speaker1_name="Anna Chope", spea
126
  """Generate audio podcast from text content."""
127
  progress(0.7, desc="Generating podcast audio...")
128
 
129
- api_key = os.environ.get("GEMINI_API_KEY")
130
- if not api_key:
131
- raise ValueError("GEMINI_API_KEY environment variable is not set")
132
 
133
- client = genai.Client(api_key=api_key)
134
 
135
  model = "gemini-2.5-flash-preview-tts"
136
 
@@ -328,7 +329,7 @@ def create_interface():
328
 
329
  gr.Markdown("""
330
  ---
331
- **Note:** This app requires a Gemini API key to function. Make sure the `GEMINI_API_KEY` environment variable is set.
332
 
333
  The generated podcast will feature two AI voices having a natural conversation about the website content.
334
  """)
@@ -338,4 +339,4 @@ def create_interface():
338
 
339
  if __name__ == "__main__":
340
  demo = create_interface()
341
- demo.launch()
 
9
  from google import genai
10
  from google.genai import types
11
 
12
+ # Direct API key - WARNING: This is not recommended for production use
13
+ GEMINI_API_KEY = "AIzaSyDy5hjn9NFamWhBjqsVsD2WSoFNr2MrHSw"
14
+
15
 
16
  def save_binary_file(file_name, data):
17
  """Save binary data to a file."""
 
78
  """Fetch and analyze web content using Gemini with tools."""
79
  progress(0.1, desc="Initializing Gemini client...")
80
 
81
+ if not GEMINI_API_KEY:
82
+ raise ValueError("GEMINI_API_KEY is not set")
 
83
 
84
+ client = genai.Client(api_key=GEMINI_API_KEY)
85
 
86
  progress(0.2, desc="Fetching web content...")
87
 
 
128
  """Generate audio podcast from text content."""
129
  progress(0.7, desc="Generating podcast audio...")
130
 
131
+ if not GEMINI_API_KEY:
132
+ raise ValueError("GEMINI_API_KEY is not set")
 
133
 
134
+ client = genai.Client(api_key=GEMINI_API_KEY)
135
 
136
  model = "gemini-2.5-flash-preview-tts"
137
 
 
329
 
330
  gr.Markdown("""
331
  ---
332
+ **Note:** API key is now directly embedded in the code for convenience.
333
 
334
  The generated podcast will feature two AI voices having a natural conversation about the website content.
335
  """)
 
339
 
340
  if __name__ == "__main__":
341
  demo = create_interface()
342
+ demo.launch(debug=True)