Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,13 +5,24 @@ from transformers import pipeline
|
|
5 |
from gtts import gTTS
|
6 |
from pydub import AudioSegment
|
7 |
from pydub.silence import detect_nonsilent
|
8 |
-
from
|
9 |
import re
|
10 |
from waitress import serve
|
11 |
-
from dotenv import load_dotenv
|
12 |
|
13 |
app = Flask(__name__)
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# Use whisper-small for faster processing and better speed
|
16 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
17 |
asr_model = pipeline("automatic-speech-recognition", model="openai/whisper-small", device=0 if device == "cuda" else -1)
|
@@ -72,28 +83,6 @@ def extract_name_email_phone(text):
|
|
72 |
|
73 |
return name, email, phone
|
74 |
|
75 |
-
# Get Salesforce connection using salesforce.py
|
76 |
-
sf = get_salesforce_connection()
|
77 |
-
|
78 |
-
# Load environment variables from .env file
|
79 |
-
load_dotenv()
|
80 |
-
|
81 |
-
def get_salesforce_connection():
|
82 |
-
# Load Salesforce credentials from environment variables
|
83 |
-
sf_username = os.getenv('SF_USERNAME')
|
84 |
-
sf_password = os.getenv('SF_PASSWORD')
|
85 |
-
sf_token = os.getenv('SF_SECURITY_TOKEN')
|
86 |
-
|
87 |
-
# Check if credentials are available
|
88 |
-
if not sf_username or not sf_password or not sf_token:
|
89 |
-
raise ValueError("Salesforce credentials are missing from environment variables.")
|
90 |
-
|
91 |
-
# Connect to Salesforce
|
92 |
-
sf = Salesforce(username=sf_username, password=sf_password, security_token=sf_token)
|
93 |
-
print("Connected to Salesforce successfully!")
|
94 |
-
|
95 |
-
return sf
|
96 |
-
|
97 |
# Function to create Salesforce record
|
98 |
def create_salesforce_record(name, email, phone_number):
|
99 |
try:
|
|
|
5 |
from gtts import gTTS
|
6 |
from pydub import AudioSegment
|
7 |
from pydub.silence import detect_nonsilent
|
8 |
+
from simple_salesforce import Salesforce # Import Salesforce connection
|
9 |
import re
|
10 |
from waitress import serve
|
|
|
11 |
|
12 |
app = Flask(__name__)
|
13 |
|
14 |
+
# Salesforce connection using provided credentials
|
15 |
+
sf_username = '[email protected]'
|
16 |
+
sf_password = 'Sati@1020'
|
17 |
+
sf_token = 'sSSjyhInIsUohKpG8sHzty2q'
|
18 |
+
|
19 |
+
# Establish Salesforce connection
|
20 |
+
try:
|
21 |
+
sf = Salesforce(username=sf_username, password=sf_password, security_token=sf_token)
|
22 |
+
print("Connected to Salesforce successfully!")
|
23 |
+
except Exception as e:
|
24 |
+
print(f"Failed to connect to Salesforce: {str(e)}")
|
25 |
+
|
26 |
# Use whisper-small for faster processing and better speed
|
27 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
28 |
asr_model = pipeline("automatic-speech-recognition", model="openai/whisper-small", device=0 if device == "cuda" else -1)
|
|
|
83 |
|
84 |
return name, email, phone
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
# Function to create Salesforce record
|
87 |
def create_salesforce_record(name, email, phone_number):
|
88 |
try:
|