Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,18 +3,17 @@ import tempfile
|
|
3 |
import os
|
4 |
import google.generativeai as genai
|
5 |
|
6 |
-
|
7 |
# Configure Google API for audio summarization
|
8 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
9 |
genai.configure(api_key=GOOGLE_API_KEY)
|
10 |
|
11 |
-
def summarize_audio(audio_file_path):
|
12 |
"""Summarize the audio using Google's Generative API."""
|
13 |
model = genai.GenerativeModel("models/gemini-1.5-pro-latest")
|
14 |
audio_file = genai.upload_file(path=audio_file_path)
|
15 |
response = model.generate_content(
|
16 |
[
|
17 |
-
|
18 |
audio_file
|
19 |
]
|
20 |
)
|
@@ -36,7 +35,7 @@ st.title('Your AI Audio Summarization App')
|
|
36 |
with st.expander("About Summarization app"):
|
37 |
st.write("""
|
38 |
This application utilizes Google's generative AI to summarise the content of audio files.
|
39 |
-
Simply upload your WAV or MP3 file to receive a brief summary of its contents.
|
40 |
""")
|
41 |
|
42 |
audio_file = st.file_uploader("Upload Audio File", type=['wav', 'mp3'])
|
@@ -44,9 +43,11 @@ if audio_file is not None:
|
|
44 |
audio_path = save_uploaded_file(audio_file) # Save the uploaded file and get the path
|
45 |
st.audio(audio_path)
|
46 |
|
|
|
|
|
47 |
if st.button('Summarize Audio'):
|
48 |
with st.spinner('Please Wait : Summarizing...'):
|
49 |
-
summary_text = summarize_audio(audio_path)
|
50 |
st.info(summary_text)
|
51 |
|
52 |
# Add a section to enter Google API Key
|
|
|
3 |
import os
|
4 |
import google.generativeai as genai
|
5 |
|
|
|
6 |
# Configure Google API for audio summarization
|
7 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
8 |
genai.configure(api_key=GOOGLE_API_KEY)
|
9 |
|
10 |
+
def summarize_audio(audio_file_path, prompt):
|
11 |
"""Summarize the audio using Google's Generative API."""
|
12 |
model = genai.GenerativeModel("models/gemini-1.5-pro-latest")
|
13 |
audio_file = genai.upload_file(path=audio_file_path)
|
14 |
response = model.generate_content(
|
15 |
[
|
16 |
+
prompt,
|
17 |
audio_file
|
18 |
]
|
19 |
)
|
|
|
35 |
with st.expander("About Summarization app"):
|
36 |
st.write("""
|
37 |
This application utilizes Google's generative AI to summarise the content of audio files.
|
38 |
+
Simply upload your WAV or MP3 file and provide a prompt to receive a brief summary of its contents.
|
39 |
""")
|
40 |
|
41 |
audio_file = st.file_uploader("Upload Audio File", type=['wav', 'mp3'])
|
|
|
43 |
audio_path = save_uploaded_file(audio_file) # Save the uploaded file and get the path
|
44 |
st.audio(audio_path)
|
45 |
|
46 |
+
prompt = st.text_input("Enter your prompt:", "Please summarize the following audio.")
|
47 |
+
|
48 |
if st.button('Summarize Audio'):
|
49 |
with st.spinner('Please Wait : Summarizing...'):
|
50 |
+
summary_text = summarize_audio(audio_path, prompt)
|
51 |
st.info(summary_text)
|
52 |
|
53 |
# Add a section to enter Google API Key
|