Spaces:
Runtime error
Runtime error
Madiharehan
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,34 @@
|
|
1 |
-
# Import necessary libraries
|
2 |
import os
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Load Whisper model
|
15 |
model = whisper.load_model("base")
|
@@ -79,3 +98,4 @@ iface = gr.Interface(
|
|
79 |
|
80 |
# Launch the interface
|
81 |
iface.launch()
|
|
|
|
|
|
1 |
import os
|
2 |
+
import sys
|
3 |
|
4 |
+
# Function to check and install required libraries
|
5 |
+
def install_libraries():
|
6 |
+
try:
|
7 |
+
import whisper
|
8 |
+
import gtts
|
9 |
+
import gradio as gr
|
10 |
+
from groq import Groq
|
11 |
+
except ImportError:
|
12 |
+
print("Required libraries not found. Installing now...")
|
13 |
+
os.system("pip install git+https://github.com/openai/whisper.git gtts gradio groq")
|
14 |
+
# Try to import again after installation
|
15 |
+
try:
|
16 |
+
import whisper
|
17 |
+
import gtts
|
18 |
+
import gradio as gr
|
19 |
+
from groq import Groq
|
20 |
+
except ImportError:
|
21 |
+
print("Failed to install required libraries. Please install them manually.")
|
22 |
+
sys.exit(1)
|
23 |
+
|
24 |
+
# Call the install function
|
25 |
+
install_libraries()
|
26 |
+
|
27 |
+
# Now we can safely import the libraries
|
28 |
+
import whisper
|
29 |
+
import gtts
|
30 |
+
import gradio as gr
|
31 |
+
from groq import Groq
|
32 |
|
33 |
# Load Whisper model
|
34 |
model = whisper.load_model("base")
|
|
|
98 |
|
99 |
# Launch the interface
|
100 |
iface.launch()
|
101 |
+
|