RathodHarish commited on
Commit
5963146
·
verified ·
1 Parent(s): 45a579f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -37
app.py CHANGED
@@ -5,13 +5,6 @@ import numpy as np
5
  import os
6
  import hashlib
7
  from datetime import datetime
8
- from simple_salesforce import Salesforce
9
-
10
- # Salesforce credentials (store securely in environment variables)
11
- SF_USERNAME = os.getenv("SF_USERNAME", "[email protected]")
12
- SF_PASSWORD = os.getenv("SF_PASSWORD", "voicebot1")
13
- SF_SECURITY_TOKEN = os.getenv("SF_SECURITY_TOKEN", "jq4VVHUFti6TmzJDjjegv2h6b")
14
- SF_INSTANCE_URL = os.getenv("SF_INSTANCE_URL", "https://voicebot-dev-ed.my.salesforce.com") # Verify correct API URL
15
 
16
  # Hugging Face Inference API token (store in environment variables)
17
  HF_TOKEN = os.getenv("HF_TOKEN") # Must be set in Space secrets
@@ -19,18 +12,6 @@ HF_TOKEN = os.getenv("HF_TOKEN") # Must be set in Space secrets
19
  # Log HF_TOKEN status at startup
20
  print(f"HF_TOKEN status: {'Set' if HF_TOKEN else 'Not set'}")
21
 
22
- # Initialize Salesforce connection
23
- try:
24
- sf = Salesforce(
25
- username=SF_USERNAME,
26
- password=SF_PASSWORD,
27
- security_token=SF_SECURITY_TOKEN,
28
- instance_url=SF_INSTANCE_URL
29
- )
30
- except Exception as e:
31
- print(f"Failed to connect to Salesforce: {str(e)}")
32
- sf = None
33
-
34
  # Hugging Face API endpoints
35
  WHISPER_API_URL = "https://api-inference.huggingface.co/models/openai/whisper-tiny.en"
36
  SYMPTOM_API_URL = "https://api-inference.huggingface.co/models/abhirajeshbhai/symptom-2-disease-net"
@@ -155,10 +136,6 @@ def analyze_voice(audio_file):
155
  feedback += f"\n\n**Debug Info**: Transcription = '{transcription}', Prediction = {prediction}, Confidence = {score:.4f}, File Hash = {file_hash}"
156
  feedback += "\n**Disclaimer**: This is not a diagnostic tool. Consult a healthcare provider for medical advice."
157
 
158
- # Store in Salesforce
159
- if sf:
160
- store_in_salesforce(audio_file, feedback, transcription, prediction, score)
161
-
162
  # Clean up temporary audio file
163
  try:
164
  os.remove(audio_file)
@@ -170,20 +147,6 @@ def analyze_voice(audio_file):
170
  except Exception as e:
171
  return f"Error processing audio: {str(e)}"
172
 
173
- def store_in_salesforce(audio_file, feedback, transcription, prediction, score):
174
- """Store analysis results in Salesforce."""
175
- try:
176
- sf.HealthAssessment__c.create({
177
- "AssessmentDate__c": datetime.utcnow().isoformat(),
178
- "Feedback__c": feedback,
179
- "Transcription__c": transcription,
180
- "Prediction__c": prediction,
181
- "Confidence__c": float(score),
182
- "AudioFileName__c": os.path.basename(audio_file)
183
- })
184
- except Exception as e:
185
- print(f"Failed to store in Salesforce: {str(e)}")
186
-
187
  def test_with_sample_audio():
188
  """Test the app with sample audio files."""
189
  samples = ["audio_samples/sample.wav", "audio_samples/common_voice_en.wav"]
 
5
  import os
6
  import hashlib
7
  from datetime import datetime
 
 
 
 
 
 
 
8
 
9
  # Hugging Face Inference API token (store in environment variables)
10
  HF_TOKEN = os.getenv("HF_TOKEN") # Must be set in Space secrets
 
12
  # Log HF_TOKEN status at startup
13
  print(f"HF_TOKEN status: {'Set' if HF_TOKEN else 'Not set'}")
14
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # Hugging Face API endpoints
16
  WHISPER_API_URL = "https://api-inference.huggingface.co/models/openai/whisper-tiny.en"
17
  SYMPTOM_API_URL = "https://api-inference.huggingface.co/models/abhirajeshbhai/symptom-2-disease-net"
 
136
  feedback += f"\n\n**Debug Info**: Transcription = '{transcription}', Prediction = {prediction}, Confidence = {score:.4f}, File Hash = {file_hash}"
137
  feedback += "\n**Disclaimer**: This is not a diagnostic tool. Consult a healthcare provider for medical advice."
138
 
 
 
 
 
139
  # Clean up temporary audio file
140
  try:
141
  os.remove(audio_file)
 
147
  except Exception as e:
148
  return f"Error processing audio: {str(e)}"
149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  def test_with_sample_audio():
151
  """Test the app with sample audio files."""
152
  samples = ["audio_samples/sample.wav", "audio_samples/common_voice_en.wav"]