RiteshAkhade commited on
Commit
29b356d
·
verified ·
1 Parent(s): c9900d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -1,9 +1,13 @@
 
1
  import whisper
2
  import gradio as gr
3
  import torch
4
  from transformers import BertTokenizer, BertForSequenceClassification, pipeline
5
  from app.questions import get_question
6
 
 
 
 
7
  # Load models
8
  whisper_model = whisper.load_model("small")
9
  confidence_model = BertForSequenceClassification.from_pretrained('RiteshAkhade/final_confidence')
@@ -116,7 +120,7 @@ def transcribe_and_analyze_tech(audio, question):
116
  except Exception as e:
117
  return f"Error: {str(e)}", "", ""
118
 
119
- # UI layout
120
  with gr.Blocks(css="textarea, .gr-box { font-size: 18px !important; }") as demo:
121
  gr.HTML("<h1 style='text-align: center; font-size: 32px;'>INTERVIEW PREPARATION MODEL</h1>")
122
 
@@ -157,10 +161,22 @@ with gr.Blocks(css="textarea, .gr-box { font-size: 18px !important; }") as demo:
157
  context_analysis_result, confidence_analysis_result])
158
 
159
  if __name__ == "__main__":
160
- import os
161
 
162
- # Force disable API mode specifically for Hugging Face Spaces
163
  if "SPACE_ID" in os.environ:
164
- demo.launch(share=False, show_api=False, api_mode=False)
 
 
 
 
 
 
 
 
 
 
 
165
  else:
166
- demo.launch(share=True, show_api=False)
 
 
1
+ import os
2
  import whisper
3
  import gradio as gr
4
  import torch
5
  from transformers import BertTokenizer, BertForSequenceClassification, pipeline
6
  from app.questions import get_question
7
 
8
+ # Set environment variable to disable analytics before importing gradio
9
+ os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
10
+
11
  # Load models
12
  whisper_model = whisper.load_model("small")
13
  confidence_model = BertForSequenceClassification.from_pretrained('RiteshAkhade/final_confidence')
 
120
  except Exception as e:
121
  return f"Error: {str(e)}", "", ""
122
 
123
+ # UI layout with analytics disabled
124
  with gr.Blocks(css="textarea, .gr-box { font-size: 18px !important; }") as demo:
125
  gr.HTML("<h1 style='text-align: center; font-size: 32px;'>INTERVIEW PREPARATION MODEL</h1>")
126
 
 
161
  context_analysis_result, confidence_analysis_result])
162
 
163
  if __name__ == "__main__":
164
+ import sys
165
 
166
+ # Disable all API-related functionality without using api_mode parameter
167
  if "SPACE_ID" in os.environ:
168
+ try:
169
+ # First attempt - with analytics disabled but no api_mode
170
+ demo.launch(share=False, show_api=False)
171
+ except Exception as e:
172
+ print(f"First launch attempt failed: {str(e)}", file=sys.stderr)
173
+ try:
174
+ # Second attempt - with additional flags
175
+ demo.launch(share=False, show_api=False, enable_queue=False)
176
+ except Exception as e:
177
+ print(f"Second launch attempt failed: {str(e)}", file=sys.stderr)
178
+ # Last resort - minimal launch
179
+ demo.launch()
180
  else:
181
+ # For local development
182
+ demo.launch(share=True, show_api=False)