bluenevus commited on
Commit
0c43967
·
verified ·
1 Parent(s): a5dd94a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -13,13 +13,17 @@ from dash.exceptions import PreventUpdate
13
  import requests
14
  from pytube import YouTube
15
  from pydub import AudioSegment
16
- import openai
17
 
18
  # Initialize the Dash app
19
  app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
20
 
21
- # Retrieve the OpenAI API key from Hugging Face Spaces
22
- openai.api_key = os.environ.get("OPENAI_API_KEY")
 
 
 
 
23
 
24
  def is_valid_url(url):
25
  try:
@@ -43,8 +47,10 @@ def download_audio(url):
43
 
44
  def transcribe_audio(file_path):
45
  with open(file_path, "rb") as audio_file:
46
- transcript = openai.Audio.transcribe("whisper-1", audio_file)
47
- return transcript["text"]
 
 
48
 
49
  def process_audio(contents, filename, url):
50
  if contents:
 
13
  import requests
14
  from pytube import YouTube
15
  from pydub import AudioSegment
16
+ import google.generativeai as genai
17
 
18
  # Initialize the Dash app
19
  app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
20
 
21
+ # Retrieve the Google API key from Hugging Face Spaces
22
+ GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
23
+ genai.configure(api_key=GOOGLE_API_KEY)
24
+
25
+ # Initialize Gemini model
26
+ model = genai.GenerativeModel('gemini-2.0-flash-lite')
27
 
28
  def is_valid_url(url):
29
  try:
 
47
 
48
  def transcribe_audio(file_path):
49
  with open(file_path, "rb") as audio_file:
50
+ audio_data = audio_file.read()
51
+
52
+ response = model.generate_content(audio_data)
53
+ return response.text
54
 
55
  def process_audio(contents, filename, url):
56
  if contents: