lokesh341 commited on
Commit
ac0022c
·
verified ·
1 Parent(s): dfacb27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -10
app.py CHANGED
@@ -38,17 +38,15 @@ def create_salesforce_record(sf, name, email, phone_number):
38
  raise Exception(f"Failed to create record: {str(e)}")
39
 
40
  def get_menu_items(sf):
41
- # Query to get menu items from Salesforce (assuming Menu_Item__c is the Salesforce object)
42
  query = "SELECT Name, Price__c, Ingredients__c, Category__c FROM Menu_Item__c"
43
  result = sf.query(query)
44
  return result['records']
45
 
46
  def create_salesforce_order(sf, cart_items, total_price, customer_id):
47
- # Creating an order record in Salesforce after the customer places the final order
48
  try:
49
  order = sf.Order__c.create({
50
  'Total_Price__c': total_price,
51
- 'Cart_Items__c': json.dumps(cart_items), # Storing cart items as JSON (you can refine this as needed)
52
  'Customer__c': customer_id # Linking to the customer record
53
  })
54
  return order
@@ -78,7 +76,7 @@ def convert_to_wav(input_path, output_path):
78
 
79
  def is_silent_audio(audio_path):
80
  audio = AudioSegment.from_wav(audio_path)
81
- nonsilent_parts = detect_nonsilent(audio, min_silence_len=500, silence_thresh=audio.dBFS-16) # Reduced silence duration
82
  print(f"Detected nonsilent parts: {nonsilent_parts}")
83
  return len(nonsilent_parts) == 0 # If no speech detected
84
 
@@ -89,7 +87,6 @@ def index():
89
 
90
  @app.route("/dashboard", methods=["GET"])
91
  def dashboard():
92
- # This route will render the dashboard page
93
  return render_template("dashboard.html") # Render the dashboard template
94
 
95
  @app.route("/menu", methods=["GET"])
@@ -101,23 +98,20 @@ def menu_page():
101
 
102
  @app.route("/cart", methods=["GET"])
103
  def cart():
104
- # Retrieve cart items from the session
105
  cart_items = session.get('cart_items', [])
106
  return render_template("cart_page.html", cart_items=cart_items)
107
 
108
  @app.route("/order-summary", methods=["GET"])
109
  def order_summary():
110
- # Retrieve order details from session
111
  order_details = session.get('cart_items', [])
112
  total_price = sum(item['price'] * item['quantity'] for item in order_details)
113
  return render_template("order_summary.html", order_details=order_details, total_price=total_price)
114
 
115
  @app.route("/final_order", methods=["GET"])
116
  def final_order():
117
- # Process the final order and create an order record in Salesforce
118
  cart_items = session.get('cart_items', [])
119
  total_price = sum(item['price'] * item['quantity'] for item in cart_items)
120
- customer_id = session.get('customer_id', None) # Get customer ID from session
121
 
122
  if customer_id:
123
  try:
@@ -131,7 +125,6 @@ def final_order():
131
 
132
  @app.route("/add_to_cart", methods=["POST"])
133
  def add_to_cart():
134
- # Add item to the cart (example for cart item data: item_name, quantity)
135
  item_name = request.json.get('item_name')
136
  quantity = request.json.get('quantity')
137
 
 
38
  raise Exception(f"Failed to create record: {str(e)}")
39
 
40
  def get_menu_items(sf):
 
41
  query = "SELECT Name, Price__c, Ingredients__c, Category__c FROM Menu_Item__c"
42
  result = sf.query(query)
43
  return result['records']
44
 
45
  def create_salesforce_order(sf, cart_items, total_price, customer_id):
 
46
  try:
47
  order = sf.Order__c.create({
48
  'Total_Price__c': total_price,
49
+ 'Cart_Items__c': json.dumps(cart_items), # Storing cart items as JSON
50
  'Customer__c': customer_id # Linking to the customer record
51
  })
52
  return order
 
76
 
77
  def is_silent_audio(audio_path):
78
  audio = AudioSegment.from_wav(audio_path)
79
+ nonsilent_parts = detect_nonsilent(audio, min_silence_len=500, silence_thresh=audio.dBFS-16)
80
  print(f"Detected nonsilent parts: {nonsilent_parts}")
81
  return len(nonsilent_parts) == 0 # If no speech detected
82
 
 
87
 
88
  @app.route("/dashboard", methods=["GET"])
89
  def dashboard():
 
90
  return render_template("dashboard.html") # Render the dashboard template
91
 
92
  @app.route("/menu", methods=["GET"])
 
98
 
99
  @app.route("/cart", methods=["GET"])
100
  def cart():
 
101
  cart_items = session.get('cart_items', [])
102
  return render_template("cart_page.html", cart_items=cart_items)
103
 
104
  @app.route("/order-summary", methods=["GET"])
105
  def order_summary():
 
106
  order_details = session.get('cart_items', [])
107
  total_price = sum(item['price'] * item['quantity'] for item in order_details)
108
  return render_template("order_summary.html", order_details=order_details, total_price=total_price)
109
 
110
  @app.route("/final_order", methods=["GET"])
111
  def final_order():
 
112
  cart_items = session.get('cart_items', [])
113
  total_price = sum(item['price'] * item['quantity'] for item in cart_items)
114
+ customer_id = session.get('customer_id', None)
115
 
116
  if customer_id:
117
  try:
 
125
 
126
  @app.route("/add_to_cart", methods=["POST"])
127
  def add_to_cart():
 
128
  item_name = request.json.get('item_name')
129
  quantity = request.json.get('quantity')
130